use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupDataTest method testNoRecordSum.
@Test
public void testNoRecordSum() {
GroupData data = make(new GroupOperation(GroupOperation.GroupOperationType.SUM, null, "sum"));
// SUM will return null if no records are observed
BulletRecord expected = RecordBox.get().addNull("sum").getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupDataTest method testNonNumericSum.
@Test
public void testNonNumericSum() {
GroupData data = make(new GroupOperation(GroupOperation.GroupOperationType.SUM, "someField", "foo"));
BulletRecord expected = RecordBox.get().addNull("foo").getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
data.consume(RecordBox.get().add("someField", "nonNumericValue").getRecord());
expected = RecordBox.get().addNull("foo").getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
data.consume(RecordBox.get().add("someField", 8.8).getRecord());
expected = RecordBox.get().add("foo", 8.8).getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
data.consume(RecordBox.get().add("someField", "nonNumericValue").getRecord());
expected = RecordBox.get().add("foo", 8.8).getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
data.consume(RecordBox.get().add("someField", 51.4).getRecord());
expected = RecordBox.get().add("foo", 60.2).getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupDataTest method testMergingSupportedAndUnSupportedOperation.
@Test
public void testMergingSupportedAndUnSupportedOperation() {
GroupData data = make(new GroupOperation(GroupOperation.GroupOperationType.COUNT, null, null));
BulletRecord someRecord = RecordBox.get().add("foo", 1).getRecord();
IntStream.range(0, 10).forEach(i -> data.consume(someRecord));
GroupData another = make(new GroupOperation(GroupOperation.GroupOperationType.AVG, "foo", "bar"));
IntStream.range(0, 21).forEach(i -> another.consume(someRecord));
byte[] serialized = SerializerDeserializer.toBytes(another);
// This should combine since we only merge known GroupOperations from the other GroupData
data.combine(serialized);
// AVG should not have influenced other counts.
BulletRecord expected = RecordBox.get().add(GroupOperation.GroupOperationType.COUNT.getName(), 10L).getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupDataTest method testNoRecordMax.
@Test
public void testNoRecordMax() {
GroupData data = make(new GroupOperation(GroupOperation.GroupOperationType.MAX, null, "max"));
// MAX will return null if no records are observed
BulletRecord expected = RecordBox.get().addNull("max").getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupDataTest method testMultiMin.
@Test
public void testMultiMin() {
GroupData data = make(new GroupOperation(GroupOperation.GroupOperationType.MIN, "someField", "foo"));
List<Double> numbers = asList(0.0, 8.8, -88.0, 51.0, 4.0, -4.0, 1234567.89, -51.0);
numbers.stream().map(x -> RecordBox.get().add("someField", x).getRecord()).forEach(data::consume);
BulletRecord expected = RecordBox.get().add("foo", -88.0).getRecord();
Assert.assertEquals(data.getMetricsAsBulletRecord(), expected);
}
Aggregations