Search in sources :

Example 1 with BatchSimulatingIterator

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

the class CompositeBatchIteratorTest method testCompositeBatchIteratorWithBatchedSources.

@Test
public void testCompositeBatchIteratorWithBatchedSources() throws Exception {
    List<Object[]> expectedResult = new ArrayList<>();
    // consumes the unbatched/loaded iterator first
    expectedResult.add(new Object[] { 5 });
    expectedResult.add(new Object[] { 6 });
    expectedResult.add(new Object[] { 7 });
    expectedResult.add(new Object[] { 8 });
    expectedResult.add(new Object[] { 9 });
    expectedResult.add(new Object[] { 0 });
    expectedResult.add(new Object[] { 1 });
    expectedResult.add(new Object[] { 2 });
    expectedResult.add(new Object[] { 3 });
    expectedResult.add(new Object[] { 4 });
    BatchIteratorTester tester = new BatchIteratorTester(() -> new CompositeBatchIterator(new CloseAssertingBatchIterator(new BatchSimulatingIterator(TestingBatchIterators.range(0, 5), 2, 6, null)), TestingBatchIterators.range(5, 10)));
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) ArrayList(java.util.ArrayList) BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

Example 2 with BatchSimulatingIterator

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

the class LimitingBatchIteratorTest method testLimitingBatchIteratorWithBatchedSource.

@Test
public void testLimitingBatchIteratorWithBatchedSource() throws Exception {
    BatchIteratorTester tester = new BatchIteratorTester(() -> {
        BatchSimulatingIterator batchSimulatingIt = new BatchSimulatingIterator(TestingBatchIterators.range(0, 10), 2, 5, null);
        return LimitingBatchIterator.newInstance(batchSimulatingIt, limit);
    });
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

Example 3 with BatchSimulatingIterator

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

the class NestedLoopBatchIteratorTest method testFullOuterJoinBatchedSource.

@Test
public void testFullOuterJoinBatchedSource() throws Exception {
    Supplier<BatchIterator> batchIteratorSupplier = () -> NestedLoopBatchIterator.fullOuterJoin(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(fullJoinResult);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) BatchIteratorTester(io.crate.testing.BatchIteratorTester) NestedLoopBatchIterator(io.crate.data.join.NestedLoopBatchIterator) Test(org.junit.Test)

Example 4 with BatchSimulatingIterator

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

the class NestedLoopBatchIteratorTest method testRightJoinBatchedSource.

@Test
public void testRightJoinBatchedSource() throws Exception {
    Supplier<BatchIterator> batchIteratorSupplier = () -> NestedLoopBatchIterator.rightJoin(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(rightJoinResult);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) BatchIteratorTester(io.crate.testing.BatchIteratorTester) NestedLoopBatchIterator(io.crate.data.join.NestedLoopBatchIterator) Test(org.junit.Test)

Example 5 with BatchSimulatingIterator

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

the class NestedLoopBatchIteratorTest method testNestedLoopWithBatchedSource.

@Test
public void testNestedLoopWithBatchedSource() throws Exception {
    BatchIteratorTester tester = new BatchIteratorTester(() -> NestedLoopBatchIterator.crossJoin(new BatchSimulatingIterator(TestingBatchIterators.range(0, 3), 2, 2, null), new BatchSimulatingIterator(TestingBatchIterators.range(0, 3), 2, 2, null)));
    tester.verifyResultAndEdgeCaseBehaviour(threeXThreeRows);
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

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