Search in sources :

Example 1 with Projector

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));
}
Also used : Projector(io.crate.data.Projector) Bucket(io.crate.data.Bucket) TestingHelpers.isRow(io.crate.testing.TestingHelpers.isRow) Row(io.crate.data.Row) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with Projector

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);
    }
}
Also used : Projector(io.crate.data.Projector) Projection(io.crate.planner.projection.Projection)

Example 3 with Projector

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));
}
Also used : Projector(io.crate.data.Projector) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 4 with Projector

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));
}
Also used : Projector(io.crate.data.Projector) Bucket(io.crate.data.Bucket) TestingHelpers.isRow(io.crate.testing.TestingHelpers.isRow) Row(io.crate.data.Row) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

Projector (io.crate.data.Projector)4 CrateUnitTest (io.crate.test.integration.CrateUnitTest)3 Test (org.junit.Test)3 Bucket (io.crate.data.Bucket)2 Row (io.crate.data.Row)2 TestingHelpers.isRow (io.crate.testing.TestingHelpers.isRow)2 Projection (io.crate.planner.projection.Projection)1