Search in sources :

Example 1 with CrateDocCollectorBuilder

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

the class LuceneShardCollectorProvider method getBuilder.

@Override
protected CrateCollector.Builder getBuilder(RoutedCollectPhase collectPhase, boolean requiresScroll, JobCollectContext jobCollectContext) {
    SharedShardContext sharedShardContext = jobCollectContext.sharedShardContexts().getOrCreateContext(indexShard.shardId());
    Engine.Searcher searcher = sharedShardContext.acquireSearcher();
    IndexShard indexShard = sharedShardContext.indexShard();
    try {
        LuceneQueryBuilder.Context queryContext = luceneQueryBuilder.convert(collectPhase.whereClause(), indexShard.mapperService(), indexShard.indexFieldDataService(), indexShard.indexService().cache());
        jobCollectContext.addSearcher(sharedShardContext.readerId(), searcher);
        InputFactory.Context<? extends LuceneCollectorExpression<?>> docCtx = docInputFactory.extractImplementations(collectPhase);
        return new CrateDocCollectorBuilder(searcher.searcher(), queryContext.query(), queryContext.minScore(), Symbols.containsColumn(collectPhase.toCollect(), DocSysColumns.SCORE), getCollectorContext(sharedShardContext.readerId(), docCtx), jobCollectContext.queryPhaseRamAccountingContext(), docCtx.topLevelInputs(), docCtx.expressions());
    } catch (Throwable t) {
        searcher.close();
        throw t;
    }
}
Also used : InputFactory(io.crate.operation.InputFactory) IndexShard(org.elasticsearch.index.shard.IndexShard) LuceneQueryBuilder(io.crate.lucene.LuceneQueryBuilder) SharedShardContext(io.crate.action.job.SharedShardContext) Engine(org.elasticsearch.index.engine.Engine) CrateDocCollectorBuilder(io.crate.operation.collect.collectors.CrateDocCollectorBuilder)

Aggregations

SharedShardContext (io.crate.action.job.SharedShardContext)1 LuceneQueryBuilder (io.crate.lucene.LuceneQueryBuilder)1 InputFactory (io.crate.operation.InputFactory)1 CrateDocCollectorBuilder (io.crate.operation.collect.collectors.CrateDocCollectorBuilder)1 Engine (org.elasticsearch.index.engine.Engine)1 IndexShard (org.elasticsearch.index.shard.IndexShard)1