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);
}
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());
}
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;
}
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());
}
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" + "}");
}
Aggregations