Search in sources :

Example 1 with LastResult

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);
}
Also used : LastIndexResult(io.zulia.message.ZuliaQuery.LastIndexResult) LastResult(io.zulia.message.ZuliaQuery.LastResult) ScoredResult(io.zulia.message.ZuliaQuery.ScoredResult)

Example 2 with LastResult

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();
}
Also used : LastIndexResult(io.zulia.message.ZuliaQuery.LastIndexResult) ArrayList(java.util.ArrayList) LastResult(io.zulia.message.ZuliaQuery.LastResult) ScoredResult(io.zulia.message.ZuliaQuery.ScoredResult)

Aggregations

LastIndexResult (io.zulia.message.ZuliaQuery.LastIndexResult)2 LastResult (io.zulia.message.ZuliaQuery.LastResult)2 ScoredResult (io.zulia.message.ZuliaQuery.ScoredResult)2 ArrayList (java.util.ArrayList)1