Search in sources :

Example 26 with Projection

use of com.yahoo.bullet.query.Projection 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 Projection

use of com.yahoo.bullet.query.Projection 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 Projection

use of com.yahoo.bullet.query.Projection 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 Projection

use of com.yahoo.bullet.query.Projection 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)

Aggregations

Projection (com.yahoo.bullet.query.Projection)29 Query (com.yahoo.bullet.query.Query)29 Window (com.yahoo.bullet.query.Window)28 Raw (com.yahoo.bullet.query.aggregations.Raw)27 Test (org.testng.annotations.Test)26 BulletConfigTest (com.yahoo.bullet.common.BulletConfigTest)18 FieldExpression (com.yahoo.bullet.query.expressions.FieldExpression)12 BulletConfig (com.yahoo.bullet.common.BulletConfig)11 BinaryExpression (com.yahoo.bullet.query.expressions.BinaryExpression)11 ValueExpression (com.yahoo.bullet.query.expressions.ValueExpression)11 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 CountDistinct (com.yahoo.bullet.query.aggregations.CountDistinct)3 GroupAll (com.yahoo.bullet.query.aggregations.GroupAll)3 Operation (com.yahoo.bullet.query.expressions.Operation)3