Search in sources :

Example 36 with TestingRowConsumer

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

the class NestedLoopBatchIteratorsTest method testSemiJoinRightEmpty.

@Test
public void testSemiJoinRightEmpty() throws Exception {
    BatchIterator<Row> iterator = new SemiJoinNLBatchIterator<>(TestingBatchIterators.range(0, 5), InMemoryBatchIterator.empty(SENTINEL), new CombinedRow(1, 1), getCol0EqCol1JoinCondition());
    TestingRowConsumer consumer = new TestingRowConsumer();
    consumer.accept(iterator, null);
    assertThat(consumer.getResult(), Matchers.empty());
}
Also used : Row(io.crate.data.Row) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Example 37 with TestingRowConsumer

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

the class CrossJoinBlockNLBatchIteratorTest method createExpectedResult.

private List<Object[]> createExpectedResult(BatchIterator<Row> left, BatchIterator<Row> right) throws Exception {
    TestingRowConsumer leftConsumer = new TestingRowConsumer();
    leftConsumer.accept(left, null);
    TestingRowConsumer rightConsumer = new TestingRowConsumer();
    rightConsumer.accept(right, null);
    List<Object[]> expectedResults = new ArrayList<>();
    List<Object[]> leftResults = leftConsumer.getResult();
    List<Object[]> rightResults = rightConsumer.getResult();
    expectedRowsLeft = leftResults.size();
    expectedRowsRight = rightResults.size();
    for (Object[] leftRow : leftResults) {
        for (Object[] rightRow : rightResults) {
            Object[] combinedRow = Arrays.copyOf(leftRow, leftRow.length + rightRow.length);
            System.arraycopy(rightRow, 0, combinedRow, leftRow.length, rightRow.length);
            expectedResults.add(combinedRow);
        }
    }
    return expectedResults;
}
Also used : ArrayList(java.util.ArrayList) TestingRowConsumer(io.crate.testing.TestingRowConsumer)

Example 38 with TestingRowConsumer

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

the class CrossJoinBlockNLBatchIteratorTest method testNestedLoopLeftEmpty.

@Test
public void testNestedLoopLeftEmpty() throws Exception {
    BatchIterator<Row> iterator = new CrossJoinBlockNLBatchIterator(InMemoryBatchIterator.empty(SENTINEL), right.get(), new CombinedRow(0, 1), blockSizeCalculator, testingRowAccounting);
    TestingRowConsumer consumer = new TestingRowConsumer();
    consumer.accept(iterator, null);
    assertThat(consumer.getResult(), Matchers.empty());
}
Also used : Row(io.crate.data.Row) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Example 39 with TestingRowConsumer

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

the class AsyncCompositeBatchIteratorTest method testIteratorDoesNotHandleRejectedExecutionException.

@Test
public void testIteratorDoesNotHandleRejectedExecutionException() throws Exception {
    ThreadPoolExecutor executorService = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1));
    try {
        Supplier<BatchIterator<Row>> batchSimulatingItSupplier = () -> new BatchSimulatingIterator<>(TestingBatchIterators.range(0, 5), 2, 2, null);
        BatchIterator<Row> batchIterator = CompositeBatchIterator.asyncComposite(executorService, () -> 3, batchSimulatingItSupplier.get(), batchSimulatingItSupplier.get(), batchSimulatingItSupplier.get(), batchSimulatingItSupplier.get());
        TestingRowConsumer consumer = new TestingRowConsumer();
        consumer.accept(batchIterator, null);
        consumer.getResult();
        fail("The AsyncBatchIterator should not handle the case when the executor rejects new tasks");
    } catch (RejectedExecutionException ignored) {
    // expected
    } finally {
        executorService.shutdown();
        executorService.awaitTermination(10, TimeUnit.SECONDS);
    }
}
Also used : BatchSimulatingIterator(io.crate.testing.BatchSimulatingIterator) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Example 40 with TestingRowConsumer

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

the class NestedLoopBatchIteratorsTest method testSemiJoinLeftEmpty.

@Test
public void testSemiJoinLeftEmpty() throws Exception {
    BatchIterator<Row> iterator = new SemiJoinNLBatchIterator<>(InMemoryBatchIterator.empty(SENTINEL), TestingBatchIterators.range(0, 5), new CombinedRow(1, 1), getCol0EqCol1JoinCondition());
    TestingRowConsumer consumer = new TestingRowConsumer();
    consumer.accept(iterator, null);
    assertThat(consumer.getResult(), Matchers.empty());
}
Also used : Row(io.crate.data.Row) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Aggregations

TestingRowConsumer (io.crate.testing.TestingRowConsumer)64 Test (org.junit.Test)55 Row (io.crate.data.Row)24 CollectionBucket (io.crate.data.CollectionBucket)11 Bucket (io.crate.data.Bucket)10 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)10 InputColumn (io.crate.expression.symbol.InputColumn)6 BatchSimulatingIterator (io.crate.testing.BatchSimulatingIterator)6 ArrayBucket (io.crate.data.ArrayBucket)5 TestingHelpers.isRow (io.crate.testing.TestingHelpers.isRow)5 Streamer (io.crate.Streamer)4 Projector (io.crate.data.Projector)4 GroupingProjector (io.crate.execution.engine.aggregation.GroupingProjector)4 SortingProjector (io.crate.execution.engine.sort.SortingProjector)4 SortingTopNProjector (io.crate.execution.engine.sort.SortingTopNProjector)4 DistResultRXTask (io.crate.execution.jobs.DistResultRXTask)4 ArrayList (java.util.ArrayList)4 RowAccounting (io.crate.breaker.RowAccounting)3 CombinedRow (io.crate.data.join.CombinedRow)3 CompletionException (java.util.concurrent.CompletionException)3