Package io.crate.planner

Examples of io.crate.planner.Plan


                ImmutableList.of("99", "42"),
                false,
                false
        );

        Plan plan = new Plan();
        plan.add(indexNode);
        Job job = executor.newJob(plan);
        assertThat(job.tasks().get(0), instanceOf(ESBulkIndexTask.class));

        List<ListenableFuture<TaskResult>> result = executor.execute(job);
        TaskResult taskResult = result.get(0).get();
        assertThat(taskResult.rowCount(), is(2L));
        Object[][] rows = result.get(0).get().rows();
        assertThat(rows.length, is(0));

        // verify insertion

        ImmutableList<Symbol> outputs = ImmutableList.<Symbol>of(id_ref, name_ref);
        ESGetNode getNode = newGetNode("characters", outputs, Arrays.asList("99", "42"));
        plan = new Plan();
        plan.add(getNode);
        job = executor.newJob(plan);
        result = executor.execute(job);
        Object[][] objects = result.get(0).get().rows();

        assertThat(objects.length, is(2));
View Full Code Here


                }},
                whereClause,
                asList("1"),
                asList("1")
        );
        Plan plan = new Plan();
        plan.add(updateNode);
        plan.expectsAffectedRows(true);

        Job job = executor.newJob(plan);
        assertThat(job.tasks().get(0), instanceOf(ESUpdateByIdTask.class));
        List<ListenableFuture<TaskResult>> result = executor.execute(job);
        TaskResult taskResult = result.get(0).get();
        Object[][] rows = taskResult.rows();

        assertThat(rows.length, is(0));
        assertThat(taskResult.rowCount(), is(1L));

        // verify update
        ImmutableList<Symbol> outputs = ImmutableList.<Symbol>of(id_ref, name_ref);
        ESGetNode getNode = newGetNode("characters", outputs, "1");
        plan = new Plan();
        plan.add(getNode);
        job = executor.newJob(plan);
        result = executor.execute(job);
        Object[][] objects = result.get(0).get().rows();

        assertThat(objects.length, is(1));
View Full Code Here

                }},
                whereClause,
                ImmutableList.<String>of(),
                ImmutableList.<String>of()
        );
        Plan plan = new Plan();
        plan.add(updateNode);
        plan.expectsAffectedRows(true);

        Job job = executor.newJob(plan);
        assertThat(job.tasks().get(0), instanceOf(ESUpdateByQueryTask.class));
        List<ListenableFuture<TaskResult>> result = executor.execute(job);
        assertThat(result.get(0).get().errorMessage(), is(nullValue()));
        assertThat(result.get(0).get().rowCount(), is(1L));

        List<Symbol> outputs = Arrays.<Symbol>asList(id_ref, name_ref, version_ref);
        ESGetNode getNode = newGetNode("characters", outputs, "1");
        plan = new Plan();
        plan.add(getNode);
        plan.expectsAffectedRows(false);

        job = executor.newJob(plan);
        result = executor.execute(job);
        Object[][] rows = result.get(0).get().rows();
View Full Code Here

                }},
                new WhereClause(whereClause),
                new ArrayList<String>(0),
                new ArrayList<String>(0)
        );
        Plan plan = new Plan();
        plan.add(updateNode);
        plan.expectsAffectedRows(true);

        Job job = executor.newJob(plan);
        assertThat(job.tasks().get(0), instanceOf(ESUpdateByQueryTask.class));
        List<ListenableFuture<TaskResult>> result = executor.execute(job);
        assertThat(result.get(0).get().rowCount(), is(2L));

        refresh();

        // verify update
        Function searchWhereClause = new Function(new FunctionInfo(
                new FunctionIdent(EqOperator.NAME, Arrays.<DataType>asList(DataTypes.STRING, DataTypes.STRING)),
                DataTypes.BOOLEAN),
                Arrays.<Symbol>asList(name_ref, Literal.newLiteral("mostly harmless")));

        DocTableInfo characters = docSchemaInfo.getTableInfo("characters");
        QueryThenFetchNode node = new QueryThenFetchNode(
                characters.getRouting(WhereClause.MATCH_ALL),
                Arrays.<Symbol>asList(id_ref, name_ref),
                ImmutableList.<Symbol>of(id_ref),
                new boolean[]{false},
                new Boolean[] { null },
                null, null, new WhereClause(searchWhereClause),
                null
        );
        node.outputTypes(Arrays.asList(id_ref.info().type(), name_ref.info().type()));
        plan = new Plan();
        plan.add(node);
        plan.expectsAffectedRows(false);

        job = executor.newJob(plan);
        result = executor.execute(job);
        Object[][] rows = result.get(0).get().rows();
View Full Code Here

        CreateTableNode createTableNode = CreateTableNode.createTableNode(
                "test",
                TEST_SETTINGS,
                TEST_MAPPING
        );
        Plan plan = new Plan();
        plan.add(createTableNode);

        Job job = executor.newJob(plan);
        List<ListenableFuture<TaskResult>> futures = executor.execute(job);
        ListenableFuture<List<TaskResult>> listenableFuture = Futures.allAsList(futures);
        TaskResult taskResult = listenableFuture.get().get(0);
View Full Code Here

        if (analysis.hasNoResult()) {
            DataType[] types = outputTypesExtractor.process(analysis);
            listener.onResponse(emptyResponse(request, outputNames, types));
            return;
        }
        final Plan plan = planner.plan(analysis);
        tracePlan(plan);

        if (plan.isEmpty()) {
            assert plan.expectsAffectedRows();

            UUID jobId = UUID.randomUUID();
            statsTables.jobStarted(jobId, request.stmt());
            sendResponse(listener, emptyResponse(request,
                    outputNames,
                    plan.outputTypes().toArray(new DataType[plan.outputTypes().size()])
                )
            );
            statsTables.jobFinished(jobId, null);
        } else {
            executePlan(plan, outputNames, listener, request);
View Full Code Here

    @Override
    public ListenableFuture<Long> visitAddColumnAnalysis(final AddColumnAnalysis analysis, Void context) {
        final SettableFuture<Long> result = SettableFuture.create();
        if (analysis.newPrimaryKeys()) {
            Plan plan = genCountStarPlan(analysis.table());
            Job job = executorProvider.get().newJob(plan);
            ListenableFuture<List<TaskResult>> resultFuture = Futures.allAsList(executorProvider.get().execute(job));
            Futures.addCallback(resultFuture, new FutureCallback<List<TaskResult>>() {
                @Override
                public void onSuccess(@Nullable List<TaskResult> resultList) {
View Full Code Here

                Arrays.<Projection>asList(new AggregationProjection(ImmutableList.of(countAggregationPartial))));
        collectNode.maxRowGranularity(RowGranularity.DOC);
        collectNode.outputTypes(ImmutableList.<DataType>of(DataTypes.UNDEFINED));
        MergeNode mergeNode = new MergeNode("local count merge", collectNode.executionNodes().size());
        mergeNode.projections(ImmutableList.<Projection>of(new AggregationProjection(ImmutableList.of(countAggregationFinal))));
        Plan plan = new Plan();
        plan.add(collectNode);
        plan.add(mergeNode);
        return plan;
    }
View Full Code Here

TOP

Related Classes of io.crate.planner.Plan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.