use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class GroupProjectionTest method testStreaming2.
@Test
public void testStreaming2() throws Exception {
List<Symbol> keys = Collections.singletonList(new InputColumn(0, DataTypes.STRING));
List<Aggregation> aggregations = Collections.singletonList(new Aggregation(CountAggregation.COUNT_STAR_SIGNATURE, CountAggregation.COUNT_STAR_SIGNATURE.getReturnType().createType(), Collections.emptyList()));
GroupProjection groupProjection = new GroupProjection(keys, aggregations, AggregateMode.ITER_FINAL, RowGranularity.CLUSTER);
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(groupProjection, out);
StreamInput in = out.bytes().streamInput();
GroupProjection p2 = (GroupProjection) Projection.fromStream(in);
assertThat(p2.keys().size(), is(1));
assertThat(p2.values().size(), is(1));
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class GroupProjectionTest method testStreamingGranularity.
@Test
public void testStreamingGranularity() throws Exception {
List<Symbol> keys = List.of(new InputColumn(0, DataTypes.STRING), new InputColumn(1, DataTypes.SHORT));
List<Aggregation> aggregations = List.of();
GroupProjection p = new GroupProjection(keys, aggregations, AggregateMode.ITER_FINAL, RowGranularity.SHARD);
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(p, out);
StreamInput in = out.bytes().streamInput();
GroupProjection p2 = (GroupProjection) Projection.fromStream(in);
assertEquals(p, p2);
}
use of io.crate.expression.symbol.InputColumn in project crate by crate.
the class OrderedTopNProjectionTest method testStreaming.
@Test
public void testStreaming() throws Exception {
Projection p = new OrderedTopNProjection(10, 20, Collections.singletonList(Literal.of("foobar")), Collections.singletonList(new InputColumn(0, DataTypes.STRING)), new boolean[] { true }, new boolean[] { true });
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(p, out);
StreamInput in = out.bytes().streamInput();
Projection projection = Projection.fromStream(in);
assertThat(projection, equalTo(p));
}
use of io.crate.expression.symbol.InputColumn 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.symbol.InputColumn in project crate by crate.
the class ProjectionToProjectorVisitorTest method testTopNProjectionToSortingProjector.
@Test
public void testTopNProjectionToSortingProjector() throws Exception {
List<Symbol> outputs = Arrays.asList(Literal.of("foo"), new InputColumn(0), new InputColumn(1));
OrderedTopNProjection projection = new OrderedTopNProjection(TopN.NO_LIMIT, TopN.NO_OFFSET, outputs, Arrays.asList(new InputColumn(0), new InputColumn(1)), new boolean[] { false, false }, new boolean[] { false, false });
Projector projector = visitor.create(projection, txnCtx, RamAccounting.NO_ACCOUNTING, memoryManager, UUID.randomUUID());
assertThat(projector, instanceOf(SortingProjector.class));
}
Aggregations