Search in sources :

Example 66 with IntegerFieldValue

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

the class SimpleAdapterFactoryTestCase method requireThatCompleteUpdatesAreCombined.

@Test
public void requireThatCompleteUpdatesAreCombined() {
    DocumentType docType = new DocumentType("my_type");
    DocumentUpdate update = new DocumentUpdate(docType, "doc:foo:1");
    Field field1 = new Field("int1", DataType.INT);
    Field field2 = new Field("int2", DataType.INT);
    Field field3 = new Field("int3", DataType.INT);
    docType.addField(field1);
    docType.addField(field2);
    docType.addField(field3);
    update.addFieldUpdate(FieldUpdate.createAssign(field1, new IntegerFieldValue(10)));
    update.addFieldUpdate(FieldUpdate.createAssign(field2, new IntegerFieldValue(20)));
    update.addFieldUpdate(FieldUpdate.createIncrement(field3, 30));
    SimpleAdapterFactory factory = new SimpleAdapterFactory();
    List<UpdateAdapter> adapters = factory.newUpdateAdapterList(update);
    assertEquals(2, adapters.size());
}
Also used : Field(com.yahoo.document.Field) DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 67 with IntegerFieldValue

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

the class CompositeExpressionTestCase method requireThatToScriptBlockOutputIsParsable.

@Test
public void requireThatToScriptBlockOutputIsParsable() throws ParseException {
    Expression exp = new SetValueExpression(new IntegerFieldValue(69));
    assertScript("{ 69; }", exp);
    assertScript("{ 69; }", new StatementExpression(exp));
    assertScript("{ 69; }", new ScriptExpression(new StatementExpression(exp)));
}
Also used : IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 68 with IntegerFieldValue

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

the class RandomExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    int max;
    if (this.max != null) {
        max = this.max;
    } else {
        max = Integer.parseInt(String.valueOf(ctx.getValue()));
    }
    ctx.setValue(new IntegerFieldValue(ThreadLocalRandom.current().nextInt(max)));
}
Also used : IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue)

Example 69 with IntegerFieldValue

use of com.yahoo.document.datatypes.IntegerFieldValue 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

IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)69 Test (org.junit.Test)56 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)39 FieldValue (com.yahoo.document.datatypes.FieldValue)23 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)14 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)13 Array (com.yahoo.document.datatypes.Array)12 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)10 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)10 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)10 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)10 Struct (com.yahoo.document.datatypes.Struct)10 Field (com.yahoo.document.Field)8 DocumentType (com.yahoo.document.DocumentType)7 WeightedSet (com.yahoo.document.datatypes.WeightedSet)7 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)7 Document (com.yahoo.document.Document)5 DocumentUpdate (com.yahoo.document.DocumentUpdate)5 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)4 PredicateFieldValue (com.yahoo.document.datatypes.PredicateFieldValue)4