Skip to content

Commit

Permalink
Update variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Apr 19, 2024
1 parent 065b192 commit 7f11579
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions engine/schema/src/main/java/com/cloud/host/dao/HostTagsDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
protected final SearchBuilder<HostTagVO> HostSearch;
protected final GenericSearchBuilder<HostTagVO, String> DistinctImplictTagsSearch;
private final SearchBuilder<HostTagVO> stSearch;
private final SearchBuilder<HostTagVO> stIdSearch;
private final SearchBuilder<HostTagVO> tagIdsearch;
private final SearchBuilder<HostTagVO> ImplicitTagsSearch;

@Inject
Expand All @@ -64,9 +64,9 @@ public HostTagsDaoImpl() {
stSearch.and("idIN", stSearch.entity().getId(), SearchCriteria.Op.IN);
stSearch.done();

stIdSearch = createSearchBuilder();
stIdSearch.and("id", stIdSearch.entity().getId(), SearchCriteria.Op.EQ);
stIdSearch.done();
tagIdsearch = createSearchBuilder();
tagIdsearch.and("id", tagIdsearch.entity().getId(), SearchCriteria.Op.EQ);
tagIdsearch.done();

ImplicitTagsSearch = createSearchBuilder();
ImplicitTagsSearch.and("hostId", ImplicitTagsSearch.entity().getHostId(), SearchCriteria.Op.EQ);
Expand Down Expand Up @@ -182,21 +182,21 @@ public HostTagResponse newHostTagResponse(HostTagVO tag) {
}

@Override
public List<HostTagVO> searchByIds(Long... stIds) {
public List<HostTagVO> searchByIds(Long... tagIds) {
String batchCfg = _configDao.getValue("detail.batch.query.size");

final int detailsBatchSize = batchCfg != null ? Integer.parseInt(batchCfg) : 2000;

// query details by batches
List<HostTagVO> uvList = new ArrayList<HostTagVO>();
List<HostTagVO> tagList = new ArrayList<>();
int curr_index = 0;

if (stIds.length > detailsBatchSize) {
while ((curr_index + detailsBatchSize) <= stIds.length) {
if (tagIds.length > detailsBatchSize) {
while ((curr_index + detailsBatchSize) <= tagIds.length) {
Long[] ids = new Long[detailsBatchSize];

for (int k = 0, j = curr_index; j < curr_index + detailsBatchSize; j++, k++) {
ids[k] = stIds[j];
ids[k] = tagIds[j];
}

SearchCriteria<HostTagVO> sc = stSearch.create();
Expand All @@ -206,33 +206,33 @@ public List<HostTagVO> searchByIds(Long... stIds) {
List<HostTagVO> vms = searchIncludingRemoved(sc, null, null, false);

if (vms != null) {
uvList.addAll(vms);
tagList.addAll(vms);
}

curr_index += detailsBatchSize;
}
}

if (curr_index < stIds.length) {
int batch_size = (stIds.length - curr_index);
if (curr_index < tagIds.length) {
int batch_size = (tagIds.length - curr_index);
// set the ids value
Long[] ids = new Long[batch_size];

for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
ids[k] = stIds[j];
ids[k] = tagIds[j];
}

SearchCriteria<HostTagVO> sc = stSearch.create();

sc.setParameters("idIN", (Object[])ids);

List<HostTagVO> vms = searchIncludingRemoved(sc, null, null, false);
List<HostTagVO> tags = searchIncludingRemoved(sc, null, null, false);

if (vms != null) {
uvList.addAll(vms);
if (tags != null) {
tagList.addAll(tags);
}
}

return uvList;
return tagList;
}
}

0 comments on commit 7f11579

Please sign in to comment.