Search in sources :

Example 16 with PredicateQueryItem

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;
}
Also used : PredicateQueryItem(com.yahoo.prelude.query.PredicateQueryItem)

Example 17 with PredicateQueryItem

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());
}
Also used : PredicateQueryItem(com.yahoo.prelude.query.PredicateQueryItem) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Aggregations

PredicateQueryItem (com.yahoo.prelude.query.PredicateQueryItem)17 Test (org.junit.Test)12 ByteBuffer (java.nio.ByteBuffer)2 Query (com.yahoo.search.Query)1 Result (com.yahoo.search.Result)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 BigInteger (java.math.BigInteger)1