Search in sources :

Example 21 with DependencyCarrier

use of io.crate.planner.DependencyCarrier in project crate by crate.

the class UpdateSettingsPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
    ClusterUpdateSettingsRequest request = isPersistent ? new ClusterUpdateSettingsRequest().persistentSettings(buildSettingsFrom(settings, eval)) : new ClusterUpdateSettingsRequest().transientSettings(buildSettingsFrom(settings, eval));
    OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
    dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, actionListener);
}
Also used : CrateSettings(io.crate.metadata.settings.CrateSettings) Collection(java.util.Collection) Function(java.util.function.Function) Lists2(io.crate.common.collections.Lists2) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) Assignment(io.crate.sql.tree.Assignment) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Settings(org.elasticsearch.common.settings.Settings) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 22 with DependencyCarrier

use of io.crate.planner.DependencyCarrier in project crate by crate.

the class DeletePartitions method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    ArrayList<String> indexNames = getIndices(plannerContext.transactionContext(), dependencies.nodeContext(), params, subQueryResults);
    DeleteIndexRequest request = new DeleteIndexRequest(indexNames.toArray(new String[0]));
    request.indicesOptions(IndicesOptions.lenientExpandOpen());
    dependencies.transportActionProvider().transportDeleteIndexAction().execute(request, new OneRowActionListener<>(consumer, r -> Row1.ROW_COUNT_UNKNOWN));
}
Also used : IndexParts(io.crate.metadata.IndexParts) TransactionContext(io.crate.metadata.TransactionContext) NodeContext(io.crate.metadata.NodeContext) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) RelationName(io.crate.metadata.RelationName) Function(java.util.function.Function) Lists2(io.crate.common.collections.Lists2) PartitionName(io.crate.metadata.PartitionName) ArrayList(java.util.ArrayList) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) List(java.util.List) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) DataTypes(io.crate.types.DataTypes) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

Example 23 with DependencyCarrier

use of io.crate.planner.DependencyCarrier in project crate by crate.

the class DropSnapshotPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row parameters, SubQueryResults subQueryResult) {
    DeleteSnapshotRequest request = new DeleteSnapshotRequest(dropSnapshot.repository(), dropSnapshot.snapshot());
    var transportDeleteSnapshotAction = dependencies.transportActionProvider().transportDeleteSnapshotAction();
    transportDeleteSnapshotAction.execute(request, new OneRowActionListener<>(consumer, response -> {
        if (!response.isAcknowledged()) {
            LOGGER.info("delete snapshot '{}.{}' not acknowledged", request.repository(), request.snapshot());
        }
        return new Row1(1L);
    }));
}
Also used : RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) Logger(org.apache.logging.log4j.Logger) Row(io.crate.data.Row) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest) OneRowActionListener(io.crate.execution.support.OneRowActionListener) LogManager(org.apache.logging.log4j.LogManager) AnalyzedDropSnapshot(io.crate.analyze.AnalyzedDropSnapshot) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest)

Example 24 with DependencyCarrier

use of io.crate.planner.DependencyCarrier in project crate by crate.

the class AlterTableAddColumnPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
    BoundAddColumn stmt = bind(alterTable, plannerContext.transactionContext(), dependencies.nodeContext(), params, subQueryResults, dependencies.fulltextAnalyzerResolver());
    dependencies.alterTableOperation().executeAlterTableAddColumn(stmt).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
Also used : AnalyzedColumnDefinition(io.crate.analyze.AnalyzedColumnDefinition) HashMap(java.util.HashMap) ObjectType(io.crate.types.ObjectType) Function(java.util.function.Function) ArrayList(java.util.ArrayList) DependencyCarrier(io.crate.planner.DependencyCarrier) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Settings(org.elasticsearch.common.settings.Settings) Locale(java.util.Locale) Map(java.util.Map) OneRowActionListener(io.crate.execution.support.OneRowActionListener) AnalyzedAlterTableAddColumn(io.crate.analyze.AnalyzedAlterTableAddColumn) FulltextAnalyzerResolver(io.crate.metadata.FulltextAnalyzerResolver) LinkedHashSet(java.util.LinkedHashSet) DocSysColumns(io.crate.metadata.doc.DocSysColumns) DocTableInfo(io.crate.metadata.doc.DocTableInfo) TableInfo(io.crate.metadata.table.TableInfo) NodeContext(io.crate.metadata.NodeContext) BoundAddColumn(io.crate.analyze.BoundAddColumn) ColumnIdent(io.crate.metadata.ColumnIdent) Reference(io.crate.metadata.Reference) CheckConstraint(io.crate.sql.tree.CheckConstraint) RowConsumer(io.crate.data.RowConsumer) Objects(java.util.Objects) AnalyzedTableElements(io.crate.analyze.AnalyzedTableElements) List(java.util.List) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) Row1(io.crate.data.Row1) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) Row1(io.crate.data.Row1) BoundAddColumn(io.crate.analyze.BoundAddColumn)

Example 25 with DependencyCarrier

use of io.crate.planner.DependencyCarrier 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)

Aggregations

DependencyCarrier (io.crate.planner.DependencyCarrier)25 Row (io.crate.data.Row)24 PlannerContext (io.crate.planner.PlannerContext)24 RowConsumer (io.crate.data.RowConsumer)23 SubQueryResults (io.crate.planner.operators.SubQueryResults)22 Row1 (io.crate.data.Row1)21 Plan (io.crate.planner.Plan)21 OneRowActionListener (io.crate.execution.support.OneRowActionListener)19 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)17 Symbol (io.crate.expression.symbol.Symbol)17 Function (java.util.function.Function)17 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)11 List (java.util.List)10 DocTableInfo (io.crate.metadata.doc.DocTableInfo)8 ArrayList (java.util.ArrayList)8 NodeContext (io.crate.metadata.NodeContext)7 Settings (org.elasticsearch.common.settings.Settings)7 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)6 InMemoryBatchIterator (io.crate.data.InMemoryBatchIterator)5 SENTINEL (io.crate.data.SentinelRow.SENTINEL)5