Search in sources :

Example 6 with Projection

use of com.yahoo.bullet.parsing.Projection in project bullet-core by yahoo.

the class ProjectionOperationsTest method testRepeatedProjections.

@Test
public void testRepeatedProjections() {
    Projection first = makeProjection("field", "id");
    Projection second = makeProjection("map_field.foo", "bar");
    RecordBox box = RecordBox.get().add("field", "test").addMap("map_field", Pair.of("foo", "baz"));
    BulletRecord record = box.getRecord();
    BulletRecord firstProjection = ProjectionOperations.project(record, first);
    BulletRecord secondProjection = ProjectionOperations.project(record, second);
    box = RecordBox.get().add("field", "test").addMap("map_field", Pair.of("foo", "baz"));
    BulletRecord expectedOriginal = box.getRecord();
    Assert.assertEquals(record, expectedOriginal);
    box = RecordBox.get().add("id", "test");
    BulletRecord expectedFirstProjection = box.getRecord();
    Assert.assertEquals(firstProjection, expectedFirstProjection);
    box = RecordBox.get().add("bar", "baz");
    BulletRecord expectedSecondProjection = box.getRecord();
    Assert.assertEquals(secondProjection, expectedSecondProjection);
}
Also used : RecordBox(com.yahoo.bullet.result.RecordBox) BulletRecord(com.yahoo.bullet.record.BulletRecord) ProjectionUtils.makeProjection(com.yahoo.bullet.parsing.ProjectionUtils.makeProjection) Projection(com.yahoo.bullet.parsing.Projection) Test(org.testng.annotations.Test)

Example 7 with Projection

use of com.yahoo.bullet.parsing.Projection in project bullet-core by yahoo.

the class ProjectionOperationsTest method testDefaults.

@Test
public void testDefaults() {
    Projection projection = new Projection();
    Assert.assertNull(projection.getFields());
    BulletRecord record = RecordBox.get().add("foo", "bar").getRecord();
    BulletRecord actual = ProjectionOperations.project(record, projection);
    BulletRecord expected = RecordBox.get().add("foo", "bar").getRecord();
    Assert.assertEquals(actual, expected);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) ProjectionUtils.makeProjection(com.yahoo.bullet.parsing.ProjectionUtils.makeProjection) Projection(com.yahoo.bullet.parsing.Projection) Test(org.testng.annotations.Test)

Aggregations

Projection (com.yahoo.bullet.parsing.Projection)7 BulletRecord (com.yahoo.bullet.record.BulletRecord)7 ProjectionUtils.makeProjection (com.yahoo.bullet.parsing.ProjectionUtils.makeProjection)6 Test (org.testng.annotations.Test)6 RecordBox (com.yahoo.bullet.result.RecordBox)2