Search in sources :

Example 41 with TestingRowConsumer

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

the class S3FileReadingCollectorTest method getObjects.

private TestingRowConsumer getObjects(Collection<String> fileUris, String compression, S3ObjectInputStream s3InputStream, boolean collectSourceUriFailure) throws Throwable {
    TestingRowConsumer consumer = new TestingRowConsumer();
    getObjects(fileUris, compression, s3InputStream, consumer, collectSourceUriFailure);
    return consumer;
}
Also used : TestingRowConsumer(io.crate.testing.TestingRowConsumer)

Example 42 with TestingRowConsumer

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

the class KillPlanTest method testKillTaskCallsBroadcastOnTransportKillAllNodeAction.

@Test
public void testKillTaskCallsBroadcastOnTransportKillAllNodeAction() {
    AtomicInteger broadcastCalls = new AtomicInteger(0);
    AtomicInteger nodeOperationCalls = new AtomicInteger(0);
    TransportKillAllNodeAction killAllNodeAction = new TransportKillAllNodeAction(new TasksService(clusterService, new JobsLogs(() -> false)), clusterService, mock(TransportService.class)) {

        @Override
        public void broadcast(KillAllRequest request, ActionListener<Long> listener) {
            broadcastCalls.incrementAndGet();
        }

        @Override
        public CompletableFuture<KillResponse> nodeOperation(KillAllRequest request) {
            nodeOperationCalls.incrementAndGet();
            return super.nodeOperation(request);
        }
    };
    KillPlan killPlan = new KillPlan(null);
    killPlan.execute(null, "dummy-user", killAllNodeAction, mock(TransportKillJobsNodeAction.class), new TestingRowConsumer());
    assertThat(broadcastCalls.get(), is(1));
    assertThat(nodeOperationCalls.get(), is(0));
}
Also used : TransportKillJobsNodeAction(io.crate.execution.jobs.kill.TransportKillJobsNodeAction) KillAllRequest(io.crate.execution.jobs.kill.KillAllRequest) ActionListener(org.elasticsearch.action.ActionListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TransportService(org.elasticsearch.transport.TransportService) TransportKillAllNodeAction(io.crate.execution.jobs.kill.TransportKillAllNodeAction) TasksService(io.crate.execution.jobs.TasksService) JobsLogs(io.crate.execution.engine.collect.stats.JobsLogs) KillResponse(io.crate.execution.jobs.kill.KillResponse) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Example 43 with TestingRowConsumer

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

the class SQLIntegrationTestCase method execute.

public TestingRowConsumer execute(PlanForNode planForNode) {
    DependencyCarrier dependencyCarrier = internalCluster().getInstance(DependencyCarrier.class, planForNode.nodeName);
    TestingRowConsumer downstream = new TestingRowConsumer();
    planForNode.plan.execute(dependencyCarrier, planForNode.plannerContext, downstream, Row.EMPTY, SubQueryResults.EMPTY);
    return downstream;
}
Also used : DependencyCarrier(io.crate.planner.DependencyCarrier) TestingRowConsumer(io.crate.testing.TestingRowConsumer)

Example 44 with TestingRowConsumer

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

the class DocValuesGroupByOptimizedIteratorTest method test_group_by_doc_values_optimized_iterator_for_single_numeric_key.

@Test
public void test_group_by_doc_values_optimized_iterator_for_single_numeric_key() throws Exception {
    SumAggregation<?> sumAggregation = (SumAggregation<?>) functions.getQualified(Signature.aggregate(SumAggregation.NAME, DataTypes.LONG.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.LONG), DataTypes.LONG);
    var sumDocValuesAggregator = sumAggregation.getDocValueAggregator(List.of(new Reference(new ReferenceIdent(RelationName.fromIndexName("test"), "z"), RowGranularity.DOC, DataTypes.LONG, ColumnPolicy.DYNAMIC, IndexType.PLAIN, true, true, 0, null)), mock(DocTableInfo.class), List.of());
    var keyExpressions = List.of(new LongColumnReference("y"));
    var it = DocValuesGroupByOptimizedIterator.GroupByIterator.forSingleKey(List.of(sumDocValuesAggregator), indexSearcher, new Reference(new ReferenceIdent(RelationName.fromIndexName("test"), "y"), RowGranularity.DOC, DataTypes.LONG, ColumnPolicy.DYNAMIC, IndexType.PLAIN, true, true, 0, null), keyExpressions, RamAccounting.NO_ACCOUNTING, null, null, new MatchAllDocsQuery(), new CollectorContext());
    var rowConsumer = new TestingRowConsumer();
    rowConsumer.accept(it, null);
    assertThat(rowConsumer.getResult(), containsInAnyOrder(new Object[] { 0L, 6L }, new Object[] { 1L, 4L }));
}
Also used : DocTableInfo(io.crate.metadata.doc.DocTableInfo) BytesRefColumnReference(io.crate.expression.reference.doc.lucene.BytesRefColumnReference) AtomicReference(java.util.concurrent.atomic.AtomicReference) LongColumnReference(io.crate.expression.reference.doc.lucene.LongColumnReference) Reference(io.crate.metadata.Reference) SumAggregation(io.crate.execution.engine.aggregation.impl.SumAggregation) LongColumnReference(io.crate.expression.reference.doc.lucene.LongColumnReference) CollectorContext(io.crate.expression.reference.doc.lucene.CollectorContext) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) ReferenceIdent(io.crate.metadata.ReferenceIdent) TestingRowConsumer(io.crate.testing.TestingRowConsumer) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 45 with TestingRowConsumer

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

the class DistributingConsumerTest method testDistributingConsumerForwardsFailure.

@Test
public void testDistributingConsumerForwardsFailure() throws Exception {
    Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
    TestingRowConsumer collectingConsumer = new TestingRowConsumer();
    DistResultRXTask distResultRXTask = createPageDownstreamContext(streamers, collectingConsumer);
    TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, distResultRXTask);
    DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
    distributingConsumer.accept(null, new CompletionException(new IllegalArgumentException("foobar")));
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("foobar");
    collectingConsumer.getResult();
}
Also used : Streamer(io.crate.Streamer) CompletionException(java.util.concurrent.CompletionException) DistResultRXTask(io.crate.execution.jobs.DistResultRXTask) 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