use of io.crate.testing.BatchSimulatingIterator in project crate by crate.
the class NestedLoopBatchIteratorTest method testLeftJoinBatchedSource.
@Test
public void testLeftJoinBatchedSource() throws Exception {
Supplier<BatchIterator> batchIteratorSupplier = () -> NestedLoopBatchIterator.leftJoin(new BatchSimulatingIterator(TestingBatchIterators.range(0, 4), 2, 2, null), new BatchSimulatingIterator(TestingBatchIterators.range(2, 6), 2, 2, null), getCol0EqCol1JoinCondition());
BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
tester.verifyResultAndEdgeCaseBehaviour(leftJoinResult);
}
use of io.crate.testing.BatchSimulatingIterator in project crate by crate.
the class RowsBatchIteratorTest method testCollectRowsWithSimulatedBatches.
@Test
public void testCollectRowsWithSimulatedBatches() throws Exception {
Iterable<Row> rows = RowGenerator.range(0, 50);
Supplier<BatchIterator> batchIteratorSupplier = () -> new CloseAssertingBatchIterator(new BatchSimulatingIterator(RowsBatchIterator.newInstance(rows, 1), 10, 5, null));
BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
List<Object[]> expectedResult = StreamSupport.stream(rows.spliterator(), false).map(Row::materialize).collect(Collectors.toList());
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.testing.BatchSimulatingIterator in project crate by crate.
the class SkippingBatchIteratorTest method testSkippingBatchIteratorWithBatchedSource.
@Test
public void testSkippingBatchIteratorWithBatchedSource() throws Exception {
BatchIteratorTester tester = new BatchIteratorTester(() -> {
BatchIterator source = TestingBatchIterators.range(0, 10);
source = new CloseAssertingBatchIterator(new BatchSimulatingIterator(source, 2, 5, null));
return new SkippingBatchIterator(source, offset);
});
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.testing.BatchSimulatingIterator in project crate by crate.
the class AsyncCompositeBatchIteratorTest method testCompositeBatchIterator.
@Test
public void testCompositeBatchIterator() throws Exception {
Supplier<BatchIterator> batchSimulatingItSupplier = () -> new CloseAssertingBatchIterator(new BatchSimulatingIterator(TestingBatchIterators.range(5, 10), 2, 2, null));
ExecutorService executorService = Executors.newFixedThreadPool(3);
try {
BatchIteratorTester tester = new BatchIteratorTester(() -> new AsyncCompositeBatchIterator(executorService, TestingBatchIterators.range(0, 5), batchSimulatingItSupplier.get()));
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
} finally {
executorService.shutdown();
executorService.awaitTermination(10, TimeUnit.SECONDS);
}
}
use of io.crate.testing.BatchSimulatingIterator in project crate by crate.
the class SingleBucketBuilderTest method testSingleBucketBuilderWithBatchedSource.
@Test
public void testSingleBucketBuilderWithBatchedSource() throws Exception {
BatchIterator iterator = TestingBatchIterators.range(0, 4);
bucketBuilder.accept(new BatchSimulatingIterator(iterator, 2, 2, executor), null);
Bucket rows = bucketBuilder.completionFuture().get(10, TimeUnit.SECONDS);
assertThat(TestingHelpers.printedTable(rows), is("0\n" + "1\n" + "2\n" + "3\n"));
}
Aggregations