Search in sources :

Example 1 with TypedAvroBulletRecordProvider

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);
}
Also used : Field(com.yahoo.bullet.query.Field) BulletRecord(com.yahoo.bullet.record.BulletRecord) BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) TypedAvroBulletRecordProvider(com.yahoo.bullet.record.avro.TypedAvroBulletRecordProvider) UnaryExpression(com.yahoo.bullet.query.expressions.UnaryExpression) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Aggregations

Field (com.yahoo.bullet.query.Field)1 BinaryExpression (com.yahoo.bullet.query.expressions.BinaryExpression)1 FieldExpression (com.yahoo.bullet.query.expressions.FieldExpression)1 UnaryExpression (com.yahoo.bullet.query.expressions.UnaryExpression)1 BulletRecord (com.yahoo.bullet.record.BulletRecord)1 TypedAvroBulletRecordProvider (com.yahoo.bullet.record.avro.TypedAvroBulletRecordProvider)1 Test (org.testng.annotations.Test)1