use of io.crate.data.Row1 in project crate by crate.
the class FetchBatchAccumulatorTest method testFetchBatchAccumulatorMultipleFetches.
@Test
public void testFetchBatchAccumulatorMultipleFetches() throws Exception {
FetchBatchAccumulator fetchBatchAccumulator = new FetchBatchAccumulator(fetchOperation, getFunctions(), buildOutputSymbols(), buildFetchProjectorContext(), 2);
fetchBatchAccumulator.onItem(new Row1(1L));
fetchBatchAccumulator.onItem(new Row1(2L));
Iterator<? extends Row> result = fetchBatchAccumulator.processBatch(false).get(10, TimeUnit.SECONDS);
assertThat(result.next().get(0), is(1));
assertThat(result.next().get(0), is(2));
fetchBatchAccumulator.onItem(new Row1(3L));
fetchBatchAccumulator.onItem(new Row1(4L));
result = fetchBatchAccumulator.processBatch(false).get(10, TimeUnit.SECONDS);
assertThat(result.next().get(0), is(3));
assertThat(result.next().get(0), is(4));
}
use of io.crate.data.Row1 in project crate by crate.
the class GenericShowTask method execute.
@Override
public void execute(BatchConsumer consumer, Row parameters) {
Row1 row;
try {
row = new Row1(showStatementDispatcher.process(statement, jobId));
} catch (Throwable t) {
consumer.accept(null, t);
return;
}
consumer.accept(RowsBatchIterator.newInstance(row), null);
}
use of io.crate.data.Row1 in project crate by crate.
the class BroadcastingBucketBuilderTest method testBucketIsReUsed.
@Test
public void testBucketIsReUsed() throws Exception {
final BroadcastingBucketBuilder builder = new BroadcastingBucketBuilder(new Streamer[] { DataTypes.INTEGER.streamer() }, 3);
builder.add(new Row1(10));
Bucket[] buckets = new Bucket[3];
builder.build(buckets);
final Bucket rows = buckets[0];
assertThat(rows, Matchers.sameInstance(buckets[1]));
assertThat(rows, Matchers.sameInstance(buckets[2]));
}
use of io.crate.data.Row1 in project crate by crate.
the class ModuloBucketBuilderTest method testRowsAreDistributedByModulo.
@Test
public void testRowsAreDistributedByModulo() throws Exception {
final ModuloBucketBuilder builder = new ModuloBucketBuilder(new Streamer[] { DataTypes.INTEGER.streamer() }, 2, 0);
builder.add(new Row1(1));
builder.add(new Row1(2));
builder.add(new Row1(3));
builder.add(new Row1(4));
Bucket[] buckets = new Bucket[2];
builder.build(buckets);
final Bucket rowsD1 = buckets[0];
assertThat(rowsD1.size(), is(2));
assertThat(TestingHelpers.printedTable(rowsD1), is("2\n4\n"));
final Bucket rowsD2 = buckets[1];
assertThat(rowsD2.size(), is(2));
assertThat(TestingHelpers.printedTable(rowsD2), is("1\n3\n"));
}
use of io.crate.data.Row1 in project crate by crate.
the class MultiBucketBuilderTest method testSizeIsResetOnBuildBuckets.
@Test
public void testSizeIsResetOnBuildBuckets() throws Exception {
Bucket[] buckets = new Bucket[1];
for (MultiBucketBuilder builder : builders) {
builder.add(new Row1(42));
builder.add(new Row1(42));
assertThat(builder.size(), is(2));
builder.build(buckets);
assertThat(buckets[0].size(), is(2));
assertThat(builder.size(), is(0));
}
}
Aggregations