use of io.zulia.message.ZuliaQuery.LastResult in project zuliasearch by zuliaio.
the class CursorHelper method getUniqueSortedCursor.
public static String getUniqueSortedCursor(LastResult lastResult) {
LastResult.Builder lastResultBuilder = LastResult.newBuilder();
for (LastIndexResult lastIndexResult : lastResult.getLastIndexResultList()) {
LastIndexResult.Builder lastIndexResultBuilder = LastIndexResult.newBuilder();
lastIndexResultBuilder.setIndexName(lastIndexResult.getIndexName());
for (ScoredResult scoredResult : lastIndexResult.getLastForShardList()) {
ScoredResult.Builder scoredResultBuilder = ScoredResult.newBuilder(scoredResult).clearScore().clearResultDocument();
lastIndexResultBuilder.addLastForShard(scoredResultBuilder);
}
lastResultBuilder.addLastIndexResult(lastIndexResultBuilder);
}
return new String(Base64.getEncoder().encode(lastResultBuilder.build().toByteArray()), StandardCharsets.UTF_8);
}
use of io.zulia.message.ZuliaQuery.LastResult 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