Search in sources :

Example 86 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class AggregationTest method testConfiguredSize.

@Test
public void testConfiguredSize() {
    BulletConfig config = new BulletConfig();
    config.set(BulletConfig.AGGREGATION_DEFAULT_SIZE, 10);
    config.set(BulletConfig.AGGREGATION_MAX_SIZE, 200);
    // Need to lower or else AGGREGATION_MAX_SIZE will default to DEFAULT_AGGREGATION_MAX_SIZE
    config.set(BulletConfig.GROUP_AGGREGATION_MAX_SIZE, 200);
    config.validate();
    Aggregation aggregation = new Aggregation();
    aggregation.setSize(null);
    aggregation.configure(config);
    Assert.assertEquals(aggregation.getSize(), (Integer) 10);
    aggregation.setSize(-10);
    aggregation.configure(config);
    Assert.assertEquals(aggregation.getSize(), (Integer) 10);
    aggregation.setSize(0);
    aggregation.configure(config);
    Assert.assertEquals(aggregation.getSize(), (Integer) 10);
    aggregation.setSize(1);
    aggregation.configure(config);
    Assert.assertEquals(aggregation.getSize(), (Integer) 1);
    aggregation.setSize(10);
    aggregation.configure(config);
    Assert.assertEquals(aggregation.getSize(), (Integer) 10);
    aggregation.setSize(200);
    aggregation.configure(config);
    Assert.assertEquals(aggregation.getSize(), (Integer) 200);
    aggregation.setSize(4000);
    aggregation.configure(config);
    Assert.assertEquals(aggregation.getSize(), (Integer) 200);
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 87 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class AggregationTest method testSuccessfulValidate.

@Test
public void testSuccessfulValidate() {
    Aggregation aggregation = new Aggregation();
    aggregation.setType(GROUP);
    aggregation.setAttributes(makeAttributes(makeGroupOperation(COUNT, null, "count")));
    aggregation.configure(new BulletConfig());
    Assert.assertFalse(aggregation.initialize().isPresent());
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 88 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class FilterUtils method makeClause.

public static Clause makeClause(Clause.Operation operation, Clause... clauses) {
    LogicalClause clause = new LogicalClause();
    clause.setOperation(operation);
    if (clauses != null) {
        clause.setClauses(asList(clauses));
    }
    clause.configure(new BulletConfig());
    clause.initialize();
    return clause;
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig)

Example 89 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class LogicalClauseTest method testConfigure.

@Test
public void testConfigure() {
    LogicalClause logicalClause = new LogicalClause();
    logicalClause.setOperation(AND);
    logicalClause.configure(new BulletConfig());
    FilterClause filterClause = new FilterClause();
    filterClause.setField("id");
    filterClause.setOperation(REGEX_LIKE);
    filterClause.setValues(singletonList("f.*"));
    logicalClause.setClauses(singletonList(filterClause));
    Assert.assertNull(filterClause.getPatterns());
    logicalClause.configure(new BulletConfig());
    Assert.assertNotNull(filterClause.getPatterns());
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 90 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.

the class QueryTest method testToString.

@Test
public void testToString() {
    BulletConfig config = new BulletConfig();
    config.set(BulletConfig.AGGREGATION_DEFAULT_SIZE, 1);
    config.set(BulletConfig.QUERY_DEFAULT_DURATION, 30000L);
    Query query = new Query();
    query.configure(config.validate());
    Assert.assertEquals(query.toString(), "{" + "filters: null, projection: null, " + "aggregation: {size: 1, type: RAW, fields: null, attributes: null}, " + "window: null, " + "duration: 30000" + "}");
    query.setFilters(singletonList(FilterUtils.getFieldFilter(Clause.Operation.EQUALS, "foo", "bar")));
    query.setProjection(ProjectionUtils.makeProjection("field", "bid"));
    query.configure(config);
    Assert.assertEquals(query.toString(), "{" + "filters: [{operation: EQUALS, field: field, values: [foo, bar]}], " + "projection: {fields: {field=bid}}, " + "aggregation: {size: 1, type: RAW, fields: null, attributes: null}, " + "window: null, " + "duration: 30000" + "}");
    query.setWindow(WindowUtils.makeTumblingWindow(4000));
    query.configure(config);
    Assert.assertEquals(query.toString(), "{" + "filters: [{operation: EQUALS, field: field, values: [foo, bar]}], " + "projection: {fields: {field=bid}}, " + "aggregation: {size: 1, type: RAW, fields: null, attributes: null}, " + "window: {emit: {type=TIME, every=4000}, include: null}, " + "duration: 30000" + "}");
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Aggregations

BulletConfig (com.yahoo.bullet.common.BulletConfig)101 Test (org.testng.annotations.Test)87 Aggregation (com.yahoo.bullet.parsing.Aggregation)37 List (java.util.List)25 Query (com.yahoo.bullet.parsing.Query)20 QueryUtils.makeAggregationQuery (com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery)17 BulletError (com.yahoo.bullet.common.BulletError)16 BulletRecord (com.yahoo.bullet.record.BulletRecord)16 Arrays.asList (java.util.Arrays.asList)16 Clip (com.yahoo.bullet.result.Clip)14 Collections.singletonList (java.util.Collections.singletonList)12 QueryUtils.makeProjectionFilterQuery (com.yahoo.bullet.parsing.QueryUtils.makeProjectionFilterQuery)11 QueryUtils.makeRawFullQuery (com.yahoo.bullet.parsing.QueryUtils.makeRawFullQuery)11 Map (java.util.Map)11 AggregationUtils.makeAttributes (com.yahoo.bullet.parsing.AggregationUtils.makeAttributes)10 Window (com.yahoo.bullet.parsing.Window)10 Concept (com.yahoo.bullet.result.Meta.Concept)10 RecordBox (com.yahoo.bullet.result.RecordBox)10 ArrayList (java.util.ArrayList)10 IntStream (java.util.stream.IntStream)10