Search in sources :

Example 1 with Row1

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));
}
Also used : Row1(io.crate.data.Row1) Test(org.junit.Test)

Example 2 with Row1

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);
}
Also used : Row1(io.crate.data.Row1)

Example 3 with Row1

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]));
}
Also used : Row1(io.crate.data.Row1) Bucket(io.crate.data.Bucket) Test(org.junit.Test)

Example 4 with Row1

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"));
}
Also used : Row1(io.crate.data.Row1) Bucket(io.crate.data.Bucket) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 5 with Row1

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));
    }
}
Also used : Row1(io.crate.data.Row1) Bucket(io.crate.data.Bucket) Test(org.junit.Test)

Aggregations

Row1 (io.crate.data.Row1)57 Row (io.crate.data.Row)27 OneRowActionListener (io.crate.execution.support.OneRowActionListener)26 RowConsumer (io.crate.data.RowConsumer)24 Test (org.junit.Test)23 SubQueryResults (io.crate.planner.operators.SubQueryResults)22 DependencyCarrier (io.crate.planner.DependencyCarrier)20 PlannerContext (io.crate.planner.PlannerContext)20 Plan (io.crate.planner.Plan)19 Symbol (io.crate.expression.symbol.Symbol)17 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)16 Function (java.util.function.Function)16 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)11 NodeContext (io.crate.metadata.NodeContext)10 Settings (org.elasticsearch.common.settings.Settings)10 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)9 List (java.util.List)9 ArrayList (java.util.ArrayList)8 Bucket (io.crate.data.Bucket)7 RelationName (io.crate.metadata.RelationName)7