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));
}
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);
}
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()));
}
Aggregations