use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupAllTest method testCountingMoreThanMaximum.
@Test
public void testCountingMoreThanMaximum() {
GroupAll groupAll = makeGroupAll(makeGroupOperation(GroupOperation.GroupOperationType.COUNT, null, null));
BulletRecord someRecord = RecordBox.get().add("foo", 1).getRecord();
IntStream.range(0, 2 * BulletConfig.DEFAULT_AGGREGATION_MAX_SIZE).forEach(i -> groupAll.consume(someRecord));
Assert.assertNotNull(groupAll.getData());
List<BulletRecord> aggregate = groupAll.getResult().getRecords();
Assert.assertEquals(aggregate.size(), 1);
BulletRecord actual = aggregate.get(0);
BulletRecord expected = RecordBox.get().add(GroupOperation.GroupOperationType.COUNT.getName(), 2L * BulletConfig.DEFAULT_AGGREGATION_MAX_SIZE).getRecord();
Assert.assertEquals(actual, expected);
Assert.assertEquals(groupAll.getRecords(), aggregate);
Assert.assertEquals(groupAll.getMetadata().asMap(), groupAll.getResult().getMeta().asMap());
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupAllTest method testNoRecordCount.
@Test
public void testNoRecordCount() {
GroupAll groupAll = makeGroupAll(makeGroupOperation(GroupOperation.GroupOperationType.COUNT, null, null));
Assert.assertNotNull(groupAll.getData());
List<BulletRecord> aggregate = groupAll.getResult().getRecords();
Assert.assertEquals(aggregate.size(), 1);
BulletRecord actual = aggregate.get(0);
BulletRecord expected = RecordBox.get().add(GroupOperation.GroupOperationType.COUNT.getName(), 0L).getRecord();
Assert.assertEquals(actual, expected);
Assert.assertEquals(groupAll.getRecords(), aggregate);
Assert.assertEquals(groupAll.getMetadata().asMap(), groupAll.getResult().getMeta().asMap());
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class GroupAllTest method testAvg.
@Test
public void testAvg() {
GroupAll groupAll = makeGroupAll(makeGroupOperation(GroupOperation.GroupOperationType.AVG, "someField", "avg"));
Assert.assertNotNull(groupAll.getData());
groupAll.consume(RecordBox.get().addNull("someField").getRecord());
BulletRecord expected = RecordBox.get().addNull("avg").getRecord();
Assert.assertEquals(groupAll.getResult().getRecords().get(0), expected);
groupAll.consume(RecordBox.get().add("someField", -4.8).getRecord());
groupAll.consume(RecordBox.get().add("someField", -8).getRecord());
groupAll.consume(RecordBox.get().add("someField", 51.44).getRecord());
expected = RecordBox.get().add("avg", 12.88).getRecord();
Assert.assertEquals(groupAll.getResult().getRecords().get(0), expected);
groupAll.consume(RecordBox.get().addNull("someField").getRecord());
expected = RecordBox.get().add("avg", 12.88).getRecord();
Assert.assertEquals(groupAll.getResult().getRecords().get(0), expected);
groupAll.consume(RecordBox.get().add("someField", 88.0).getRecord());
expected = RecordBox.get().add("avg", 31.66).getRecord();
Assert.assertEquals(groupAll.getResult().getRecords().get(0), expected);
Assert.assertEquals(groupAll.getResult().getRecords().size(), 1);
Assert.assertEquals(groupAll.getRecords(), groupAll.getResult().getRecords());
Assert.assertEquals(groupAll.getMetadata().asMap(), groupAll.getResult().getMeta().asMap());
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-core by yahoo.
the class TupleSketch method getRecords.
@Override
public List<BulletRecord> getRecords() {
merge();
List<BulletRecord> result = new ArrayList<>();
SketchIterator<GroupDataSummary> iterator = this.result.iterator();
for (int count = 0; iterator.next() && count < maxSize; count++) {
GroupData data = iterator.getSummary().getData();
result.add(data.getAsBulletRecord());
}
return result;
}
use of com.yahoo.bullet.record.BulletRecord 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);
}
Aggregations