Search in sources :

Example 11 with BulletConfig

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

the class FilterClauseTest method testConfigureForPatterns.

@Test
public void testConfigureForPatterns() {
    FilterClause filterClause = new FilterClause();
    filterClause.setOperation(Clause.Operation.REGEX_LIKE);
    filterClause.setValues(singletonList(".g.*"));
    Assert.assertNull(filterClause.getPatterns());
    filterClause.configure(new BulletConfig());
    Assert.assertFalse(filterClause.initialize().isPresent());
    List<Pattern> actual = filterClause.getPatterns();
    Assert.assertNotNull(actual);
    Assert.assertEquals(actual.size(), 1);
    Assert.assertEquals(actual.get(0).pattern(), ".g.*");
}
Also used : Pattern(java.util.regex.Pattern) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 12 with BulletConfig

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

the class FilterClauseTest method testConfigureForBadPatterns.

@Test
public void testConfigureForBadPatterns() {
    FilterClause filterClause = new FilterClause();
    filterClause.setOperation(Clause.Operation.REGEX_LIKE);
    filterClause.setValues(singletonList("*TEST*"));
    Assert.assertNull(filterClause.getPatterns());
    filterClause.configure(new BulletConfig());
    Assert.assertFalse(filterClause.initialize().isPresent());
    Assert.assertNotNull(filterClause.getPatterns());
    Assert.assertTrue(filterClause.getPatterns().isEmpty());
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 13 with BulletConfig

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

the class FilterUtils method makeClause.

public static Clause makeClause(String field, List<String> values, Clause.Operation operation) {
    FilterClause clause = new FilterClause();
    clause.setField(field);
    clause.setValues(values == null ? Collections.singletonList(Type.NULL_EXPRESSION) : values);
    clause.setOperation(operation);
    clause.configure(new BulletConfig());
    clause.initialize();
    return clause;
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig)

Example 14 with BulletConfig

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

the class QueryTest method testDefaults.

@Test
public void testDefaults() {
    Query query = new Query();
    BulletConfig config = new BulletConfig();
    query.configure(config);
    Assert.assertNull(query.getProjection());
    Assert.assertNull(query.getFilters());
    Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
    Assert.assertEquals(query.getAggregation().getType(), Aggregation.Type.RAW);
    Assert.assertEquals((Object) query.getAggregation().getSize(), BulletConfig.DEFAULT_AGGREGATION_SIZE);
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 15 with BulletConfig

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

the class QueryTest method testDuration.

@Test
public void testDuration() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    query.configure(config);
    Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
    query.setDuration(-1000L);
    query.configure(config);
    Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
    query.setDuration(0L);
    query.configure(config);
    Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
    query.setDuration(1L);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) 1L);
    query.setDuration(BulletConfig.DEFAULT_QUERY_DURATION);
    query.configure(config);
    Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
    query.setDuration(BulletConfig.DEFAULT_QUERY_MAX_DURATION);
    query.configure(config);
    Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_MAX_DURATION);
    // Overflow
    query.setDuration(BulletConfig.DEFAULT_QUERY_MAX_DURATION * 2);
    query.configure(config);
    Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_MAX_DURATION);
}
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