Search in sources :

Example 36 with BulletConfig

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

the class RunningQueryTest method testCreatingWithStringQuery.

@Test
public void testCreatingWithStringQuery() {
    BulletConfig config = new BulletConfig();
    RunningQuery runningQuery = new RunningQuery("foo", "{}", config);
    Assert.assertFalse(runningQuery.initialize().isPresent());
    Assert.assertEquals(runningQuery.getId(), "foo");
    Assert.assertNotNull(runningQuery.getQuery());
    Assert.assertEquals(runningQuery.toString(), "{}");
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 37 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig 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 38 with BulletConfig

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

the class RunningQueryTest method testInitialization.

@Test
public void testInitialization() {
    BulletConfig config = new BulletConfig();
    String query = makeAggregationQuery(Aggregation.Type.RAW, null, Window.Unit.RECORD, 10, Window.Unit.TIME, 2000);
    RunningQuery runningQuery = new RunningQuery("foo", query, config);
    Optional<List<BulletError>> errors = runningQuery.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), Collections.singletonList(Window.NOT_ONE_RECORD_EMIT));
}
Also used : List(java.util.List) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 39 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig 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 40 with BulletConfig

use of com.yahoo.bullet.common.BulletConfig 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)

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