Search in sources :

Example 1 with LastIndexResult

use of io.zulia.message.ZuliaQuery.LastIndexResult 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 LastIndexResult

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

Example 3 with LastIndexResult

use of io.zulia.message.ZuliaQuery.LastIndexResult 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)3 ScoredResult (io.zulia.message.ZuliaQuery.ScoredResult)3 LastResult (io.zulia.message.ZuliaQuery.LastResult)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1