Search in sources :

Example 1 with BatchIteratorTester

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

the class AsyncOperationBatchIteratorTest method runTest.

private void runTest(Supplier<BatchIterator> sourceSupplier) throws Exception {
    Supplier<BatchIterator> biSupplier = () -> {
        BatchIterator source = sourceSupplier.get();
        Input<?> input = source.rowData().get(0);
        BatchAccumulator<Row, Iterator<? extends Row>> accumulator = new DummyBatchAccumulator(input);
        return new AsyncOperationBatchIterator(source, 1, accumulator);
    };
    List<Object[]> expectedResult = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        expectedResult.add(new Object[] { i * 3 });
    }
    BatchIteratorTester tester = new BatchIteratorTester(biSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : ArrayList(java.util.ArrayList) BatchIteratorTester(io.crate.testing.BatchIteratorTester)

Example 2 with BatchIteratorTester

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

the class CollectingBatchIteratorTest method testCollectingBatchIterator.

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

Example 3 with BatchIteratorTester

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

the class CompositeBatchIteratorTest method testCompositeBatchIterator.

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

Example 4 with BatchIteratorTester

use of io.crate.testing.BatchIteratorTester 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 5 with BatchIteratorTester

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

the class FilteringBatchIteratorTest method testFilteringBatchIterator.

@Test
public void testFilteringBatchIterator() throws Exception {
    List<Object[]> expectedResult = IntStream.iterate(0, l -> l + 2).limit(10).mapToObj(l -> new Object[] { l }).collect(Collectors.toList());
    BatchIteratorTester tester = new BatchIteratorTester(() -> new FilteringBatchIterator(TestingBatchIterators.range(0, 20), evenRow));
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : TestingBatchIterators(io.crate.testing.TestingBatchIterators) IntStream(java.util.stream.IntStream) List(java.util.List) Test(org.junit.Test) BatchIteratorTester(io.crate.testing.BatchIteratorTester) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) BooleanSupplier(java.util.function.BooleanSupplier) BatchIteratorTester(io.crate.testing.BatchIteratorTester) 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