Search in sources :

Example 6 with RecordBox

use of com.yahoo.bullet.result.RecordBox in project bullet-core by yahoo.

the class FilterOperationsTest method testComparisonNestedField.

@Test
public void testComparisonNestedField() {
    FilterClause clause = getFieldFilter("demographic_map.age", GREATER_THAN, "30");
    // "null" is not > 30
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    RecordBox box = RecordBox.get();
    box.addMap("demographic_map", Pair.of("age", "3"));
    Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
    box.addMap("demographic_map", Pair.of("age", "30"));
    Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
    box.addMap("demographic_map", Pair.of("age", "31"));
    Assert.assertTrue(FilterOperations.perform(box.getRecord(), clause));
}
Also used : RecordBox(com.yahoo.bullet.result.RecordBox) FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 7 with RecordBox

use of com.yahoo.bullet.result.RecordBox 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 8 with RecordBox

use of com.yahoo.bullet.result.RecordBox in project bullet-core by yahoo.

the class QuerierTest method testFilteringProjection.

@Test
public void testFilteringProjection() {
    Querier querier = make(Querier.Mode.PARTITION, makeProjectionFilterQuery("map_field.id", Arrays.asList("1", "23"), Clause.Operation.EQUALS, Pair.of("map_field.id", "mid")), configWithNoTimestamp());
    RecordBox boxA = RecordBox.get().addMap("map_field", Pair.of("id", "3"));
    querier.consume(boxA.getRecord());
    Assert.assertFalse(querier.isClosed());
    Assert.assertNull(querier.getData());
    RecordBox boxB = RecordBox.get().addMap("map_field", Pair.of("id", "23"));
    RecordBox expected = RecordBox.get().add("mid", "23");
    querier.consume(boxB.getRecord());
    Assert.assertFalse(querier.isClosed());
    Assert.assertEquals(querier.getData(), getListBytes(expected.getRecord()));
}
Also used : RecordBox(com.yahoo.bullet.result.RecordBox) Test(org.testng.annotations.Test)

Aggregations

RecordBox (com.yahoo.bullet.result.RecordBox)8 Test (org.testng.annotations.Test)7 FilterClause (com.yahoo.bullet.parsing.FilterClause)3 BulletRecord (com.yahoo.bullet.record.BulletRecord)3 Projection (com.yahoo.bullet.parsing.Projection)2 ProjectionUtils.makeProjection (com.yahoo.bullet.parsing.ProjectionUtils.makeProjection)2 ArrayList (java.util.ArrayList)1