use of io.crate.data.BatchIterator in project crate by crate.
the class SingleBucketBuilderTest method testSingleBucketBuilderWithBatchedSource.
@Test
public void testSingleBucketBuilderWithBatchedSource() throws Exception {
BatchIterator iterator = TestingBatchIterators.range(0, 4);
bucketBuilder.accept(new BatchSimulatingIterator(iterator, 2, 2, executor), null);
Bucket rows = bucketBuilder.completionFuture().get(10, TimeUnit.SECONDS);
assertThat(TestingHelpers.printedTable(rows), is("0\n" + "1\n" + "2\n" + "3\n"));
}
use of io.crate.data.BatchIterator in project crate by crate.
the class IndexWriterCountBatchIteratorTest method testIndexWriterIterator.
@Test
public void testIndexWriterIterator() throws Exception {
execute("create table bulk_import (id int primary key) with (number_of_replicas=0)");
ensureGreen();
Supplier<BatchIterator> sourceSupplier = () -> RowsBatchIterator.newInstance(RowGenerator.fromSingleColValues(() -> IntStream.range(0, 10).mapToObj(i -> new BytesRef("{\"id\": " + i + "}")).iterator()), 1);
Supplier<String> indexNameResolver = IndexNameResolver.forTable(new TableIdent(null, "bulk_import"));
Input<?> sourceInput = new InputCollectExpression(0);
List<CollectExpression<Row, ?>> collectExpressions = Collections.singletonList((InputCollectExpression) sourceInput);
RowShardResolver rowShardResolver = getRowShardResolver();
BulkShardProcessor bulkShardProcessor = getBulkShardProcessor();
Supplier<ShardUpsertRequest.Item> updateItemSupplier = () -> new ShardUpsertRequest.Item(rowShardResolver.id(), null, new Object[] { sourceInput.value() }, null);
List<Object[]> expectedResult = Collections.singletonList(new Object[] { 10L });
BatchIteratorTester tester = new BatchIteratorTester(() -> IndexWriterCountBatchIterator.newIndexInstance(sourceSupplier.get(), indexNameResolver, collectExpressions, rowShardResolver, bulkShardProcessor, updateItemSupplier));
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.data.BatchIterator in project crate by crate.
the class SortingProjectorTest method testOrderBy.
@Test
public void testOrderBy() throws Exception {
SortingProjector projector = createProjector(2, 0);
BatchIterator batchIterator = projector.apply(TestingBatchIterators.range(1, 11));
consumer.accept(batchIterator, null);
Bucket rows = consumer.getBucket();
assertThat(rows.size(), is(10));
int iterateLength = 1;
for (Row row : rows) {
assertThat(row, isRow(iterateLength++, true));
}
}
use of io.crate.data.BatchIterator in project crate by crate.
the class SortingProjectorTest method testOrderByWithOffset.
@Test
public void testOrderByWithOffset() throws Exception {
SortingProjector projector = createProjector(2, 5);
BatchIterator batchIterator = projector.apply(TestingBatchIterators.range(1, 11));
consumer.accept(batchIterator, null);
Bucket rows = consumer.getBucket();
assertThat(rows.size(), is(5));
int iterateLength = 6;
for (Row row : rows) {
assertThat(row, isRow(iterateLength++, true));
}
}
use of io.crate.data.BatchIterator in project crate by crate.
the class NodeStatsIteratorTest method testRequestsAreIssued.
@Test
public void testRequestsAreIssued() throws InterruptedException, ExecutionException, TimeoutException {
List<Symbol> toCollect = new ArrayList<>();
toCollect.add(idRef);
toCollect.add(nameRef);
when(collectPhase.toCollect()).thenReturn(toCollect);
BatchIterator iterator = NodeStatsIterator.newInstance(transportNodeStatsAction, collectPhase, nodes, new InputFactory(getFunctions()));
iterator.loadNextBatch();
verifyNoMoreInteractions(transportNodeStatsAction);
}
Aggregations