use of com.yahoo.bullet.result.RecordBox in project bullet-core by yahoo.
the class GroupDataTest method testGroupMultipleFields.
@Test
public void testGroupMultipleFields() {
GroupData data = make(new GroupOperation(GroupOperation.GroupOperationType.COUNT, "shouldBeIgnored", "myCount"), new GroupOperation(GroupOperation.GroupOperationType.MIN, "minField", "myMin"), new GroupOperation(GroupOperation.GroupOperationType.MIN, "groupField", "minGroupField"), new GroupOperation(GroupOperation.GroupOperationType.MAX, "maxField", "myMax"), new GroupOperation(GroupOperation.GroupOperationType.MAX, "groupField", "maxGroupField"), new GroupOperation(GroupOperation.GroupOperationType.SUM, "groupField", "sumGroupField"));
List<Double> minColumnValues = asList(0.0, -8.8, 51.0);
List<Double> maxColumnValues = asList(4.4, 88.51, -8.44);
List<Double> groupColumnValues = asList(123.45, -884451.8851, 3.14);
List<BulletRecord> records = new ArrayList<>();
for (int i = 0; i < minColumnValues.size(); i++) {
RecordBox recordBox = RecordBox.get();
recordBox.add("minField", minColumnValues.get(i));
recordBox.add("maxField", maxColumnValues.get(i));
recordBox.add("groupField", groupColumnValues.get(i));
records.add(recordBox.getRecord());
}
records.stream().forEach(data::consume);
BulletRecord expected = RecordBox.get().add("myCount", 3L).add("myMin", -8.8).add("minGroupField", -884451.8851).add("myMax", 88.51).add("maxGroupField", 123.45).add("sumGroupField", -884325.2951).getRecord();
Assert.assertTrue(expected.equals(data.getMetricsAsBulletRecord()));
}
use of com.yahoo.bullet.result.RecordBox in project bullet-core by yahoo.
the class FilterOperationsTest method testComparisonBooleanMap.
@Test
public void testComparisonBooleanMap() {
FilterClause clause = getFieldFilter("filter_map.is_fake_event", EQUALS, "true");
// "null" is not true
Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
RecordBox box = RecordBox.get();
Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
box.addMap("filter_map", Pair.of("is_fake_event", true));
Assert.assertTrue(FilterOperations.perform(box.getRecord(), clause));
box.addMap("filter_map", Pair.of("is_fake_event", false));
Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
}
use of com.yahoo.bullet.result.RecordBox in project bullet-core by yahoo.
the class FilterOperationsTest method testComparisonUncastable.
@Test
public void testComparisonUncastable() {
FilterClause clause = getFieldFilter("unreal", EQUALS, "1.23", "4.56");
RecordBox box = RecordBox.get().add("unreal", 123L);
// Trying to cast
Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
}
use of com.yahoo.bullet.result.RecordBox 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);
}
use of com.yahoo.bullet.result.RecordBox in project bullet-core by yahoo.
the class GroupDataSummaryTest method makeRecord.
private static BulletRecord makeRecord(List<String> fields, List<GroupOperation.GroupOperationType> operations, int base) {
RecordBox box = RecordBox.get();
for (int i = 0; i < fields.size(); i++) {
box.add("field_" + i, fields.get(i));
}
for (int i = 0; i < operations.size(); i++) {
String key = "metric_" + i;
GroupOperation.GroupOperationType type = operations.get(i);
Number number = makeNumber(type, base, i, operations.size());
if (number != null) {
box.add(key, number);
}
}
return box.getRecord();
}
Aggregations