use of com.yahoo.prelude.query.PredicateQueryItem in project vespa by vespa-engine.
the class BooleanAttributeParserTest method assertParse.
private PredicateQueryItem assertParse(String s, int numFeatures) {
PredicateQueryItem item = new PredicateQueryItem();
BooleanAttributeParser parser = new BooleanSearcher.PredicateValueAttributeParser(item);
parser.parse(s);
assertEquals(numFeatures, item.getFeatures().size());
return item;
}
use of com.yahoo.prelude.query.PredicateQueryItem in project vespa by vespa-engine.
the class BooleanAttributeParserTest method requireThatTermsCanHaveBitmaps.
@Test
public void requireThatTermsCanHaveBitmaps() throws Exception {
PredicateQueryItem q = assertParse("{foo:bar:0x1}", 1);
PredicateQueryItem.Entry[] features = new PredicateQueryItem.Entry[q.getFeatures().size()];
q.getFeatures().toArray(features);
assertEquals(1l, q.getFeatures().iterator().next().getSubQueryBitmap());
q = assertParse("{foo:bar:0x1, baz:qux:0xf}", 2);
Iterator<PredicateQueryItem.Entry> it = q.getFeatures().iterator();
assertEquals(1l, it.next().getSubQueryBitmap());
assertEquals(15l, it.next().getSubQueryBitmap());
q = assertParse("{foo:bar:0xffffffffffffffff}", 1);
assertEquals(-1l, q.getFeatures().iterator().next().getSubQueryBitmap());
q = assertParse("{foo:bar:[63]}", 1);
assertEquals(new BigInteger("ffffffffffffffff", 16).shiftRight(1).add(BigInteger.ONE).longValue(), q.getFeatures().iterator().next().getSubQueryBitmap());
q = assertParse("{foo:bar:0x7fffffffffffffff}", 1);
assertEquals(new BigInteger("ffffffffffffffff", 16).shiftRight(1).longValue(), q.getFeatures().iterator().next().getSubQueryBitmap());
q = assertParse("{foo:bar:[0]}", 1);
assertEquals(1l, q.getFeatures().iterator().next().getSubQueryBitmap());
q = assertParse("{foo:bar:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}", 1);
assertEquals(1l, q.getFeatures().iterator().next().getSubQueryBitmap());
q = assertParse("{foo:bar:[0,2,6,8]}", 1);
assertEquals(0x145l, q.getFeatures().iterator().next().getSubQueryBitmap());
q = assertParse("{foo:[bar:[0,8,6,2],baz:[1,3,4,15]]}", 2);
it = q.getFeatures().iterator();
assertEquals(0x145l, it.next().getSubQueryBitmap());
assertEquals(0x801al, it.next().getSubQueryBitmap());
}
Aggregations