Search in sources :

Example 1 with WeakAndItem

use of com.yahoo.prelude.query.WeakAndItem in project vespa by vespa-engine.

the class YqlParser method buildWeakAnd.

@NonNull
private CompositeItem buildWeakAnd(OperatorNode<ExpressionOperator> spec) {
    WeakAndItem weakAnd = new WeakAndItem();
    Integer targetNumHits = getAnnotation(spec, TARGET_NUM_HITS, Integer.class, null, "desired minimum hits to produce");
    if (targetNumHits != null) {
        weakAnd.setN(targetNumHits);
    }
    Integer scoreThreshold = getAnnotation(spec, SCORE_THRESHOLD, Integer.class, null, "min dot product score for hit inclusion");
    if (scoreThreshold != null) {
        weakAnd.setScoreThreshold(scoreThreshold);
    }
    return convertVarArgs(spec, 1, weakAnd);
}
Also used : BigInteger(java.math.BigInteger) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Example 2 with WeakAndItem

use of com.yahoo.prelude.query.WeakAndItem in project vespa by vespa-engine.

the class ItemEncodingTestCase method testWandItemEncoding.

@Test
public void testWandItemEncoding() {
    WordItem a = new WordItem("a");
    WordItem b = new WordItem("b");
    WeakAndItem wand = new WeakAndItem();
    wand.addItem(a);
    wand.addItem(b);
    ByteBuffer buffer = ByteBuffer.allocate(128);
    int count = wand.encode(buffer);
    buffer.flip();
    assertEquals("Serialization count", 3, count);
    assertType(buffer, 16, 0);
    assertEquals("WeakAnd arity", 2, buffer.get());
    assertEquals("WeakAnd N", 100, buffer.getShort() & 0x3fff);
    assertEquals(0, buffer.get());
    assertWord(buffer, "a");
    assertWord(buffer, "b");
}
Also used : MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) ByteBuffer(java.nio.ByteBuffer) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) Test(org.junit.Test)

Aggregations

WeakAndItem (com.yahoo.prelude.query.WeakAndItem)2 MarkerWordItem (com.yahoo.prelude.query.MarkerWordItem)1 WordItem (com.yahoo.prelude.query.WordItem)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 BigInteger (java.math.BigInteger)1 ByteBuffer (java.nio.ByteBuffer)1 Test (org.junit.Test)1