use of io.crate.operation.reference.doc.lucene.IntegerColumnReference in project crate by crate.
the class LuceneBatchIteratorBenchmark method createLuceneBatchIterator.
@Setup
public void createLuceneBatchIterator() throws Exception {
IndexWriter iw = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
String columnName = "x";
for (int i = 0; i < 10_000_000; i++) {
Document doc = new Document();
doc.add(new NumericDocValuesField(columnName, i));
iw.addDocument(doc);
}
iw.commit();
iw.forceMerge(1, true);
indexSearcher = new IndexSearcher(DirectoryReader.open(iw, true));
IntegerColumnReference columnReference = new IntegerColumnReference(columnName);
columnRefs = Collections.singletonList(columnReference);
collectorContext = new CollectorContext(mock(IndexFieldDataService.class), new CollectorFieldsVisitor(0));
}
use of io.crate.operation.reference.doc.lucene.IntegerColumnReference in project crate by crate.
the class IntegerColumnReferenceTest method testIntegerExpression.
@Test
public void testIntegerExpression() throws Exception {
IntegerColumnReference integerColumn = new IntegerColumnReference(column);
integerColumn.startCollect(ctx);
integerColumn.setNextReader(readerContext);
IndexSearcher searcher = new IndexSearcher(readerContext.reader());
TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 20);
int i = -10;
for (ScoreDoc doc : topDocs.scoreDocs) {
integerColumn.setNextDocId(doc.doc);
assertThat(integerColumn.value(), is(i));
i++;
}
}
Aggregations