Search in sources :

Example 6 with Window

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

the class WindowingOperationsTest method testRawReactiveWindow.

@Test
public void testRawReactiveWindow() {
    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.RAW);
    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 7 with Window

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

the class AdditiveTumblingTest method make.

private AdditiveTumbling make(int length, int minimumWindow) {
    config.set(BulletConfig.WINDOW_MIN_EMIT_EVERY, minimumWindow);
    config.validate();
    Window window = makeAdditiveTumblingWindow(length);
    return new AdditiveTumbling(strategy, window, config);
}
Also used : Window(com.yahoo.bullet.parsing.Window)

Example 8 with Window

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

the class ReactiveTest method makeReactiveWindow.

private Window makeReactiveWindow() {
    Window window = WindowUtils.makeReactiveWindow();
    window.configure(config);
    window.initialize();
    return window;
}
Also used : Window(com.yahoo.bullet.parsing.Window)

Example 9 with Window

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

the class ReactiveTest method testBadMaxWindowSize.

@Test
public void testBadMaxWindowSize() {
    Window window = WindowUtils.makeWindow(Window.Unit.RECORD, 10);
    window.configure(config);
    Optional<List<BulletError>> errors = window.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Window.NOT_ONE_RECORD_EMIT));
    Reactive reactive = new Reactive(strategy, window, config);
    errors = reactive.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Reactive.ONLY_ONE_RECORD));
    window = WindowUtils.makeWindow(Window.Unit.TIME, 10000);
    window.configure(config);
    Assert.assertFalse(window.initialize().isPresent());
    reactive = new Reactive(strategy, window, config);
    errors = reactive.initialize();
    Assert.assertTrue(errors.isPresent());
    Assert.assertEquals(errors.get(), singletonList(Reactive.NOT_RECORD));
}
Also used : Window(com.yahoo.bullet.parsing.Window) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) Arrays.asList(java.util.Arrays.asList) Test(org.testng.annotations.Test)

Example 10 with Window

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

the class ReactiveTest method testResettingForPartitoin.

@Test
public void testResettingForPartitoin() {
    Window window = makeReactiveWindow();
    Reactive reactive = new Reactive(strategy, window, config);
    Assert.assertFalse(reactive.initialize().isPresent());
    Assert.assertEquals(strategy.getResetCalls(), 0);
    reactive.consume(RecordBox.get().getRecord());
    Assert.assertTrue(reactive.isClosed());
    Assert.assertTrue(reactive.isClosedForPartition());
    Assert.assertEquals(strategy.getConsumeCalls(), 1);
    reactive.resetForPartition();
    Assert.assertFalse(reactive.isClosed());
    Assert.assertFalse(reactive.isClosedForPartition());
    Assert.assertEquals(strategy.getResetCalls(), 1);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Test(org.testng.annotations.Test)

Aggregations

Window (com.yahoo.bullet.parsing.Window)32 Test (org.testng.annotations.Test)24 BulletConfig (com.yahoo.bullet.common.BulletConfig)6 Query (com.yahoo.bullet.parsing.Query)6 Aggregation (com.yahoo.bullet.parsing.Aggregation)5 MockStrategy (com.yahoo.bullet.aggregations.MockStrategy)2 Meta (com.yahoo.bullet.result.Meta)2 Arrays.asList (java.util.Arrays.asList)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 Map (java.util.Map)2 AdditiveTumbling (com.yahoo.bullet.windowing.AdditiveTumbling)1 Basic (com.yahoo.bullet.windowing.Basic)1 Reactive (com.yahoo.bullet.windowing.Reactive)1 Tumbling (com.yahoo.bullet.windowing.Tumbling)1