Search in sources :

Example 21 with Aggregation

use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.

the class GroupByTest method testAttributeOperationsUnknownOperation.

@Test
public void testAttributeOperationsUnknownOperation() {
    Aggregation aggregation = makeAggregation(emptyMap(), 10, null);
    aggregation.setAttributes(makeAttributes(makeGroupOperation(COUNT, null, "bar"), makeGroupOperation(COUNT_FIELD, "foo", "foo_avg")));
    GroupBy groupBy = makeGroupBy(new BulletConfig(), aggregation, ALL_METADATA);
    // The bad operation should have been thrown out.
    Assert.assertFalse(groupBy.initialize().isPresent());
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 22 with Aggregation

use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.

the class GroupByTest method testAttributeOperationsDuplicateOperation.

@Test
public void testAttributeOperationsDuplicateOperation() {
    Aggregation aggregation = makeAggregation(emptyMap(), 10, null);
    aggregation.setAttributes(makeAttributes(makeGroupOperation(COUNT, null, null), makeGroupOperation(SUM, "foo", null), makeGroupOperation(COUNT, null, null), makeGroupOperation(SUM, "bar", null), makeGroupOperation(SUM, "foo", null), makeGroupOperation(SUM, "bar", null)));
    GroupBy groupBy = makeGroupBy(new BulletConfig(), aggregation, ALL_METADATA);
    // The bad ones should be removed.
    Assert.assertFalse(groupBy.initialize().isPresent());
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 23 with Aggregation

use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.

the class GroupByTest method makeAggregation.

public static Aggregation makeAggregation(Map<String, String> fields, int size, List<Map<String, String>> operations) {
    Aggregation aggregation = new Aggregation();
    aggregation.setType(GROUP);
    aggregation.setFields(fields);
    aggregation.setSize(size);
    if (operations != null) {
        aggregation.setAttributes(makeAttributes(operations));
    }
    return aggregation;
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation)

Example 24 with Aggregation

use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.

the class RawTest method makeRaw.

private static Raw makeRaw(int size, int maxSize) {
    Aggregation aggregation = new Aggregation();
    aggregation.setSize(size);
    BulletConfig config = new BulletConfig();
    config.set(BulletConfig.RAW_AGGREGATION_MAX_SIZE, maxSize);
    Raw raw = new Raw(aggregation, config.validate());
    raw.initialize();
    return raw;
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) BulletConfig(com.yahoo.bullet.common.BulletConfig)

Example 25 with Aggregation

use of com.yahoo.bullet.parsing.Aggregation in project bullet-core by yahoo.

the class TopKTest method makeTopK.

public static TopK makeTopK(BulletConfig configuration, Map<String, Object> attributes, Map<String, String> fields, int size, List<Map.Entry<Concept, String>> metadata) {
    Aggregation aggregation = new Aggregation();
    aggregation.setType(Aggregation.Type.TOP_K);
    aggregation.setFields(fields);
    aggregation.setAttributes(attributes);
    aggregation.setSize(size);
    TopK topK = new TopK(aggregation, addMetadata(configuration, metadata));
    topK.initialize();
    return topK;
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation)

Aggregations

Aggregation (com.yahoo.bullet.parsing.Aggregation)39 Test (org.testng.annotations.Test)31 BulletConfig (com.yahoo.bullet.common.BulletConfig)30 Query (com.yahoo.bullet.parsing.Query)12 List (java.util.List)11 BulletError (com.yahoo.bullet.common.BulletError)10 Arrays.asList (java.util.Arrays.asList)10 QueryUtils.makeAggregationQuery (com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery)7 QueryUtils.makeProjectionFilterQuery (com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery)5 QueryUtils.makeRawFullQuery (com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery)5 Window (com.yahoo.bullet.parsing.Window)5 Map (java.util.Map)4 TestHelpers.addMetadata (com.yahoo.bullet.TestHelpers.addMetadata)3 AggregationUtils.makeAttributes (com.yahoo.bullet.parsing.AggregationUtils.makeAttributes)3 BulletRecord (com.yahoo.bullet.record.BulletRecord)3 Clip (com.yahoo.bullet.result.Clip)3 Concept (com.yahoo.bullet.result.Meta.Concept)3 RecordBox (com.yahoo.bullet.result.RecordBox)3 Collections.singletonList (java.util.Collections.singletonList)3 Collections.singletonMap (java.util.Collections.singletonMap)3