use of com.yahoo.bullet.query.Window in project bullet-core by yahoo.
the class ByteArrayPubSubMessageSerDeTest method testLazyMessage.
@Test
public void testLazyMessage() {
ByteArrayPubSubMessageSerDe serDe = new ByteArrayPubSubMessageSerDe(null);
Query query = new Query(new Projection(), null, new Raw(1), null, new Window(), 1L);
PubSubMessage converted = serDe.toMessage("id", query, "foo");
PubSubMessage reverted = serDe.fromMessage(converted);
Assert.assertSame(reverted, converted);
// Starts off as byte[]
Assert.assertEquals(reverted.getContent(), SerializerDeserializer.toBytes(query));
// Payload is now made a Query
Query revertedQuery = reverted.getContentAsQuery();
Assert.assertEquals(revertedQuery.getProjection().getType(), Projection.Type.PASS_THROUGH);
Assert.assertEquals(revertedQuery.getAggregation().getType(), AggregationType.RAW);
Assert.assertEquals((long) revertedQuery.getAggregation().getSize(), 1L);
Assert.assertEquals((long) revertedQuery.getDuration(), 1L);
Assert.assertSame(reverted.getContent(), revertedQuery);
// Payload is now made a byte[]
byte[] revertedByteArray = reverted.getContentAsByteArray();
Assert.assertEquals(revertedByteArray, SerializerDeserializer.toBytes(query));
Assert.assertSame(reverted.getContent(), revertedByteArray);
}
use of com.yahoo.bullet.query.Window in project bullet-core by yahoo.
the class ByteArrayPubSubMessageSerDeTest method testConvertingQuery.
@Test
public void testConvertingQuery() {
ByteArrayPubSubMessageSerDe serDe = new ByteArrayPubSubMessageSerDe(null);
Query query = new Query(new Projection(), null, new Raw(1), null, new Window(), 1L);
PubSubMessage actual = serDe.toMessage("id", query, "foo");
Assert.assertEquals(actual.getId(), "id");
Assert.assertEquals(actual.getContent(), SerializerDeserializer.toBytes(query));
Assert.assertEquals(actual.getMetadata().getContent(), "foo");
}
use of com.yahoo.bullet.query.Window in project bullet-core by yahoo.
the class SimpleEqualityPartitionerTest method createQuery.
private Query createQuery() {
Query query = new Query(new Projection(), null, new Raw(null), null, new Window(), null);
query.configure(config);
return query;
}
use of com.yahoo.bullet.query.Window in project bullet-core by yahoo.
the class SimpleEqualityPartitionerTest method createQuery.
private Query createQuery(Expression filter) {
Query query = new Query(new Projection(), filter, new Raw(null), null, new Window(), null);
query.configure(config);
return query;
}
use of com.yahoo.bullet.query.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.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);
// 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);
}
Aggregations