use of org.apache.lucene.store.ByteBuffersDirectory in project crate by crate.
the class OrderedLuceneBatchIteratorFactoryTest method prepareSearchers.
@Before
public void prepareSearchers() throws Exception {
IndexWriter iw1 = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
IndexWriter iw2 = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
expectedResult = LongStream.range(0, 20).mapToObj(i -> new Object[] { i }).collect(Collectors.toList());
// expect descending order to differentiate between insert order
expectedResult.sort(Comparator.comparingLong((Object[] o) -> ((long) o[0])).reversed());
for (int i = 0; i < 20; i++) {
Document doc = new Document();
doc.add(new NumericDocValuesField(columnName, i));
if (i % 2 == 0) {
iw1.addDocument(doc);
} else {
iw2.addDocument(doc);
}
}
iw1.commit();
iw2.commit();
searcher1 = new IndexSearcher(DirectoryReader.open(iw1));
searcher2 = new IndexSearcher(DirectoryReader.open(iw2));
orderBy = new OrderBy(Collections.singletonList(reference), reverseFlags, nullsFirst);
}
use of org.apache.lucene.store.ByteBuffersDirectory in project crate by crate.
the class DocValuesGroupByOptimizedIteratorTest method setup.
@Before
public void setup() throws IOException {
var nodeContext = createNodeContext();
functions = nodeContext.functions();
var indexWriter = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig());
for (var row : rows) {
Document doc = new Document();
doc.add(new SortedSetDocValuesField("x", BytesRefs.toBytesRef(row[0])));
doc.add(new NumericDocValuesField("y", (Long) row[1]));
doc.add(new NumericDocValuesField("z", (Long) row[2]));
indexWriter.addDocument(doc);
}
indexWriter.commit();
indexSearcher = new IndexSearcher(DirectoryReader.open(indexWriter));
}
use of org.apache.lucene.store.ByteBuffersDirectory in project crate by crate.
the class LuceneBatchIteratorTest method prepareSearcher.
@Before
public void prepareSearcher() throws Exception {
IndexWriter iw = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
String columnName = "x";
expectedResult = new ArrayList<>(20);
for (long i = 0; i < 20; i++) {
Document doc = new Document();
doc.add(new NumericDocValuesField(columnName, i));
iw.addDocument(doc);
expectedResult.add(new Object[] { i });
}
iw.commit();
indexSearcher = new IndexSearcher(DirectoryReader.open(iw));
LongColumnReference columnReference = new LongColumnReference(columnName);
columnRefs = Collections.singletonList(columnReference);
}
use of org.apache.lucene.store.ByteBuffersDirectory in project crate by crate.
the class GroupByOptimizedIteratorTest method testHighCardinalityRatioReturnsTrueForHighCardinality.
@Test
public void testHighCardinalityRatioReturnsTrueForHighCardinality() throws Exception {
IndexWriter iw = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
String columnName = "x";
for (int i = 0; i < 10; i++) {
Document doc = new Document();
BytesRef value = new BytesRef(Integer.toString(i));
doc.add(new Field(columnName, value, KeywordFieldMapper.Defaults.FIELD_TYPE));
iw.addDocument(doc);
}
iw.commit();
IndexSearcher indexSearcher = new IndexSearcher(DirectoryReader.open(iw));
assertThat(GroupByOptimizedIterator.hasHighCardinalityRatio(() -> new Engine.Searcher("dummy", indexSearcher.getIndexReader(), indexSearcher.getQueryCache(), indexSearcher.getQueryCachingPolicy(), () -> {
}), "x"), is(true));
}
use of org.apache.lucene.store.ByteBuffersDirectory in project crate by crate.
the class GroupByOptimizedIteratorTest method prepare.
@Before
public void prepare() throws Exception {
NodeContext nodeCtx = createNodeContext();
IndexWriter iw = new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
columnName = "x";
expectedResult = new ArrayList<>(20);
for (long i = 0; i < 20; i++) {
Document doc = new Document();
String val = "val_" + i;
doc.add(new SortedSetDocValuesField(columnName, new BytesRef(val)));
iw.addDocument(doc);
expectedResult.add(new Object[] { val, 1L });
}
iw.commit();
indexSearcher = new IndexSearcher(DirectoryReader.open(iw));
inExpr = new InputCollectExpression(0);
CountAggregation aggregation = (CountAggregation) nodeCtx.functions().getQualified(CountAggregation.COUNT_STAR_SIGNATURE, Collections.emptyList(), CountAggregation.COUNT_STAR_SIGNATURE.getReturnType().createType());
aggregationContexts = List.of(new AggregationContext(aggregation, () -> true, List.of()));
}
Aggregations