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");
}
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);
}
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("*-*"));
}
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("*-*"));
}
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("*"));
}
Aggregations