use of io.crate.testing.TestingBatchConsumer 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();
}
use of io.crate.testing.TestingBatchConsumer in project crate by crate.
the class FileReadingCollectorTest method testMultipleUriSupport.
@Test
public void testMultipleUriSupport() throws Throwable {
List<String> fileUris = new ArrayList<>();
fileUris.add(Paths.get(tmpFile.toURI()).toUri().toString());
fileUris.add(Paths.get(tmpFileEmptyLine.toURI()).toUri().toString());
TestingBatchConsumer consumer = getObjects(fileUris, null);
Iterator<Row> it = consumer.getBucket().iterator();
assertThat(it.next(), isRow("{\"name\": \"Arthur\", \"id\": 4, \"details\": {\"age\": 38}}"));
assertThat(it.next(), isRow("{\"id\": 5, \"name\": \"Trillian\", \"details\": {\"age\": 33}}"));
assertThat(it.next(), isRow("{\"name\": \"Arthur\", \"id\": 4, \"details\": {\"age\": 38}}"));
assertThat(it.next(), isRow("{\"id\": 5, \"name\": \"Trillian\", \"details\": {\"age\": 33}}"));
}
use of io.crate.testing.TestingBatchConsumer in project crate by crate.
the class NestedLoopBatchIteratorTest method testNestedLoopLeftAndRightEmpty.
@Test
public void testNestedLoopLeftAndRightEmpty() throws Exception {
BatchIterator iterator = NestedLoopBatchIterator.crossJoin(RowsBatchIterator.empty(), RowsBatchIterator.empty());
TestingBatchConsumer consumer = new TestingBatchConsumer();
consumer.accept(iterator, null);
assertThat(consumer.getResult(), Matchers.empty());
}
use of io.crate.testing.TestingBatchConsumer in project crate by crate.
the class NestedLoopBatchIteratorTest method testNestedLoopRightEmpty.
@Test
public void testNestedLoopRightEmpty() throws Exception {
BatchIterator iterator = NestedLoopBatchIterator.crossJoin(TestingBatchIterators.range(0, 5), RowsBatchIterator.empty());
TestingBatchConsumer consumer = new TestingBatchConsumer();
consumer.accept(iterator, null);
assertThat(consumer.getResult(), Matchers.empty());
}
use of io.crate.testing.TestingBatchConsumer in project crate by crate.
the class DistributingConsumerTest method testSendUsingDistributingConsumerAndReceiveWithPageDownstreamContext.
@Test
public void testSendUsingDistributingConsumerAndReceiveWithPageDownstreamContext() throws Exception {
Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
TestingBatchConsumer collectingConsumer = new TestingBatchConsumer();
PageDownstreamContext pageDownstreamContext = createPageDownstreamContext(streamers, collectingConsumer);
TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, pageDownstreamContext);
DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
distributingConsumer.accept(TestingBatchIterators.range(0, 5), 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());
}
Aggregations