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());
}
Aggregations