Search in sources :

Example 11 with Aggregation

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

the class RunningQueryTest method testTimingOut.

@Test
public void testTimingOut() throws Exception {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    query.setAggregation(new Aggregation());
    query.setDuration(1L);
    query.configure(config);
    Assert.assertFalse(query.initialize().isPresent());
    RunningQuery runningQuery = new RunningQuery("foo", query);
    Assert.assertFalse(runningQuery.initialize().isPresent());
    // Sleep to make sure it's 1 ms
    Thread.sleep(1);
    Assert.assertTrue(runningQuery.isTimedOut());
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) QueryUtils.makeAggregationQuery(com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery) Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 12 with Aggregation

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

the class RunningQueryTest method testCreatingWithQuery.

@Test
public void testCreatingWithQuery() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    query.setAggregation(new Aggregation());
    query.configure(config);
    Assert.assertFalse(query.initialize().isPresent());
    RunningQuery runningQuery = new RunningQuery("foo", query);
    Assert.assertFalse(runningQuery.initialize().isPresent());
    Assert.assertEquals(runningQuery.getId(), "foo");
    Assert.assertNotNull(runningQuery.getQuery());
    String actual = runningQuery.toString();
    Assert.assertTrue(actual.contains("{"));
    Assert.assertTrue(actual.contains("filters: null, projection: null,"));
    Assert.assertTrue(actual.contains("aggregation: {size: 500, type: RAW, fields: null, attributes: null},"));
    Assert.assertTrue(actual.contains("window: null, duration:"));
    Assert.assertTrue(actual.contains("}"));
}
Also used : Aggregation(com.yahoo.bullet.parsing.Aggregation) QueryUtils.makeAggregationQuery(com.yahoo.bullet.parsing.QueryUtils.makeAggregationQuery) Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 13 with Aggregation

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

the class WindowingOperationsTest method testNotForcingNonRawToTumbling.

@Test
public void testNotForcingNonRawToTumbling() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    Window window = WindowUtils.makeReactiveWindow();
    window.configure(config);
    query.setWindow(window);
    Aggregation aggregation = new Aggregation();
    aggregation.setType(Aggregation.Type.GROUP);
    query.setAggregation(aggregation);
    Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Reactive.class);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Aggregation(com.yahoo.bullet.parsing.Aggregation) Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 14 with Aggregation

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

the class WindowingOperationsTest method testAdditiveTumblingWindow.

@Test
public void testAdditiveTumblingWindow() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    Window window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.ALL, null);
    window.configure(config);
    query.setWindow(window);
    Aggregation aggregation = new Aggregation();
    aggregation.setType(Aggregation.Type.GROUP);
    query.setAggregation(aggregation);
    Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), AdditiveTumbling.class);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Aggregation(com.yahoo.bullet.parsing.Aggregation) Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 15 with Aggregation

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

the class WindowingOperationsTest method testOtherWindowsForcedToTumbling.

@Test
public void testOtherWindowsForcedToTumbling() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    Window window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.RECORD, 4);
    window.configure(config);
    query.setWindow(window);
    Aggregation aggregation = new Aggregation();
    aggregation.setType(Aggregation.Type.COUNT_DISTINCT);
    query.setAggregation(aggregation);
    Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Tumbling.class);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Aggregation(com.yahoo.bullet.parsing.Aggregation) Query(com.yahoo.bullet.parsing.Query) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

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