use of io.zulia.message.ZuliaQuery.ScoredResult in project zuliasearch by zuliaio.
the class QueryCombiner method createLastIndexResultMapWithPreviousLastResults.
private Map<String, ScoredResult[]> createLastIndexResultMapWithPreviousLastResults() {
Map<String, ScoredResult[]> lastIndexResultMap = new HashMap<>();
for (String indexName : indexToShardQueryResponseMap.keySet()) {
int numberOfShards = indexToShardCount.get(indexName);
lastIndexResultMap.put(indexName, new ScoredResult[numberOfShards]);
}
for (LastIndexResult lir : lastResult.getLastIndexResultList()) {
ScoredResult[] lastForShardArr = lastIndexResultMap.get(lir.getIndexName());
// initialize with last results
for (ScoredResult sr : lir.getLastForShardList()) {
lastForShardArr[sr.getShard()] = sr;
}
}
return lastIndexResultMap;
}
use of io.zulia.message.ZuliaQuery.ScoredResult in project zuliasearch by zuliaio.
the class QueryCombiner method createLastResult.
private LastResult createLastResult(Map<String, ScoredResult[]> lastIndexResultMap) {
LastResult.Builder newLastResultBuilder = LastResult.newBuilder();
for (String indexName : lastIndexResultMap.keySet()) {
ScoredResult[] lastForShardArr = lastIndexResultMap.get(indexName);
int numberOfShards = indexToShardCount.get(indexName);
List<ScoredResult> indexList = new ArrayList<>();
for (int shard = 0; shard < numberOfShards; shard++) {
if (lastForShardArr[shard] != null) {
ScoredResult.Builder minimalSR = ScoredResult.newBuilder(lastForShardArr[shard]).clearUniqueId().clearIndexName().clearResultIndex().clearTimestamp().clearResultDocument();
indexList.add(minimalSR.build());
}
}
if (!indexList.isEmpty()) {
LastIndexResult lastIndexResult = LastIndexResult.newBuilder().addAllLastForShard(indexList).setIndexName(indexName).build();
newLastResultBuilder.addLastIndexResult(lastIndexResult);
}
}
return newLastResultBuilder.build();
}
Aggregations