use of io.crate.execution.engine.collect.collectors.LuceneBatchIterator in project crate by crate.
the class QueryTester method runQuery.
public List<Object> runQuery(String resultColumn, String expression, Object... params) throws Exception {
Query query = toQuery(expression, params);
LuceneBatchIterator batchIterator = getIterator.apply(ColumnIdent.fromPath(resultColumn), query);
return BatchIterators.collect(batchIterator, Collectors.mapping(row -> row.get(0), Collectors.toList())).get(5, TimeUnit.SECONDS);
}
use of io.crate.execution.engine.collect.collectors.LuceneBatchIterator in project crate by crate.
the class LuceneShardCollectorProvider method getUnorderedIterator.
@Override
protected BatchIterator<Row> getUnorderedIterator(RoutedCollectPhase collectPhase, boolean requiresScroll, CollectTask collectTask) {
ShardId shardId = indexShard.shardId();
SharedShardContext sharedShardContext = collectTask.sharedShardContexts().getOrCreateContext(shardId);
var searcher = sharedShardContext.acquireSearcher("unordered-iterator: " + formatSource(collectPhase));
collectTask.addSearcher(sharedShardContext.readerId(), searcher);
IndexShard sharedShardContextShard = sharedShardContext.indexShard();
// A closed shard has no mapper service and cannot be queried with lucene,
// therefore skip it
boolean isClosed = sharedShardContextShard.mapperService() == null;
if (isClosed) {
return InMemoryBatchIterator.empty(SentinelRow.SENTINEL);
}
QueryShardContext queryShardContext = sharedShardContext.indexService().newQueryShardContext();
LuceneQueryBuilder.Context queryContext = luceneQueryBuilder.convert(collectPhase.where(), collectTask.txnCtx(), sharedShardContextShard.mapperService(), sharedShardContextShard.shardId().getIndexName(), queryShardContext, table, sharedShardContext.indexService().cache());
InputFactory.Context<? extends LuceneCollectorExpression<?>> docCtx = docInputFactory.extractImplementations(collectTask.txnCtx(), collectPhase);
return new LuceneBatchIterator(searcher.item(), queryContext.query(), queryContext.minScore(), Symbols.containsColumn(collectPhase.toCollect(), DocSysColumns.SCORE), new CollectorContext(sharedShardContext.readerId()), docCtx.topLevelInputs(), docCtx.expressions());
}
Aggregations