use of io.crate.expression.operator.EqOperator in project crate by crate.
the class ProjectionToProjectorVisitorTest method testFilterProjection.
@Test
public void testFilterProjection() throws Exception {
List<Symbol> arguments = Arrays.asList(Literal.of(2), new InputColumn(1));
EqOperator op = (EqOperator) nodeCtx.functions().get(null, EqOperator.NAME, arguments, SearchPath.pathWithPGCatalogAndDoc());
Function function = new Function(op.signature(), arguments, EqOperator.RETURN_TYPE);
FilterProjection projection = new FilterProjection(function, Arrays.asList(new InputColumn(0), new InputColumn(1)));
Projector projector = visitor.create(projection, txnCtx, RamAccounting.NO_ACCOUNTING, memoryManager, UUID.randomUUID());
assertThat(projector, instanceOf(FilterProjector.class));
List<Object[]> rows = new ArrayList<>();
rows.add($("human", 2));
rows.add($("vogon", 1));
BatchIterator<Row> filteredBI = projector.apply(InMemoryBatchIterator.of(new CollectionBucket(rows), SENTINEL, true));
TestingRowConsumer consumer = new TestingRowConsumer();
consumer.accept(filteredBI, null);
Bucket bucket = consumer.getBucket();
assertThat(bucket.size(), is(1));
}
use of io.crate.expression.operator.EqOperator in project crate by crate.
the class ProjectingRowConsumerTest method testConsumerRequiresScrollAndProjectorsDontSupportScrolling.
@Test
public void testConsumerRequiresScrollAndProjectorsDontSupportScrolling() {
List<Symbol> arguments = Arrays.asList(Literal.of(2), new InputColumn(1, DataTypes.INTEGER));
EqOperator op = (EqOperator) nodeCtx.functions().get(null, EqOperator.NAME, arguments, SearchPath.pathWithPGCatalogAndDoc());
Function function = new Function(op.signature(), arguments, EqOperator.RETURN_TYPE);
FilterProjection filterProjection = new FilterProjection(function, Arrays.asList(new InputColumn(0), new InputColumn(1)));
RowConsumer delegateConsumerRequiresScroll = new DummyRowConsumer(true);
RowConsumer projectingConsumer = ProjectingRowConsumer.create(delegateConsumerRequiresScroll, Collections.singletonList(filterProjection), UUID.randomUUID(), txnCtx, RamAccounting.NO_ACCOUNTING, memoryManager, projectorFactory);
assertThat(projectingConsumer.requiresScroll(), is(true));
}
use of io.crate.expression.operator.EqOperator in project crate by crate.
the class DocLevelCollectTest method testCollectDocLevelWhereClause.
@Test
public void testCollectDocLevelWhereClause() throws Throwable {
List<Symbol> arguments = Arrays.asList(testDocLevelReference, Literal.of(2));
EqOperator op = (EqOperator) functions.get(null, EqOperator.NAME, arguments, SearchPath.pathWithPGCatalogAndDoc());
List<Symbol> toCollect = Collections.singletonList(testDocLevelReference);
WhereClause whereClause = new WhereClause(new Function(op.signature(), arguments, EqOperator.RETURN_TYPE));
RoutedCollectPhase collectNode = getCollectNode(toCollect, whereClause);
Bucket result = collect(collectNode);
assertThat(result, contains(isRow(2)));
}
Aggregations