Search in sources :

Example 6 with BatchSimulatingIterator

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);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) BatchIteratorTester(io.crate.testing.BatchIteratorTester) NestedLoopBatchIterator(io.crate.data.join.NestedLoopBatchIterator) Test(org.junit.Test)

Example 7 with BatchSimulatingIterator

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);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

Example 8 with BatchSimulatingIterator

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);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

Example 9 with BatchSimulatingIterator

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);
    }
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) ExecutorService(java.util.concurrent.ExecutorService) BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

Example 10 with BatchSimulatingIterator

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"));
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) Bucket(io.crate.data.Bucket) BatchIterator(io.crate.data.BatchIterator) FailingBatchIterator(io.crate.testing.FailingBatchIterator) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

BatchSimulatingIterator (io.crate.testing.BatchSimulatingIterator)10 Test (org.junit.Test)10 BatchIteratorTester (io.crate.testing.BatchIteratorTester)9 NestedLoopBatchIterator (io.crate.data.join.NestedLoopBatchIterator)3 BatchIterator (io.crate.data.BatchIterator)1 Bucket (io.crate.data.Bucket)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 FailingBatchIterator (io.crate.testing.FailingBatchIterator)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1