Search in sources :

Example 31 with RowConsumer

use of io.crate.data.RowConsumer in project crate by crate.

the class DeleteAllPartitions method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier executor, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    if (partitions.isEmpty()) {
        consumer.accept(InMemoryBatchIterator.of(new Row1(0L), SentinelRow.SENTINEL), null);
    } else {
        /*
             * table is partitioned, in case of concurrent "delete from partitions"
             * it could be that some partitions are already deleted,
             * so ignore it if some are missing
             */
        DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(partitions().toArray(new String[0])).indicesOptions(IndicesOptions.lenientExpandOpen());
        executor.transportActionProvider().transportDeleteIndexAction().execute(deleteIndexRequest, new OneRowActionListener<>(consumer, r -> Row1.ROW_COUNT_UNKNOWN));
    }
}
Also used : DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) List(java.util.List) Row(io.crate.data.Row) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) OneRowActionListener(io.crate.execution.support.OneRowActionListener) SentinelRow(io.crate.data.SentinelRow) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

Example 32 with RowConsumer

use of io.crate.data.RowConsumer in project crate by crate.

the class DropAnalyzerPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    ClusterUpdateSettingsRequest request = createRequest(dropAnalyzer.name(), dependencies.fulltextAnalyzerResolver());
    dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, new OneRowActionListener<>(consumer, r -> new Row1(1L)));
}
Also used : TOKEN_FILTER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.TOKEN_FILTER) TOKENIZER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.TOKENIZER) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Settings(org.elasticsearch.common.settings.Settings) Row(io.crate.data.Row) ANALYZER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.ANALYZER) AnalyzedDropAnalyzer(io.crate.analyze.AnalyzedDropAnalyzer) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) CHAR_FILTER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.CHAR_FILTER) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) FulltextAnalyzerResolver(io.crate.metadata.FulltextAnalyzerResolver) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 33 with RowConsumer

use of io.crate.data.RowConsumer 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 34 with RowConsumer

use of io.crate.data.RowConsumer 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 35 with RowConsumer

use of io.crate.data.RowConsumer 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)

Aggregations

RowConsumer (io.crate.data.RowConsumer)37 Row (io.crate.data.Row)26 Row1 (io.crate.data.Row1)24 SubQueryResults (io.crate.planner.operators.SubQueryResults)24 OneRowActionListener (io.crate.execution.support.OneRowActionListener)22 DependencyCarrier (io.crate.planner.DependencyCarrier)22 PlannerContext (io.crate.planner.PlannerContext)22 Plan (io.crate.planner.Plan)21 Symbol (io.crate.expression.symbol.Symbol)18 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)17 Function (java.util.function.Function)17 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)12 NodeContext (io.crate.metadata.NodeContext)11 List (java.util.List)10 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)9 ArrayList (java.util.ArrayList)9 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)8 Test (org.junit.Test)8 DocTableInfo (io.crate.metadata.doc.DocTableInfo)7 Settings (org.elasticsearch.common.settings.Settings)7