use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class FieldTest method testHashCode.
@Test
public void testHashCode() {
Field fieldA = new Field("abc", new ValueExpression(5));
Field fieldB = new Field("def", new ValueExpression(5));
Field fieldC = new Field("abc", new ValueExpression(1));
Field fieldD = new Field("abc", new ValueExpression(5));
Assert.assertNotEquals(fieldA.hashCode(), fieldB.hashCode());
Assert.assertNotEquals(fieldA.hashCode(), fieldC.hashCode());
Assert.assertEquals(fieldA.hashCode(), fieldD.hashCode());
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class SimpleEqualityPartitioner method addFieldToMapping.
private void addFieldToMapping(FieldExpression fieldExpression, ValueExpression valueExpression, Map<String, Set<Serializable>> mapping) {
if (fieldExpression.getKey() instanceof Expression || fieldExpression.getSubKey() instanceof Expression) {
return;
}
String field = fieldExpression.getName();
if (fieldSet.contains(field)) {
Serializable value = valueExpression.getValue();
mapping.computeIfAbsent(field, s -> new HashSet<>()).add(value);
}
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class CastEvaluatorTest method testConstructor.
@Test
public void testConstructor() {
CastExpression expression = new CastExpression(new ValueExpression(5), Type.STRING);
expression.setType(Type.STRING);
CastEvaluator evaluator = new CastEvaluator(expression);
Assert.assertTrue(evaluator.value instanceof ValueEvaluator);
Assert.assertEquals(evaluator.castType, Type.STRING);
Assert.assertEquals(evaluator.evaluate(RecordBox.get().getRecord()), new TypedObject(Type.STRING, "5"));
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class NAryEvaluatorTest method testConstructor.
@Test
public void testConstructor() {
NAryExpression expression = new NAryExpression(Arrays.asList(new ValueExpression(false), new ValueExpression(1), new ValueExpression(2)), Operation.IF);
expression.setType(Type.INTEGER);
NAryEvaluator evaluator = new NAryEvaluator(expression);
Assert.assertTrue(evaluator.operands.get(0) instanceof ValueEvaluator);
Assert.assertTrue(evaluator.operands.get(1) instanceof ValueEvaluator);
Assert.assertTrue(evaluator.operands.get(2) instanceof ValueEvaluator);
Assert.assertEquals(evaluator.op, N_ARY_OPERATORS.get(Operation.IF));
Assert.assertEquals(evaluator.evaluate(RecordBox.get().getRecord()), new TypedObject(Type.INTEGER, 2));
}
use of com.yahoo.bullet.query.expressions.ValueExpression in project bullet-core by yahoo.
the class ValueEvaluatorTest method testConstructor.
@Test
public void testConstructor() {
ValueEvaluator evaluator = new ValueEvaluator(new ValueExpression(5));
Assert.assertEquals(evaluator.value, new TypedObject(Type.INTEGER, 5));
Assert.assertEquals(evaluator.evaluate(RecordBox.get().getRecord()), evaluator.value);
evaluator = new ValueEvaluator(new ValueExpression("5"));
Assert.assertEquals(evaluator.value, new TypedObject(Type.STRING, "5"));
Assert.assertEquals(evaluator.evaluate(RecordBox.get().getRecord()), evaluator.value);
}
Aggregations