Search in sources :

Example 11 with BatchIteratorTester

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

the class NestedLoopBatchIteratorTest method testLeftJoin.

@Test
public void testLeftJoin() throws Exception {
    Supplier<BatchIterator> batchIteratorSupplier = () -> NestedLoopBatchIterator.leftJoin(TestingBatchIterators.range(0, 4), TestingBatchIterators.range(2, 6), getCol0EqCol1JoinCondition());
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(leftJoinResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) NestedLoopBatchIterator(io.crate.data.join.NestedLoopBatchIterator) Test(org.junit.Test)

Example 12 with BatchIteratorTester

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

the class NestedLoopBatchIteratorTest method testNestedLoopBatchIterator.

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

Example 13 with BatchIteratorTester

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

the class RowsBatchIteratorTest method testCollectRows.

@Test
public void testCollectRows() throws Exception {
    List<Row> rows = Arrays.asList(new Row1(10), new Row1(20));
    Supplier<BatchIterator> batchIteratorSupplier = () -> RowsBatchIterator.newInstance(rows, 1);
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    List<Object[]> expectedResult = Arrays.asList(new Object[] { 10 }, new Object[] { 20 });
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

Example 14 with BatchIteratorTester

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

the class SkippingBatchIteratorTest method testSkippingBatchIterator.

@Test
public void testSkippingBatchIterator() throws Exception {
    BatchIteratorTester tester = new BatchIteratorTester(() -> new SkippingBatchIterator(TestingBatchIterators.range(0, 10), offset));
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test)

Example 15 with BatchIteratorTester

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

the class BatchPagingIteratorTest method testBatchPagingIterator.

@Test
public void testBatchPagingIterator() throws Exception {
    Iterable<Row> rows = RowGenerator.range(0, 3);
    List<Object[]> expectedResult = StreamSupport.stream(rows.spliterator(), false).map(Row::materialize).collect(Collectors.toList());
    BatchIteratorTester tester = new BatchIteratorTester(() -> {
        PassThroughPagingIterator<Integer, Row> pagingIterator = PassThroughPagingIterator.repeatable();
        pagingIterator.merge(Collections.singletonList(new KeyIterable<>(0, rows)));
        return new BatchPagingIterator<>(pagingIterator, exhaustedIt -> false, () -> true, () -> {
        }, 1);
    });
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) Row(io.crate.data.Row) Test(org.junit.Test)

Aggregations

BatchIteratorTester (io.crate.testing.BatchIteratorTester)27 Test (org.junit.Test)26 BatchSimulatingIterator (io.crate.testing.BatchSimulatingIterator)9 NestedLoopBatchIterator (io.crate.data.join.NestedLoopBatchIterator)6 CrateUnitTest (io.crate.test.integration.CrateUnitTest)4 BytesRef (org.apache.lucene.util.BytesRef)3 Symbol (io.crate.analyze.symbol.Symbol)2 BatchIterator (io.crate.data.BatchIterator)2 Row (io.crate.data.Row)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IntStream (java.util.stream.IntStream)2 OrderBy (io.crate.analyze.OrderBy)1 InputColumn (io.crate.analyze.symbol.InputColumn)1 RamAccountingContext (io.crate.breaker.RamAccountingContext)1 Input (io.crate.data.Input)1 RowsBatchIterator (io.crate.data.RowsBatchIterator)1 ShardUpsertRequest (io.crate.executor.transport.ShardUpsertRequest)1 TransportShardUpsertAction (io.crate.executor.transport.TransportShardUpsertAction)1 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)1