use of io.crate.data.RowConsumer in project crate by crate.
the class CreateUserPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
SecureHash newPassword = UserActions.generateSecureHash(createUser.properties(), params, plannerContext.transactionContext(), plannerContext.nodeContext());
userManager.createUser(createUser.userName(), newPassword).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
use of io.crate.data.RowConsumer in project crate by crate.
the class ResetSettingsPlan 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);
Settings settings = buildSettingsFrom(resetAnalyzedStatement.settingsToRemove(), eval);
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(settings).transientSettings(settings);
OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, actionListener);
}
use of io.crate.data.RowConsumer in project crate by crate.
the class DecommissionNodePlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
var boundedNodeIdOrName = boundNodeIdOrName(analyzedDecommissionNode, plannerContext.transactionContext(), plannerContext.nodeContext(), params, subQueryResults);
String targetNodeId = NodeSelection.resolveNodeId(dependencies.clusterService().state().nodes(), boundedNodeIdOrName);
dependencies.transportActionProvider().transportDecommissionNodeAction().execute(targetNodeId, new DecommissionNodeRequest(), new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L)));
}
use of io.crate.data.RowConsumer in project crate by crate.
the class ProjectingRowConsumerTest method testErrorHandlingIfProjectorApplicationFails.
@Test
public void testErrorHandlingIfProjectorApplicationFails() throws Exception {
WriterProjection writerProjection = new WriterProjection(Collections.singletonList(new InputColumn(0, DataTypes.STRING)), Literal.of("/x/y/z/hopefully/invalid/on/your/system/"), null, Collections.emptyMap(), Collections.emptyList(), WriterProjection.OutputFormat.JSON_OBJECT, Settings.EMPTY);
TestingRowConsumer consumer = new TestingRowConsumer();
RowConsumer rowConsumer = ProjectingRowConsumer.create(consumer, Collections.singletonList(writerProjection), UUID.randomUUID(), txnCtx, RamAccounting.NO_ACCOUNTING, memoryManager, projectorFactory);
rowConsumer.accept(InMemoryBatchIterator.empty(SENTINEL), null);
expectedException.expect(UnhandledServerException.class);
expectedException.expectMessage("Failed to open output");
consumer.getResult();
}
use of io.crate.data.RowConsumer in project crate by crate.
the class ProjectingRowConsumerTest method testConsumerDoesNotRequireScrollYieldsProjectingConsumerWithoutScrollRequirements.
@Test
public void testConsumerDoesNotRequireScrollYieldsProjectingConsumerWithoutScrollRequirements() {
GroupProjection groupProjection = new GroupProjection(new ArrayList<>(), new ArrayList<>(), AggregateMode.ITER_FINAL, RowGranularity.DOC);
RowConsumer delegateConsumerRequiresScroll = new DummyRowConsumer(false);
RowConsumer projectingConsumer = ProjectingRowConsumer.create(delegateConsumerRequiresScroll, Collections.singletonList(groupProjection), UUID.randomUUID(), txnCtx, RamAccounting.NO_ACCOUNTING, memoryManager, projectorFactory);
assertThat(projectingConsumer.requiresScroll(), is(false));
}
Aggregations