use of io.crate.operation.operator.EqOperator in project crate by crate.
the class ProjectionToProjectorVisitorTest method testFilterProjection.
@Test
public void testFilterProjection() throws Exception {
EqOperator op = (EqOperator) functions.get(new FunctionIdent(EqOperator.NAME, ImmutableList.of(DataTypes.INTEGER, DataTypes.INTEGER)));
Function function = new Function(op.info(), Arrays.asList(Literal.of(2), new InputColumn(1)));
FilterProjection projection = new FilterProjection(function, Arrays.asList(new InputColumn(0), new InputColumn(1)));
Projector projector = visitor.create(projection, RAM_ACCOUNTING_CONTEXT, UUID.randomUUID());
assertThat(projector, instanceOf(FilterProjector.class));
List<Object[]> rows = new ArrayList<>();
rows.add($("human", 2));
rows.add($("vogon", 1));
BatchIterator filteredBI = projector.apply(RowsBatchIterator.newInstance(new CollectionBucket(rows), 2));
TestingBatchConsumer consumer = new TestingBatchConsumer();
consumer.accept(filteredBI, null);
Bucket bucket = consumer.getBucket();
assertThat(bucket.size(), is(1));
}
use of io.crate.operation.operator.EqOperator in project crate by crate.
the class DocLevelCollectTest method testCollectDocLevelWhereClause.
@Test
public void testCollectDocLevelWhereClause() throws Throwable {
EqOperator op = (EqOperator) functions.get(new FunctionIdent(EqOperator.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER, DataTypes.INTEGER)));
List<Symbol> toCollect = Collections.<Symbol>singletonList(testDocLevelReference);
WhereClause whereClause = new WhereClause(new Function(op.info(), Arrays.<Symbol>asList(testDocLevelReference, Literal.of(2))));
RoutedCollectPhase collectNode = getCollectNode(toCollect, whereClause);
Bucket result = collect(collectNode);
assertThat(result, contains(isRow(2)));
}
Aggregations