Search in sources :

Example 26 with Window

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);
}
Also used : Window(com.yahoo.bullet.query.Window) Query(com.yahoo.bullet.query.Query) Projection(com.yahoo.bullet.query.Projection) Raw(com.yahoo.bullet.query.aggregations.Raw) Test(org.testng.annotations.Test)

Example 27 with Window

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");
}
Also used : Window(com.yahoo.bullet.query.Window) Query(com.yahoo.bullet.query.Query) Projection(com.yahoo.bullet.query.Projection) Raw(com.yahoo.bullet.query.aggregations.Raw) Test(org.testng.annotations.Test)

Example 28 with Window

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;
}
Also used : Window(com.yahoo.bullet.query.Window) Query(com.yahoo.bullet.query.Query) Projection(com.yahoo.bullet.query.Projection) Raw(com.yahoo.bullet.query.aggregations.Raw)

Example 29 with Window

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;
}
Also used : Window(com.yahoo.bullet.query.Window) Query(com.yahoo.bullet.query.Query) Projection(com.yahoo.bullet.query.Projection) Raw(com.yahoo.bullet.query.aggregations.Raw)

Example 30 with Window

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);
}
Also used : Window(com.yahoo.bullet.query.Window) MockStrategy(com.yahoo.bullet.querying.aggregations.MockStrategy) Test(org.testng.annotations.Test)

Aggregations

Window (com.yahoo.bullet.query.Window)42 Test (org.testng.annotations.Test)34 Projection (com.yahoo.bullet.query.Projection)28 Query (com.yahoo.bullet.query.Query)28 Raw (com.yahoo.bullet.query.aggregations.Raw)26 BulletConfigTest (com.yahoo.bullet.common.BulletConfigTest)17 FieldExpression (com.yahoo.bullet.query.expressions.FieldExpression)12 BinaryExpression (com.yahoo.bullet.query.expressions.BinaryExpression)11 ValueExpression (com.yahoo.bullet.query.expressions.ValueExpression)11 BulletConfig (com.yahoo.bullet.common.BulletConfig)10 Expression (com.yahoo.bullet.query.expressions.Expression)10 ListExpression (com.yahoo.bullet.query.expressions.ListExpression)10 UnaryExpression (com.yahoo.bullet.query.expressions.UnaryExpression)10 BulletRecord (com.yahoo.bullet.record.BulletRecord)7 Field (com.yahoo.bullet.query.Field)6 Metadata (com.yahoo.bullet.pubsub.Metadata)5 RecordBox (com.yahoo.bullet.result.RecordBox)5 Map (java.util.Map)4 CountDistinct (com.yahoo.bullet.query.aggregations.CountDistinct)3 GroupAll (com.yahoo.bullet.query.aggregations.GroupAll)3