Search in sources :

Example 56 with BulletRecord

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());
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Test(org.testng.annotations.Test)

Example 57 with BulletRecord

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());
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Test(org.testng.annotations.Test)

Example 58 with BulletRecord

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());
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Test(org.testng.annotations.Test)

Example 59 with BulletRecord

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;
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) ArrayList(java.util.ArrayList) GroupDataSummary(com.yahoo.bullet.aggregations.grouping.GroupDataSummary) GroupData(com.yahoo.bullet.aggregations.grouping.GroupData) CachingGroupData(com.yahoo.bullet.aggregations.grouping.CachingGroupData)

Example 60 with BulletRecord

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);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Projection(com.yahoo.bullet.parsing.Projection)

Aggregations

BulletRecord (com.yahoo.bullet.record.BulletRecord)210 Test (org.testng.annotations.Test)196 Tuple (org.apache.storm.tuple.Tuple)55 CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)53 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)53 TopKTest (com.yahoo.bullet.aggregations.TopKTest)53 Clip (com.yahoo.bullet.result.Clip)53 HashMap (java.util.HashMap)53 Map (java.util.Map)53 BulletConfig (com.yahoo.bullet.common.BulletConfig)46 List (java.util.List)45 IntStream (java.util.stream.IntStream)45 Assert (org.testng.Assert)45 RecordBox (com.yahoo.bullet.result.RecordBox)43 Arrays.asList (java.util.Arrays.asList)40 Pair (org.apache.commons.lang3.tuple.Pair)40 AggregationUtils.makeAttributes (com.yahoo.bullet.parsing.AggregationUtils.makeAttributes)34 BulletError (com.yahoo.bullet.common.BulletError)33 Aggregation (com.yahoo.bullet.parsing.Aggregation)33 Concept (com.yahoo.bullet.result.Meta.Concept)33