Search in sources :

Example 16 with BulletConfig

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

the class QueryTest method testInitializeNullValues.

@Test
public void testInitializeNullValues() {
    Query query = new Query();
    query.setProjection(null);
    query.setFilters(null);
    query.setAggregation(null);
    query.configure(new BulletConfig());
    Optional<List<BulletError>> errorList = query.initialize();
    Assert.assertFalse(errorList.isPresent());
}
Also used : List(java.util.List) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 17 with BulletConfig

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

the class QueryTest method testWindowForced.

@Test
public void testWindowForced() {
    BulletConfig config = new BulletConfig();
    Query query = new Query();
    query.setWindow(WindowUtils.makeReactiveWindow());
    query.configure(config);
    Assert.assertNotNull(query.getWindow());
    config.set(BulletConfig.WINDOW_DISABLE, true);
    config.validate();
    query.setWindow(WindowUtils.makeReactiveWindow());
    query.configure(config);
    Assert.assertNull(query.getWindow());
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 18 with BulletConfig

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

the class QueryTest method testAggregationForced.

@Test
public void testAggregationForced() {
    Query query = new Query();
    query.setAggregation(null);
    Assert.assertNull(query.getProjection());
    Assert.assertNull(query.getFilters());
    // If you had null for aggregation
    Assert.assertNull(query.getAggregation());
    query.configure(new BulletConfig());
    Assert.assertNotNull(query.getAggregation());
}
Also used : BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 19 with BulletConfig

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

the class WindowTest method testErrorsInInitialization.

@Test
public void testErrorsInInitialization() {
    BulletConfig config = new BulletConfig();
    Window window;
    Optional<List<BulletError>> errors;
    window = new Window();
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EMIT));
    window = WindowUtils.makeWindow(Window.Unit.ALL, 10);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EMIT));
    window = WindowUtils.makeWindow(Window.Unit.TIME, null);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EVERY));
    window = WindowUtils.makeWindow(Window.Unit.RECORD, -1);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EVERY));
    window = WindowUtils.makeWindow(Window.Unit.RECORD, 0);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EVERY));
    window = WindowUtils.makeWindow(Window.Unit.RECORD, 2);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.NOT_ONE_RECORD_EMIT));
    window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.ALL, null);
    window.getInclude().put(Window.INCLUDE_FIRST_FIELD, 1000);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_FIRST));
    window = WindowUtils.makeWindow(Window.Unit.RECORD, 1, Window.Unit.ALL, null);
    window.getInclude().put(Window.INCLUDE_FIRST_FIELD, 10);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.NO_RECORD_ALL));
    window = WindowUtils.makeWindow(Window.Unit.TIME, 1, Window.Unit.ALL, null);
    window.getInclude().put(Window.INCLUDE_FIRST_FIELD, 10);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_FIRST));
    window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.TIME, null);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
    window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.TIME, 2000);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
    window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.RECORD, 5);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
    window = WindowUtils.makeWindow(Window.Unit.RECORD, 1, Window.Unit.RECORD, 5);
    window.configure(config);
    errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
}
Also used : List(java.util.List) Collections.singletonList(java.util.Collections.singletonList) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 20 with BulletConfig

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

the class WindowTest method testProperInitialization.

@Test
public void testProperInitialization() {
    BulletConfig config = new BulletConfig();
    Window window;
    Optional<List<BulletError>> errors;
    window = WindowUtils.makeTumblingWindow(2000);
    window.configure(config);
    Assert.assertFalse(window.initialize().isPresent());
    window = WindowUtils.makeWindow(Window.Unit.TIME, 2000);
    window.configure(config);
    Assert.assertFalse(window.initialize().isPresent());
    window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.TIME, 1000);
    window.configure(config);
    errors = window.initialize();
    Assert.assertFalse(errors.isPresent());
    window = WindowUtils.makeReactiveWindow();
    window.configure(config);
    Assert.assertFalse(window.initialize().isPresent());
    window = WindowUtils.makeWindow(Window.Unit.RECORD, 1, Window.Unit.RECORD, 1);
    window.configure(config);
    errors = window.initialize();
    Assert.assertFalse(errors.isPresent());
    window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.ALL, null);
    window.configure(config);
    errors = window.initialize();
    Assert.assertFalse(errors.isPresent());
}
Also used : List(java.util.List) Collections.singletonList(java.util.Collections.singletonList) 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