use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class ReactiveTest method testMetadata.
@Test
public void testMetadata() {
Window window = makeReactiveWindow();
Reactive reactive = new Reactive(strategy, window, config);
Assert.assertFalse(reactive.initialize().isPresent());
Assert.assertFalse(reactive.isClosed());
Assert.assertFalse(reactive.isClosedForPartition());
reactive.consume(RecordBox.get().getRecord());
Assert.assertTrue(reactive.isClosed());
Assert.assertTrue(reactive.isClosedForPartition());
Assert.assertEquals(strategy.getMetadataCalls(), 0);
long timeNow = System.currentTimeMillis();
Meta meta = reactive.getMetadata();
Assert.assertNotNull(meta);
Map<String, Object> asMap = (Map<String, Object>) meta.asMap().get("window_stats");
Assert.assertEquals(asMap.get("num"), 1L);
Assert.assertEquals(asMap.get("name"), SlidingRecord.NAME);
Assert.assertEquals(asMap.get("size"), 1);
Assert.assertTrue(((Long) asMap.get("close")) >= timeNow);
Assert.assertEquals(strategy.getMetadataCalls(), 1);
reactive.reset();
Assert.assertFalse(reactive.isClosed());
Assert.assertFalse(reactive.isClosedForPartition());
meta = reactive.getMetadata();
Assert.assertNotNull(meta);
asMap = (Map<String, Object>) meta.asMap().get("window_stats");
Assert.assertEquals(asMap.get("num"), 2L);
Assert.assertEquals(asMap.get("name"), SlidingRecord.NAME);
Assert.assertEquals(asMap.get("size"), 0);
Assert.assertTrue(((Long) asMap.get("close")) >= timeNow);
Assert.assertEquals(strategy.getMetadataCalls(), 2);
reactive.consume(RecordBox.get().getRecord());
Assert.assertTrue(reactive.isClosed());
Assert.assertTrue(reactive.isClosedForPartition());
meta = reactive.getMetadata();
Assert.assertNotNull(meta);
asMap = (Map<String, Object>) meta.asMap().get("window_stats");
Assert.assertEquals(asMap.get("num"), 2L);
Assert.assertEquals(asMap.get("name"), SlidingRecord.NAME);
Assert.assertEquals(asMap.get("size"), 1);
Assert.assertTrue(((Long) asMap.get("close")) >= timeNow);
Assert.assertEquals(strategy.getMetadataCalls(), 3);
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class ReactiveTest method testCreation.
@Test
public void testCreation() {
Window window = makeReactiveWindow();
Reactive reactive = new Reactive(strategy, window, config);
Assert.assertFalse(reactive.initialize().isPresent());
Assert.assertFalse(reactive.isClosed());
Assert.assertFalse(reactive.isClosedForPartition());
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class SlidingRecordTest method testImproperInitialization.
@Test
public void testImproperInitialization() {
SlidingRecord sliding = new SlidingRecord(strategy, new Window(), config);
Optional<List<BulletError>> errors = sliding.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(SlidingRecord.NOT_RECORD));
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class WindowingOperationsTest method testTumblingWindow.
@Test
public void testTumblingWindow() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Window window = WindowUtils.makeTumblingWindow(1000);
window.configure(config);
query.setWindow(window);
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Tumbling.class);
}
use of com.yahoo.bullet.parsing.Window in project bullet-core by yahoo.
the class WindowingOperationsTest method testNotForcingRawToReactive.
@Test
public void testNotForcingRawToReactive() {
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.RAW);
query.setAggregation(aggregation);
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), AdditiveTumbling.class);
}
Aggregations