use of com.yahoo.bullet.record.avro.TypedAvroBulletRecordProvider in project bullet-core by yahoo.
the class ProjectionTest method testProjectNewRecord.
@Test
public void testProjectNewRecord() {
BulletRecord record = RecordBox.get().add("a", 2).add("b", 4).add("c", 6).getRecord();
List<Field> fields = Arrays.asList(new Field("d", new BinaryExpression(new FieldExpression("a"), new FieldExpression("b"), Operation.ADD)), new Field("e", new BinaryExpression(new FieldExpression("b"), new FieldExpression("c"), Operation.MUL)), new Field("f", new BinaryExpression(new FieldExpression("d"), new FieldExpression("e"), Operation.ADD)), new Field("g", new FieldExpression("g")), new Field("h", new UnaryExpression(new FieldExpression("a"), Operation.SIZE_OF)));
Projection projection = new Projection(fields);
BulletRecord newRecord = projection.project(record, new TypedAvroBulletRecordProvider());
Assert.assertEquals(newRecord.fieldCount(), 2);
Assert.assertEquals(newRecord.typedGet("d").getValue(), 6);
Assert.assertEquals(newRecord.typedGet("e").getValue(), 24);
}
Aggregations