use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class ItemEncodingTestCase method testAndItemEncoding.
@Test
public void testAndItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
AndItem and = new AndItem();
and.addItem(a);
and.addItem(b);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = and.encode(buffer);
buffer.flip();
assertEquals("Serialization count", 3, count);
assertType(buffer, 1, 0);
assertEquals("And arity", 2, buffer.get());
assertWord(buffer, "a");
assertWord(buffer, "b");
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class ItemEncodingTestCase method testWordItemEncoding.
@Test
public void testWordItemEncoding() {
WordItem word = new WordItem("test");
word.setWeight(150);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = word.encode(buffer);
buffer.flip();
assertEquals("Serialization count", 1, count);
assertType(buffer, 4, 1);
assertWeight(buffer, 150);
assertEquals("Index length", 0, buffer.get());
assertEquals("Word length", 4, buffer.get());
assertEquals("Word length", 4, buffer.remaining());
assertEquals('t', buffer.get());
assertEquals('e', buffer.get());
assertEquals('s', buffer.get());
assertEquals('t', buffer.get());
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class ItemEncodingTestCase method testNearItemEncoding.
@Test
public void testNearItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
NearItem near = new NearItem(7);
near.addItem(a);
near.addItem(b);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = near.encode(buffer);
buffer.flip();
assertEquals("Serialization count", 3, count);
assertType(buffer, 11, 0);
assertEquals("Near arity", 2, buffer.get());
assertEquals("Limit", 7, buffer.get());
assertWord(buffer, "a");
assertWord(buffer, "b");
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class ItemEncodingTestCase method testFilterWordItemEncoding.
@Test
public void testFilterWordItemEncoding() {
WordItem word = new WordItem("test");
word.setFilter(true);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = word.encode(buffer);
buffer.flip();
assertEquals("Serialization count", 1, count);
assertType(buffer, 4, 4);
assertEquals(0x08, buffer.get());
assertEquals("Index length", 0, buffer.get());
assertEquals("Word length", 4, buffer.get());
assertEquals("Word length", 4, buffer.remaining());
assertEquals('t', buffer.get());
assertEquals('e', buffer.get());
assertEquals('s', buffer.get());
assertEquals('t', buffer.get());
}
use of com.yahoo.prelude.query.WordItem in project vespa by vespa-engine.
the class ItemEncodingTestCase method testEquivItemEncoding.
@Test
public void testEquivItemEncoding() {
WordItem a = new WordItem("a");
WordItem b = new WordItem("b");
EquivItem equiv = new EquivItem();
equiv.addItem(a);
equiv.addItem(b);
ByteBuffer buffer = ByteBuffer.allocate(128);
int count = equiv.encode(buffer);
buffer.flip();
assertEquals("Serialization count", 3, count);
assertType(buffer, 14, 0);
assertEquals("Equiv arity", 2, buffer.get());
assertWord(buffer, "a");
assertWord(buffer, "b");
}
Aggregations