use of com.yahoo.bullet.query.expressions.BinaryExpression 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."));
}
use of com.yahoo.bullet.query.expressions.BinaryExpression in project bullet-core by yahoo.
the class SimpleEqualityPartitionerTest method testPartitioningForQueryWithNestedFields.
@Test
public void testPartitioningForQueryWithNestedFields() {
SimpleEqualityPartitioner partitioner = createPartitioner("A", "B", "C", "D.e");
Query query = createQuery(new BinaryExpression(new FieldExpression("A"), new ValueExpression("bar"), Operation.EQUALS), new BinaryExpression(new FieldExpression("B"), new ValueExpression("quux"), Operation.EQUALS), new BinaryExpression(new FieldExpression("C"), new ValueExpression("qux"), Operation.EQUALS), new BinaryExpression(new FieldExpression("D", "e"), new ValueExpression("norf"), Operation.EQUALS));
Assert.assertEquals(partitioner.getKeys(query), singleton("bar.-quux.-qux.-norf."));
}
use of com.yahoo.bullet.query.expressions.BinaryExpression in project bullet-core by yahoo.
the class HavingStrategyTest method testHaving.
@Test
public void testHaving() {
List<BulletRecord> records = new ArrayList<>();
records.add(RecordBox.get().add("a", 6).getRecord());
records.add(RecordBox.get().add("a", 1).getRecord());
records.add(RecordBox.get().add("a", 8).getRecord());
records.add(RecordBox.get().add("a", 2).getRecord());
records.add(RecordBox.get().add("b", 10).getRecord());
records.add(RecordBox.get().add("a", 7).getRecord());
Clip clip = new Clip();
clip.add(records);
// a > 5
BinaryExpression expression = new BinaryExpression(new FieldExpression("a"), new ValueExpression(5), Operation.GREATER_THAN);
HavingStrategy strategy = (HavingStrategy) new Having(expression).getPostStrategy();
Clip result = strategy.execute(clip);
Assert.assertEquals(result.getRecords().size(), 3);
Assert.assertEquals(result.getRecords().get(0).typedGet("a").getValue(), 6);
Assert.assertEquals(result.getRecords().get(1).typedGet("a").getValue(), 8);
Assert.assertEquals(result.getRecords().get(2).typedGet("a").getValue(), 7);
}
use of com.yahoo.bullet.query.expressions.BinaryExpression in project bullet-core by yahoo.
the class BinaryEvaluatorTest method testConstructor.
@Test
public void testConstructor() {
BinaryExpression expression = new BinaryExpression(new ValueExpression(1), new ValueExpression(2), Operation.ADD);
expression.setType(Type.INTEGER);
BinaryEvaluator evaluator = new BinaryEvaluator(expression);
Assert.assertTrue(evaluator.left instanceof ValueEvaluator);
Assert.assertTrue(evaluator.right instanceof ValueEvaluator);
Assert.assertEquals(evaluator.op, BINARY_OPERATORS.get(Operation.ADD));
Assert.assertEquals(evaluator.evaluate(RecordBox.get().getRecord()), new TypedObject(Type.INTEGER, 3));
}
use of com.yahoo.bullet.query.expressions.BinaryExpression in project bullet-core by yahoo.
the class SimpleEqualityPartitionerTest method testPartitioningForQueryWithAllFields.
@Test
public void testPartitioningForQueryWithAllFields() {
SimpleEqualityPartitioner partitioner = createPartitioner("A", "B", "C");
Query query = createQuery(new BinaryExpression(new FieldExpression("A"), new ValueExpression("bar"), Operation.EQUALS), new BinaryExpression(new FieldExpression("B"), new ValueExpression("baz"), Operation.EQUALS), new BinaryExpression(new FieldExpression("C"), new ValueExpression("qux"), Operation.EQUALS));
Assert.assertEquals(partitioner.getKeys(query), singleton("bar.-baz.-qux."));
}
Aggregations