Search in sources :

Example 1 with TestingRowConsumer

use of io.crate.testing.TestingRowConsumer in project crate by crate.

the class HandlerSideLevelCollectTest method collect.

private Bucket collect(RoutedCollectPhase collectPhase) throws Exception {
    TestingRowConsumer consumer = new TestingRowConsumer();
    CollectTask collectTask = mock(CollectTask.class);
    when(collectTask.txnCtx()).thenReturn(txnCtx);
    BatchIterator<Row> bi = operation.createIterator(txnCtx, collectPhase, consumer.requiresScroll(), collectTask).get(5, TimeUnit.SECONDS);
    consumer.accept(bi, null);
    return new CollectionBucket(consumer.getResult());
}
Also used : Row(io.crate.data.Row) TestingRowConsumer(io.crate.testing.TestingRowConsumer) CollectionBucket(io.crate.data.CollectionBucket)

Example 2 with TestingRowConsumer

use of io.crate.testing.TestingRowConsumer in project crate by crate.

the class DistributingConsumerTest method testSendUsingDistributingConsumerAndReceiveWithDistResultRXTask.

@Test
public void testSendUsingDistributingConsumerAndReceiveWithDistResultRXTask() throws Exception {
    try {
        Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
        TestingRowConsumer collectingConsumer = new TestingRowConsumer();
        DistResultRXTask distResultRXTask = createPageDownstreamContext(streamers, collectingConsumer);
        TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, distResultRXTask);
        DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
        BatchSimulatingIterator<Row> batchSimulatingIterator = new BatchSimulatingIterator<>(TestingBatchIterators.range(0, 5), 2, 3, executorService);
        distributingConsumer.accept(batchSimulatingIterator, null);
        List<Object[]> result = collectingConsumer.getResult();
        assertThat(TestingHelpers.printedTable(new CollectionBucket(result)), is("0\n" + "1\n" + "2\n" + "3\n" + "4\n"));
        // pageSize=2 and 5 rows causes 3x pushResult
        verify(distributedResultAction, times(3)).pushResult(anyString(), any(), any());
    } finally {
        executorService.shutdown();
        executorService.awaitTermination(10, TimeUnit.SECONDS);
    }
}
Also used : Streamer(io.crate.Streamer) BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) Row(io.crate.data.Row) DistResultRXTask(io.crate.execution.jobs.DistResultRXTask) TestingRowConsumer(io.crate.testing.TestingRowConsumer) CollectionBucket(io.crate.data.CollectionBucket) Test(org.junit.Test)

Example 3 with TestingRowConsumer

use of io.crate.testing.TestingRowConsumer in project crate by crate.

the class DistributingConsumerTest method testFailureOnAllLoadedIsForwarded.

@Test
public void testFailureOnAllLoadedIsForwarded() throws Exception {
    Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
    TestingRowConsumer collectingConsumer = new TestingRowConsumer();
    DistResultRXTask distResultRXTask = createPageDownstreamContext(streamers, collectingConsumer);
    TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, distResultRXTask);
    DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
    distributingConsumer.accept(FailingBatchIterator.failOnAllLoaded(), null);
    expectedException.expect(InterruptedException.class);
    collectingConsumer.getResult();
}
Also used : Streamer(io.crate.Streamer) DistResultRXTask(io.crate.execution.jobs.DistResultRXTask) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Example 4 with TestingRowConsumer

use of io.crate.testing.TestingRowConsumer in project crate by crate.

the class OrderedLuceneBatchIteratorFactoryTest method consumeIteratorAndVerifyResultIsException.

private void consumeIteratorAndVerifyResultIsException(BatchIterator<Row> rowBatchIterator, Exception exception) throws Exception {
    TestingRowConsumer consumer = new TestingRowConsumer();
    consumer.accept(rowBatchIterator, null);
    expectedException.expect(exception.getClass());
    expectedException.expectMessage(exception.getMessage());
    consumer.getResult();
}
Also used : TestingRowConsumer(io.crate.testing.TestingRowConsumer)

Example 5 with TestingRowConsumer

use of io.crate.testing.TestingRowConsumer in project crate by crate.

the class FileReadingCollectorTest method getObjects.

private TestingRowConsumer getObjects(Collection<String> fileUris, String compression, boolean collectSourceUriFailure) throws Throwable {
    TestingRowConsumer consumer = new TestingRowConsumer();
    getObjects(fileUris, compression, consumer, collectSourceUriFailure);
    return consumer;
}
Also used : TestingRowConsumer(io.crate.testing.TestingRowConsumer)

Aggregations

TestingRowConsumer (io.crate.testing.TestingRowConsumer)64 Test (org.junit.Test)55 Row (io.crate.data.Row)24 CollectionBucket (io.crate.data.CollectionBucket)11 Bucket (io.crate.data.Bucket)10 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)10 InputColumn (io.crate.expression.symbol.InputColumn)6 BatchSimulatingIterator (io.crate.testing.BatchSimulatingIterator)6 ArrayBucket (io.crate.data.ArrayBucket)5 TestingHelpers.isRow (io.crate.testing.TestingHelpers.isRow)5 Streamer (io.crate.Streamer)4 Projector (io.crate.data.Projector)4 GroupingProjector (io.crate.execution.engine.aggregation.GroupingProjector)4 SortingProjector (io.crate.execution.engine.sort.SortingProjector)4 SortingTopNProjector (io.crate.execution.engine.sort.SortingTopNProjector)4 DistResultRXTask (io.crate.execution.jobs.DistResultRXTask)4 ArrayList (java.util.ArrayList)4 RowAccounting (io.crate.breaker.RowAccounting)3 CombinedRow (io.crate.data.join.CombinedRow)3 CompletionException (java.util.concurrent.CompletionException)3