use of io.crate.operation.reference.doc.lucene.OrderByCollectorExpression in project crate by crate.
the class ScoreDocRowFunction method apply.
@Nullable
@Override
public Row apply(@Nullable ScoreDoc input) {
if (input == null) {
return null;
}
FieldDoc fieldDoc = (FieldDoc) input;
scorer.score(fieldDoc.score);
for (OrderByCollectorExpression orderByCollectorExpression : orderByCollectorExpressions) {
orderByCollectorExpression.setNextFieldDoc(fieldDoc);
}
List<LeafReaderContext> leaves = indexReader.leaves();
int readerIndex = ReaderUtil.subIndex(fieldDoc.doc, leaves);
LeafReaderContext subReaderContext = leaves.get(readerIndex);
int subDoc = fieldDoc.doc - subReaderContext.docBase;
for (LuceneCollectorExpression<?> expression : expressions) {
try {
expression.setNextReader(subReaderContext);
} catch (IOException e) {
throw Throwables.propagate(e);
}
expression.setNextDocId(subDoc);
}
return inputRow;
}
use of io.crate.operation.reference.doc.lucene.OrderByCollectorExpression in project crate by crate.
the class DocInputFactory method extractImplementations.
public InputFactory.Context<? extends LuceneCollectorExpression<?>> extractImplementations(RoutedCollectPhase phase) {
OrderBy orderBy = phase.orderBy();
ReferenceResolver<? extends LuceneCollectorExpression<?>> refResolver;
if (orderBy == null) {
refResolver = referenceResolver;
} else {
refResolver = ref -> {
if (orderBy.orderBySymbols().contains(ref)) {
return new OrderByCollectorExpression(ref, orderBy);
}
return referenceResolver.getImplementation(ref);
};
}
InputFactory.Context<? extends LuceneCollectorExpression<?>> ctx = inputFactory.ctxForRefs(refResolver);
ctx.add(phase.toCollect());
return ctx;
}
use of io.crate.operation.reference.doc.lucene.OrderByCollectorExpression in project crate by crate.
the class OrderedLuceneBatchIteratorFactoryTest method createOrderedCollector.
private LuceneOrderedDocCollector createOrderedCollector(IndexSearcher searcher, int shardId) {
CollectorContext collectorContext = new CollectorContext(mock(IndexFieldDataService.class), new CollectorFieldsVisitor(0));
List<LuceneCollectorExpression<?>> expressions = Collections.singletonList(new OrderByCollectorExpression(reference, orderBy));
return new LuceneOrderedDocCollector(new ShardId("dummy", shardId), searcher, new MatchAllDocsQuery(), null, false, // batchSize < 10 to have at least one searchMore call.
5, fieldTypeLookup, collectorContext, orderBy, new Sort(new SortedNumericSortField(columnName, SortField.Type.LONG, reverseFlags[0])), expressions, expressions);
}
Aggregations