use of io.crate.data.Projector in project crate by crate.
the class SortingTopNProjectorTest method testOrderBy.
@Test
public void testOrderBy() throws Exception {
Projector projector = getProjector(1, 3, 5);
consumer.accept(projector.apply(TestingBatchIterators.range(1, 11)), null);
Bucket rows = consumer.getBucket();
assertThat(rows.size(), is(3));
int iterateLength = 0;
for (Row row : rows) {
assertThat(row, isRow(iterateLength + 6));
iterateLength++;
}
assertThat(iterateLength, is(3));
}
use of io.crate.data.Projector in project crate by crate.
the class ProjectingBatchConsumer method accept.
@Override
public void accept(BatchIterator iterator, @Nullable Throwable failure) {
if (failure == null) {
for (Projection projection : projections) {
Projector projector = projectorFactory.create(projection, ramAccountingContext, jobId);
iterator = projector.apply(iterator);
}
consumer.accept(iterator, null);
} else {
consumer.accept(iterator, failure);
}
}
use of io.crate.data.Projector in project crate by crate.
the class SortingTopNProjectorTest method testWithHighOffset.
@Test
public void testWithHighOffset() throws Exception {
Projector projector = getProjector(2, 2, 30);
consumer.accept(projector.apply(TestingBatchIterators.range(1, 10)), null);
assertThat(consumer.getBucket().size(), is(0));
}
use of io.crate.data.Projector in project crate by crate.
the class SortingTopNProjectorTest method testOrderByWithoutOffset.
@Test
public void testOrderByWithoutOffset() throws Exception {
Projector projector = getProjector(2, 10, TopN.NO_OFFSET);
consumer.accept(projector.apply(TestingBatchIterators.range(1, 11)), null);
Bucket rows = consumer.getBucket();
assertThat(rows.size(), is(10));
int iterateLength = 0;
for (Row row : consumer.getBucket()) {
assertThat(row, isRow(iterateLength + 1, true));
iterateLength++;
}
assertThat(iterateLength, is(10));
}
Aggregations