Search in sources :

Example 26 with Window

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

the class SlidingRecordTest method testReachingWindowSizeOnCombine.

@Test
public void testReachingWindowSizeOnCombine() {
    Window window = makeSlidingWindow(10);
    SlidingRecord sliding = new SlidingRecord(strategy, window, config);
    Assert.assertFalse(sliding.initialize().isPresent());
    Assert.assertFalse(sliding.isClosed());
    Assert.assertFalse(sliding.isClosedForPartition());
    for (int i = 0; i < 6; ++i) {
        sliding.consume(RecordBox.get().getRecord());
        Assert.assertFalse(sliding.isClosed());
        Assert.assertTrue(sliding.isClosedForPartition());
    }
    Assert.assertEquals(strategy.getConsumeCalls(), 6);
    byte[] data = sliding.getData();
    // Remake
    strategy = new MockStrategy();
    sliding = new SlidingRecord(strategy, window, config);
    Assert.assertFalse(sliding.initialize().isPresent());
    // Combine in the old data
    sliding.combine(data);
    for (int i = 0; i < 3; ++i) {
        sliding.consume(RecordBox.get().getRecord());
        Assert.assertFalse(sliding.isClosed());
        Assert.assertTrue(sliding.isClosedForPartition());
    }
    Assert.assertFalse(sliding.isClosed());
    Assert.assertTrue(sliding.isClosedForPartition());
    sliding.consume(RecordBox.get().getRecord());
    Assert.assertTrue(sliding.isClosed());
    Assert.assertTrue(sliding.isClosedForPartition());
    Assert.assertEquals(strategy.getConsumeCalls(), 4);
    Assert.assertEquals(strategy.getCombineCalls(), 1);
}
Also used : Window(com.yahoo.bullet.parsing.Window) MockStrategy(com.yahoo.bullet.aggregations.MockStrategy) Test(org.testng.annotations.Test)

Example 27 with Window

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

the class SlidingRecordTest method testResettingForPartition.

@Test
public void testResettingForPartition() {
    Window window = makeSlidingWindow(5);
    SlidingRecord sliding = new SlidingRecord(strategy, window, config);
    Assert.assertFalse(sliding.initialize().isPresent());
    Assert.assertEquals(strategy.getResetCalls(), 0);
    for (int i = 0; i < 4; ++i) {
        sliding.consume(RecordBox.get().getRecord());
        Assert.assertFalse(sliding.isClosed());
        Assert.assertTrue(sliding.isClosedForPartition());
    }
    Assert.assertEquals(strategy.getConsumeCalls(), 4);
    sliding.consume(RecordBox.get().getRecord());
    Assert.assertTrue(sliding.isClosed());
    Assert.assertTrue(sliding.isClosedForPartition());
    sliding.resetForPartition();
    Assert.assertFalse(sliding.isClosed());
    Assert.assertFalse(sliding.isClosedForPartition());
    Assert.assertEquals(strategy.getConsumeCalls(), 5);
    Assert.assertEquals(strategy.getResetCalls(), 1);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Test(org.testng.annotations.Test)

Example 28 with Window

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

the class SlidingRecordTest method testCreation.

@Test
public void testCreation() {
    Window window = makeSlidingWindow(10);
    SlidingRecord sliding = new SlidingRecord(strategy, window, config);
    Assert.assertFalse(sliding.initialize().isPresent());
    Assert.assertFalse(sliding.isClosed());
    Assert.assertFalse(sliding.isClosedForPartition());
}
Also used : Window(com.yahoo.bullet.parsing.Window) Test(org.testng.annotations.Test)

Example 29 with Window

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

the class SlidingRecordTest method testReachingWindowSizeOnConsume.

@Test
public void testReachingWindowSizeOnConsume() {
    Window window = makeSlidingWindow(5);
    SlidingRecord sliding = new SlidingRecord(strategy, window, config);
    Assert.assertFalse(sliding.initialize().isPresent());
    Assert.assertFalse(sliding.isClosed());
    Assert.assertFalse(sliding.isClosedForPartition());
    for (int i = 0; i < 4; ++i) {
        sliding.consume(RecordBox.get().getRecord());
        Assert.assertFalse(sliding.isClosed());
        Assert.assertTrue(sliding.isClosedForPartition());
    }
    sliding.consume(RecordBox.get().getRecord());
    Assert.assertTrue(sliding.isClosed());
    Assert.assertTrue(sliding.isClosedForPartition());
    Assert.assertEquals(strategy.getConsumeCalls(), 5);
}
Also used : Window(com.yahoo.bullet.parsing.Window) Test(org.testng.annotations.Test)

Example 30 with Window

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

the class TumblingTest method makeTumblingWindow.

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

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