use of io.crate.expression.reference.doc.lucene.IpColumnReference in project crate by crate.
the class IpColumnReferenceTest method testNullDocValuesDoNotResultInNPE.
@Test
public void testNullDocValuesDoNotResultInNPE() throws IOException {
IpColumnReference ref = new IpColumnReference("missing_column");
ref.startCollect(ctx);
ref.setNextReader(new ReaderContext(readerContext));
ref.setNextDocId(0);
assertThat(ref.value(), Matchers.nullValue());
}
use of io.crate.expression.reference.doc.lucene.IpColumnReference 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.expression.reference.doc.lucene.IpColumnReference 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