use of io.crate.execution.engine.fetch.ReaderContext in project crate by crate.
the class LongColumnReferenceTest method testLongExpression.
@Test
public void testLongExpression() throws Exception {
LongColumnReference longColumn = new LongColumnReference(column);
longColumn.startCollect(ctx);
longColumn.setNextReader(new ReaderContext(readerContext));
IndexSearcher searcher = new IndexSearcher(readerContext.reader());
TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 20);
long l = Long.MIN_VALUE;
for (ScoreDoc doc : topDocs.scoreDocs) {
longColumn.setNextDocId(doc.doc);
assertThat(longColumn.value(), is(l));
l++;
}
}
use of io.crate.execution.engine.fetch.ReaderContext in project crate by crate.
the class StringColumnReferenceTest method testFieldCacheExpression.
@Test
public void testFieldCacheExpression() throws Exception {
BytesRefColumnReference bytesRefColumn = new BytesRefColumnReference(column);
bytesRefColumn.startCollect(ctx);
bytesRefColumn.setNextReader(new ReaderContext(readerContext));
IndexSearcher searcher = new IndexSearcher(readerContext.reader());
TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 20);
int i = 0;
StringBuilder builder = new StringBuilder();
for (ScoreDoc doc : topDocs.scoreDocs) {
builder.append(i);
bytesRefColumn.setNextDocId(doc.doc);
assertThat(bytesRefColumn.value(), is(builder.toString()));
i++;
}
}
use of io.crate.execution.engine.fetch.ReaderContext in project crate by crate.
the class LuceneBatchIterator method tryAdvanceDocIdSetIterator.
private boolean tryAdvanceDocIdSetIterator() throws IOException {
if (currentDocIdSetIt != null) {
return true;
}
while (leavesIt.hasNext()) {
LeafReaderContext leaf = leavesIt.next();
Scorer scorer = weight.scorer(leaf);
if (scorer == null) {
continue;
}
currentScorer = scorer;
currentLeaf = leaf;
currentDocIdSetIt = scorer.iterator();
var readerContext = new ReaderContext(currentLeaf);
for (LuceneCollectorExpression<?> expression : expressions) {
expression.setScorer(currentScorer);
expression.setNextReader(readerContext);
}
return true;
}
return false;
}
use of io.crate.execution.engine.fetch.ReaderContext in project crate by crate.
the class IpColumnReferenceTest method testIpExpression.
@Test
public void testIpExpression() throws Exception {
IpColumnReference columnReference = new IpColumnReference(IP_COLUMN);
columnReference.startCollect(ctx);
columnReference.setNextReader(new ReaderContext(readerContext));
IndexSearcher searcher = new IndexSearcher(readerContext.reader());
TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 21);
assertThat(topDocs.scoreDocs.length, is(21));
int i = 0;
for (ScoreDoc doc : topDocs.scoreDocs) {
columnReference.setNextDocId(doc.doc);
if (i == 20) {
assertThat(columnReference.value(), is(nullValue()));
} else if (i < 10) {
assertThat(columnReference.value(), is("192.168.0." + i));
} else {
assertThat(columnReference.value(), is("7bd0:8082:2df8:487e:e0df:e7b5:9362:" + Integer.toHexString(i)));
}
i++;
}
}
use of io.crate.execution.engine.fetch.ReaderContext in project crate by crate.
the class IpColumnReferenceTest method testIpExpressionOnArrayThrowsException.
@Test
public void testIpExpressionOnArrayThrowsException() throws Exception {
IpColumnReference columnReference = new IpColumnReference(IP_ARRAY_COLUMN);
columnReference.startCollect(ctx);
columnReference.setNextReader(new ReaderContext(readerContext));
IndexSearcher searcher = new IndexSearcher(readerContext.reader());
TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), 10);
ScoreDoc doc = topDocs.scoreDocs[0];
columnReference.setNextDocId(doc.doc);
expectedException.expect(GroupByOnArrayUnsupportedException.class);
expectedException.expectMessage("Column \"ia\" has a value that is an array. Group by doesn't work on Arrays");
columnReference.value();
}
Aggregations