Search in sources :

Example 1 with Query

use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.

the class IdentityPubSubMessageSerDeTest method testConvertingQuery.

@Test
public void testConvertingQuery() {
    IdentityPubSubMessageSerDe serDe = new IdentityPubSubMessageSerDe(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.assertSame(actual.getContent(), 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 2 with Query

use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.

the class QueryManager method addQuery.

/**
 * Adds a configured, initialized query instance {@link Querier} to the manager.
 *
 * @param id The query ID.
 * @param querier A fully initialized {@link Querier} instance.
 */
public void addQuery(String id, Querier querier) {
    Query query = querier.getQuery();
    Set<String> keys = partitioner.getKeys(query);
    for (String key : keys) {
        partitioning.computeIfAbsent(key, s -> new HashSet<>()).add(id);
        log.debug("Added query: {} to partition: {}", id, key);
    }
    queries.put(id, querier);
}
Also used : Query(com.yahoo.bullet.query.Query) BulletRecord(com.yahoo.bullet.record.BulletRecord) Partitioner(com.yahoo.bullet.querying.partitioning.Partitioner) Set(java.util.Set) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Objects(java.util.Objects) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) BulletConfig(com.yahoo.bullet.common.BulletConfig) Map(java.util.Map) StandardDeviation(org.apache.commons.math3.stat.descriptive.moment.StandardDeviation) Collections(java.util.Collections) Query(com.yahoo.bullet.query.Query) HashSet(java.util.HashSet)

Example 3 with Query

use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.

the class SimpleEqualityPartitionerTest method testDefaultPartitioningQueryWithOR.

@Test
public void testDefaultPartitioningQueryWithOR() {
    SimpleEqualityPartitioner partitioner = createPartitioner("A", "B");
    Query query = createQuery(new BinaryExpression(new BinaryExpression(new FieldExpression("A"), new ValueExpression("bar"), Operation.EQUALS), new BinaryExpression(new FieldExpression("B"), new ValueExpression("baz"), Operation.EQUALS), Operation.OR));
    Assert.assertEquals(partitioner.getKeys(query), singleton("*-*"));
}
Also used : Query(com.yahoo.bullet.query.Query) BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 4 with Query

use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.

the class SimpleEqualityPartitionerTest method testDefaultPartitioningQueryWithNOT.

@Test
public void testDefaultPartitioningQueryWithNOT() {
    SimpleEqualityPartitioner partitioner = createPartitioner("A", "B");
    Query query = createQuery(new UnaryExpression(new BinaryExpression(new FieldExpression("A"), new ValueExpression("bar"), Operation.EQUALS), Operation.NOT));
    Assert.assertEquals(partitioner.getKeys(query), singleton("*-*"));
}
Also used : Query(com.yahoo.bullet.query.Query) BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) UnaryExpression(com.yahoo.bullet.query.expressions.UnaryExpression) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 5 with Query

use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.

the class SimpleEqualityPartitionerTest method testNoPartitioningForQueryWithExpressionFields.

@Test
public void testNoPartitioningForQueryWithExpressionFields() {
    FieldExpression fieldExpression = new FieldExpression("A", new ValueExpression("b"));
    SimpleEqualityPartitioner partitioner = createPartitioner(fieldExpression.getName());
    Query query = createQuery(new BinaryExpression(fieldExpression, new ValueExpression("bar"), Operation.EQUALS));
    Assert.assertEquals(partitioner.getKeys(query), singleton("*"));
}
Also used : Query(com.yahoo.bullet.query.Query) BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Aggregations

Query (com.yahoo.bullet.query.Query)62 Test (org.testng.annotations.Test)55 Projection (com.yahoo.bullet.query.Projection)29 Window (com.yahoo.bullet.query.Window)28 Raw (com.yahoo.bullet.query.aggregations.Raw)27 FieldExpression (com.yahoo.bullet.query.expressions.FieldExpression)26 BulletConfigTest (com.yahoo.bullet.common.BulletConfigTest)25 BinaryExpression (com.yahoo.bullet.query.expressions.BinaryExpression)24 ValueExpression (com.yahoo.bullet.query.expressions.ValueExpression)24 BulletConfig (com.yahoo.bullet.common.BulletConfig)22 BulletRecord (com.yahoo.bullet.record.BulletRecord)13 Expression (com.yahoo.bullet.query.expressions.Expression)11 ListExpression (com.yahoo.bullet.query.expressions.ListExpression)11 UnaryExpression (com.yahoo.bullet.query.expressions.UnaryExpression)11 Field (com.yahoo.bullet.query.Field)6 Metadata (com.yahoo.bullet.pubsub.Metadata)5 RecordBox (com.yahoo.bullet.result.RecordBox)5 TableFunction (com.yahoo.bullet.query.tablefunctions.TableFunction)4 CountDistinct (com.yahoo.bullet.query.aggregations.CountDistinct)3 GroupAll (com.yahoo.bullet.query.aggregations.GroupAll)3