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());
}
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;
}
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());
}
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);
}
}
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());
}
Aggregations