Search in sources :

Example 1 with CompositeBatchIterator

use of io.crate.data.CompositeBatchIterator in project crate by crate.

the class MultiConsumerTest method testFirstAcceptNullIteratorDoesNotCauseNPE.

@Test
public void testFirstAcceptNullIteratorDoesNotCauseNPE() throws Exception {
    TestingBatchConsumer batchConsumer = new TestingBatchConsumer();
    BatchConsumer consumer = new CompositeCollector.MultiConsumer(2, batchConsumer, CompositeBatchIterator::new);
    consumer.accept(null, new IllegalStateException("dummy"));
    consumer.accept(RowsBatchIterator.empty(), null);
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("dummy");
    batchConsumer.getResult();
}
Also used : CompositeBatchIterator(io.crate.data.CompositeBatchIterator) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) BatchConsumer(io.crate.data.BatchConsumer) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with CompositeBatchIterator

use of io.crate.data.CompositeBatchIterator in project crate by crate.

the class MultiConsumerTest method testSuccessfulMultiConsumerUsage.

@Test
public void testSuccessfulMultiConsumerUsage() throws Exception {
    TestingBatchConsumer batchConsumer = new TestingBatchConsumer();
    BatchConsumer consumer = new CompositeCollector.MultiConsumer(2, batchConsumer, CompositeBatchIterator::new);
    consumer.accept(TestingBatchIterators.range(3, 6), null);
    consumer.accept(TestingBatchIterators.range(0, 3), null);
    List<Object[]> result = batchConsumer.getResult();
    assertThat(TestingHelpers.printedTable(new CollectionBucket(result)), is("0\n" + "1\n" + "2\n" + "3\n" + "4\n" + "5\n"));
}
Also used : CompositeBatchIterator(io.crate.data.CompositeBatchIterator) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) BatchConsumer(io.crate.data.BatchConsumer) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) CollectionBucket(io.crate.data.CollectionBucket) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

BatchConsumer (io.crate.data.BatchConsumer)2 CompositeBatchIterator (io.crate.data.CompositeBatchIterator)2 CrateUnitTest (io.crate.test.integration.CrateUnitTest)2 TestingBatchConsumer (io.crate.testing.TestingBatchConsumer)2 Test (org.junit.Test)2 CollectionBucket (io.crate.data.CollectionBucket)1