Search in sources :

Example 1 with OptimizeQueryForSearchAfter

use of io.crate.execution.engine.collect.collectors.OptimizeQueryForSearchAfter in project crate by crate.

the class LuceneShardCollectorProvider method getOrderedCollector.

@Override
public OrderedDocCollector getOrderedCollector(RoutedCollectPhase phase, SharedShardContext sharedShardContext, CollectTask collectTask, boolean requiresRepeat) {
    RoutedCollectPhase collectPhase = phase.normalize(shardNormalizer, collectTask.txnCtx());
    CollectorContext collectorContext;
    InputFactory.Context<? extends LuceneCollectorExpression<?>> ctx;
    var searcher = sharedShardContext.acquireSearcher("ordered-collector: " + formatSource(phase));
    collectTask.addSearcher(sharedShardContext.readerId(), searcher);
    IndexService indexService = sharedShardContext.indexService();
    QueryShardContext queryShardContext = indexService.newQueryShardContext();
    final var queryContext = luceneQueryBuilder.convert(collectPhase.where(), collectTask.txnCtx(), indexService.mapperService(), indexShard.shardId().getIndexName(), queryShardContext, table, indexService.cache());
    ctx = docInputFactory.extractImplementations(collectTask.txnCtx(), collectPhase);
    collectorContext = new CollectorContext(sharedShardContext.readerId());
    int batchSize = collectPhase.shardQueueSize(localNodeId.get());
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("[{}][{}] creating LuceneOrderedDocCollector. Expected number of rows to be collected: {}", sharedShardContext.indexShard().routingEntry().currentNodeId(), sharedShardContext.indexShard().shardId(), batchSize);
    }
    OptimizeQueryForSearchAfter optimizeQueryForSearchAfter = new OptimizeQueryForSearchAfter(collectPhase.orderBy(), queryContext.queryShardContext(), fieldTypeLookup);
    return new LuceneOrderedDocCollector(indexShard.shardId(), searcher.item(), queryContext.query(), queryContext.minScore(), Symbols.containsColumn(collectPhase.toCollect(), DocSysColumns.SCORE), batchSize, collectTask.getRamAccounting(), collectorContext, optimizeQueryForSearchAfter, LuceneSortGenerator.generateLuceneSort(collectTask.txnCtx(), collectorContext, collectPhase.orderBy(), docInputFactory, fieldTypeLookup), ctx.topLevelInputs(), ctx.expressions());
}
Also used : InputFactory(io.crate.expression.InputFactory) OptimizeQueryForSearchAfter(io.crate.execution.engine.collect.collectors.OptimizeQueryForSearchAfter) IndexService(org.elasticsearch.index.IndexService) QueryShardContext(org.elasticsearch.index.query.QueryShardContext) CollectorContext(io.crate.expression.reference.doc.lucene.CollectorContext) LuceneOrderedDocCollector(io.crate.execution.engine.collect.collectors.LuceneOrderedDocCollector) RoutedCollectPhase(io.crate.execution.dsl.phases.RoutedCollectPhase)

Aggregations

RoutedCollectPhase (io.crate.execution.dsl.phases.RoutedCollectPhase)1 LuceneOrderedDocCollector (io.crate.execution.engine.collect.collectors.LuceneOrderedDocCollector)1 OptimizeQueryForSearchAfter (io.crate.execution.engine.collect.collectors.OptimizeQueryForSearchAfter)1 InputFactory (io.crate.expression.InputFactory)1 CollectorContext (io.crate.expression.reference.doc.lucene.CollectorContext)1 IndexService (org.elasticsearch.index.IndexService)1 QueryShardContext (org.elasticsearch.index.query.QueryShardContext)1