Search in sources :

Example 21 with LongFieldValue

use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.

the class Base64DecodeTestCase method requireThatInputIsDecoded.

@Test
public void requireThatInputIsDecoded() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("zcIoHQ"));
    new Base64DecodeExpression().execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof LongFieldValue);
    assertEquals(489210573L, ((LongFieldValue) val).getLong());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 22 with LongFieldValue

use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.

the class Base64EncodeTestCase method requireThatInputIsEncoded.

@Test
public void requireThatInputIsEncoded() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new LongFieldValue(489210573L));
    new Base64EncodeExpression().execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof StringFieldValue);
    assertEquals("zcIoHQAAAAA=", ((StringFieldValue) val).getString());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 23 with LongFieldValue

use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.

the class HexDecodeTestCase method requireThatLargeInputIsDecoded.

@Test
public void requireThatLargeInputIsDecoded() {
    ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
    ctx.setValue(new StringFieldValue("ff7a3c87fd74abff"));
    new HexDecodeExpression().execute(ctx);
    FieldValue val = ctx.getValue();
    assertTrue(val instanceof LongFieldValue);
    assertEquals(-37651092108694529L, ((LongFieldValue) val).getLong());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue) Test(org.junit.Test)

Example 24 with LongFieldValue

use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.

the class HexEncodeExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    long input = ((LongFieldValue) ctx.getValue()).getLong();
    ctx.setValue(new StringFieldValue(Long.toHexString(input)));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue)

Example 25 with LongFieldValue

use of com.yahoo.document.datatypes.LongFieldValue in project vespa by vespa-engine.

the class OptimizePredicateExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    PredicateFieldValue predicate = ((PredicateFieldValue) ctx.getValue()).clone();
    IntegerFieldValue arity = (IntegerFieldValue) ctx.getVariable("arity");
    LongFieldValue lower_bound = (LongFieldValue) ctx.getVariable("lower_bound");
    LongFieldValue upper_bound = (LongFieldValue) ctx.getVariable("upper_bound");
    Long lower = lower_bound != null ? lower_bound.getLong() : null;
    Long upper = upper_bound != null ? upper_bound.getLong() : null;
    PredicateOptions options = new PredicateOptions(arity.getInteger(), lower, upper);
    predicate.setPredicate(optimizer.process(predicate.getPredicate(), options));
    ctx.setValue(predicate);
}
Also used : PredicateOptions(com.yahoo.search.predicate.optimization.PredicateOptions) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) PredicateFieldValue(com.yahoo.document.datatypes.PredicateFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue)

Aggregations

LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)25 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)17 Test (org.junit.Test)17 FieldValue (com.yahoo.document.datatypes.FieldValue)9 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)8 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)7 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)6 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)6 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)6 Raw (com.yahoo.document.datatypes.Raw)4 WeightedSet (com.yahoo.document.datatypes.WeightedSet)4 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)4 Array (com.yahoo.document.datatypes.Array)3 ByteBuffer (java.nio.ByteBuffer)3 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)2 PredicateFieldValue (com.yahoo.document.datatypes.PredicateFieldValue)2 FileOutputStream (java.io.FileOutputStream)2 DataType (com.yahoo.document.DataType)1 AbstractTypesTest (com.yahoo.document.annotation.AbstractTypesTest)1 Struct (com.yahoo.document.datatypes.Struct)1