use of com.yahoo.prelude.query.EquivItem 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");
}
use of com.yahoo.prelude.query.EquivItem in project vespa by vespa-engine.
the class SerializeItemTestCase method serialize_unique_id.
@Test
public void serialize_unique_id() throws ParseException {
EquivItem equivItem = new EquivItem();
equivItem.setUniqueID(42);
EquivItem deSerialized = serializeThenParse(equivItem);
assertThat(deSerialized.getUniqueID(), is(42));
}
use of com.yahoo.prelude.query.EquivItem in project vespa by vespa-engine.
the class SerializeItemTestCase method serialize_weight.
@Test
public void serialize_weight() throws ParseException {
EquivItem equivItem = new EquivItem();
equivItem.setWeight(42);
EquivItem deSerialized = serializeThenParse(equivItem);
assertThat(deSerialized.getWeight(), is(42));
}
use of com.yahoo.prelude.query.EquivItem in project vespa by vespa-engine.
the class YqlParser method instantiateEquivItem.
@NonNull
private Item instantiateEquivItem(String field, OperatorNode<ExpressionOperator> ast) {
List<OperatorNode<ExpressionOperator>> args = ast.getArgument(1);
Preconditions.checkArgument(args.size() >= 2, "Expected 2 or more arguments, got %s.", args.size());
EquivItem equiv = new EquivItem();
equiv.setIndexName(field);
for (OperatorNode<ExpressionOperator> arg : args) {
switch(arg.getOperator()) {
case LITERAL:
equiv.addItem(instantiateWordItem(field, arg, equiv.getClass()));
break;
case CALL:
assertHasFunctionName(arg, PHRASE);
equiv.addItem(instantiatePhraseItem(field, arg));
break;
default:
throw newUnexpectedArgumentException(arg.getOperator(), ExpressionOperator.CALL, ExpressionOperator.LITERAL);
}
}
return leafStyleSettings(ast, equiv);
}
use of com.yahoo.prelude.query.EquivItem in project vespa by vespa-engine.
the class SerializeItemTestCase method serialize_significance.
@Test
public void serialize_significance() throws ParseException {
EquivItem equivItem = new EquivItem();
equivItem.setSignificance(24.2);
EquivItem deSerialized = serializeThenParse(equivItem);
assertThat(deSerialized.getSignificance(), is(24.2));
}
Aggregations