anuragaw commented on a change in pull request #3306: server: reduce execution
time while listing project if projects have many resource tags
URL: https://github.com/apache/cloudstack/pull/3306#discussion_r298791786
##########
File path: server/src/main/java/com/cloud/api/query/dao/ProjectJoinDaoImpl.java
##########
@@ -101,14 +99,6 @@ public ProjectResponse newProjectResponse(ProjectJoinVO
proj) {
@Override
public ProjectResponse setProjectResponse(ProjectResponse rsp,
ProjectJoinVO proj) {
Review comment:
This method seems to be called in the following path -
`ViewResponseHelper#createProjectResponse() >
ApiDBUtils#fillProjectDetails() > ProjectJoinDaoImpl#setProjectResponse`
I am a little confused by the necessity of this method call at all. Read the
below method definitions-
```
ApiDBUtils {
public static ProjectResponse fillProjectDetails(ProjectResponse rsp,
ProjectJoinVO proj) {
return s_projectJoinDao.setProjectResponse(rsp, proj);
}
}
ViewResponseHelper {
public static List<ProjectResponse>
createProjectResponse(ProjectJoinVO... projects) {
Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<Long,
ProjectResponse>();
// Initialise the prjdatalist with the input data
for (ProjectJoinVO p : projects) {
ProjectResponse pData = prjDataList.get(p.getId());
if (pData == null) {
// first time encountering this vm
pData = ApiDBUtils.newProjectResponse(p);
} else {
// update those 1 to many mapping fields
pData = ApiDBUtils.fillProjectDetails(pData, p);
}
prjDataList.put(p.getId(), pData);
}
return new ArrayList<ProjectResponse>(prjDataList.values());
}
}
```
Why not simply delete this path and modify the ViewResponseHelper to
generate the projects response list at one go?
Apologies if I am missing something obvious?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services