Search in sources :

Example 1 with Projection

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

the class Querier method project.

private BulletRecord project(BulletRecord record) {
    Projection projection = runningQuery.getQuery().getProjection();
    BulletRecord projected = projection != null ? ProjectionOperations.project(record, projection) : record;
    return addAdditionalFields(projected);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Projection(com.yahoo.bullet.parsing.Projection)

Example 2 with Projection

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

the class ProjectionOperationsTest method testUnsupportedProjection.

@Test
public void testUnsupportedProjection() {
    Projection projection = makeProjection(ImmutablePair.of("list_field.1.foo", "bar"), ImmutablePair.of("field", "foo"));
    BulletRecord record = RecordBox.get().addList("list_field", emptyMap(), singletonMap("foo", "bar")).add("field", "123").getRecord();
    BulletRecord actual = ProjectionOperations.project(record, projection);
    BulletRecord expected = RecordBox.get().add("foo", "123").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)

Example 3 with Projection

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

the class ProjectionOperationsTest method testMapList.

@Test
public void testMapList() {
    Projection projection = makeProjection("list_field", "foo");
    BulletRecord record = RecordBox.get().addList("list_field", emptyMap(), singletonMap("foo", "baz")).getRecord();
    BulletRecord expected = RecordBox.get().addList("foo", emptyMap(), singletonMap("foo", "baz")).getRecord();
    BulletRecord actual = ProjectionOperations.project(record, projection);
    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)

Example 4 with Projection

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

the class ProjectionOperationsTest method testProjection.

@Test
public void testProjection() {
    Projection projection = makeProjection("map_field.foo", "bar");
    RecordBox box = RecordBox.get().addMap("map_field", Pair.of("foo", "baz"));
    BulletRecord actual = ProjectionOperations.project(box.getRecord(), projection);
    BulletRecord expected = RecordBox.get().add("bar", "baz").getRecord();
    Assert.assertEquals(actual, expected);
}
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 5 with Projection

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

the class ProjectionOperationsTest method testNullFieldName.

@Test
public void testNullFieldName() {
    Projection projection = makeProjection(ImmutablePair.of(null, "test"), ImmutablePair.of("map_field.foo", "foo"));
    BulletRecord record = RecordBox.get().add("field", "test").addMap("map_field", Pair.of("foo", "baz")).getRecord();
    BulletRecord actual = ProjectionOperations.project(record, projection);
    BulletRecord expected = RecordBox.get().add("foo", "baz").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