Search in sources :

Example 1 with LuceneOrderedDocCollector

use of io.crate.operation.collect.collectors.LuceneOrderedDocCollector in project crate by crate.

the class LuceneShardCollectorProvider method getOrderedCollector.

@Override
public OrderedDocCollector getOrderedCollector(RoutedCollectPhase phase, SharedShardContext sharedShardContext, JobCollectContext jobCollectContext, boolean requiresRepeat) {
    RoutedCollectPhase collectPhase = phase.normalize(shardNormalizer, null);
    CollectorContext collectorContext;
    InputFactory.Context<? extends LuceneCollectorExpression<?>> ctx;
    Engine.Searcher searcher = null;
    LuceneQueryBuilder.Context queryContext;
    try {
        searcher = sharedShardContext.acquireSearcher();
        IndexService indexService = sharedShardContext.indexService();
        queryContext = luceneQueryBuilder.convert(collectPhase.whereClause(), indexService.mapperService(), indexService.fieldData(), indexService.cache());
        jobCollectContext.addSearcher(sharedShardContext.readerId(), searcher);
        ctx = docInputFactory.extractImplementations(collectPhase);
        collectorContext = getCollectorContext(sharedShardContext.readerId(), ctx);
    } catch (Throwable t) {
        if (searcher != null) {
            searcher.close();
        }
        throw t;
    }
    int batchSize = collectPhase.shardQueueSize(localNodeId);
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("[{}][{}] creating LuceneOrderedDocCollector. Expected number of rows to be collected: {}", sharedShardContext.indexShard().routingEntry().currentNodeId(), sharedShardContext.indexShard().shardId(), batchSize);
    }
    return new LuceneOrderedDocCollector(indexShard.shardId(), searcher.searcher(), queryContext.query(), queryContext.minScore(), Symbols.containsColumn(collectPhase.toCollect(), DocSysColumns.SCORE), batchSize, fieldTypeLookup, collectorContext, collectPhase.orderBy(), LuceneSortGenerator.generateLuceneSort(collectorContext, collectPhase.orderBy(), docInputFactory, fieldTypeLookup), ctx.topLevelInputs(), ctx.expressions());
}
Also used : InputFactory(io.crate.operation.InputFactory) IndexService(org.elasticsearch.index.IndexService) LuceneQueryBuilder(io.crate.lucene.LuceneQueryBuilder) CollectorContext(io.crate.operation.reference.doc.lucene.CollectorContext) LuceneOrderedDocCollector(io.crate.operation.collect.collectors.LuceneOrderedDocCollector) Engine(org.elasticsearch.index.engine.Engine) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase)

Aggregations

LuceneQueryBuilder (io.crate.lucene.LuceneQueryBuilder)1 InputFactory (io.crate.operation.InputFactory)1 LuceneOrderedDocCollector (io.crate.operation.collect.collectors.LuceneOrderedDocCollector)1 CollectorContext (io.crate.operation.reference.doc.lucene.CollectorContext)1 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)1 IndexService (org.elasticsearch.index.IndexService)1 Engine (org.elasticsearch.index.engine.Engine)1