use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class FieldTest method testToString.
@Test
public void testToString() {
Field field = new Field("abc", new ValueExpression(5));
Assert.assertEquals(field.toString(), "{name: abc, value: {value: 5, type: INTEGER}}");
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class ProjectionTest method testProjectionCopy.
@Test
public void testProjectionCopy() {
Projection projection = new Projection(Arrays.asList(new Field("foo", new ValueExpression(5))), true);
Assert.assertEquals(projection.getFields(), Collections.singletonList(new Field("foo", new ValueExpression(5))));
Assert.assertEquals(projection.getType(), Projection.Type.COPY);
Assert.assertEquals(projection.toString(), "{fields: [{name: foo, value: {value: 5, type: INTEGER}}], type: COPY}");
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class SimpleEqualityPartitioner method mapFieldsToValues.
private void mapFieldsToValues(Expression expression, Map<String, Set<Serializable>> mapping) {
if (!(expression instanceof BinaryExpression)) {
return;
}
BinaryExpression binary = (BinaryExpression) expression;
if (binary.getOp() == Operation.AND) {
mapFieldsToValues(binary.getLeft(), mapping);
mapFieldsToValues(binary.getRight(), mapping);
} else if (binary.getOp() == Operation.EQUALS) {
if (binary.getLeft() instanceof FieldExpression && binary.getRight() instanceof ValueExpression) {
addFieldToMapping((FieldExpression) binary.getLeft(), (ValueExpression) binary.getRight(), mapping);
} else if (binary.getRight() instanceof FieldExpression && binary.getLeft() instanceof ValueExpression) {
addFieldToMapping((FieldExpression) binary.getRight(), (ValueExpression) binary.getLeft(), mapping);
}
}
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class SimpleEqualityPartitionerTest method testDefaultPartitioningQueryWithNullEqualityFilters.
@Test
public void testDefaultPartitioningQueryWithNullEqualityFilters() {
SimpleEqualityPartitioner partitioner = createPartitioner("A", "B");
Query query = createQuery(new BinaryExpression(new FieldExpression("A"), new ValueExpression(null), Operation.EQUALS), new BinaryExpression(new FieldExpression("B"), new ValueExpression(null), Operation.EQUALS));
Assert.assertEquals(partitioner.getKeys(query), singleton("null-null"));
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class SimpleEqualityPartitionerTest method testPartitioningForQueryWithAllFieldsOperandsFlipped.
@Test
public void testPartitioningForQueryWithAllFieldsOperandsFlipped() {
SimpleEqualityPartitioner partitioner = createPartitioner("A", "B", "C");
Query query = createQuery(new BinaryExpression(new ValueExpression("bar"), new FieldExpression("A"), Operation.EQUALS), new BinaryExpression(new ValueExpression("baz"), new FieldExpression("B"), Operation.EQUALS), new BinaryExpression(new ValueExpression("qux"), new FieldExpression("C"), Operation.EQUALS));
Assert.assertEquals(partitioner.getKeys(query), singleton("bar.-baz.-qux."));
}
Aggregations