Search in sources :

Example 1 with SessionSettings

use of io.crate.metadata.settings.SessionSettings in project crate by crate.

the class ShardUpsertRequestTest method test_streaming_without_returnvalues.

@Test
public void test_streaming_without_returnvalues() throws Exception {
    ShardId shardId = new ShardId("test", UUIDs.randomBase64UUID(), 1);
    String[] assignmentColumns = new String[] { "id", "name" };
    UUID jobId = UUID.randomUUID();
    Reference[] missingAssignmentColumns = new Reference[] { ID_REF, NAME_REF };
    ShardUpsertRequest request = new ShardUpsertRequest.Builder(new SessionSettings("dummyUser", SearchPath.createSearchPathFrom("dummySchema")), TimeValue.timeValueSeconds(30), DuplicateKeyAction.UPDATE_OR_FAIL, false, assignmentColumns, missingAssignmentColumns, null, jobId, false).newRequest(shardId);
    request.add(123, new ShardUpsertRequest.Item("99", null, new Object[] { 99, "Marvin" }, null, null, null));
    request.add(42, new ShardUpsertRequest.Item("99", new Symbol[0], new Object[] { 99, "Marvin" }, null, null, null));
    request.add(5, new ShardUpsertRequest.Item("42", new Symbol[] { Literal.of(42), Literal.of("Deep Thought") }, null, 2L, 1L, 5L));
    BytesStreamOutput out = new BytesStreamOutput();
    request.writeTo(out);
    StreamInput in = out.bytes().streamInput();
    ShardUpsertRequest request2 = new ShardUpsertRequest(in);
    assertThat(request, equalTo(request2));
}
Also used : Reference(io.crate.metadata.Reference) Symbol(io.crate.expression.symbol.Symbol) SessionSettings(io.crate.metadata.settings.SessionSettings) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) ShardId(org.elasticsearch.index.shard.ShardId) StreamInput(org.elasticsearch.common.io.stream.StreamInput) UUID(java.util.UUID) Test(org.junit.Test)

Example 2 with SessionSettings

use of io.crate.metadata.settings.SessionSettings in project crate by crate.

the class OptimizerTest method test_rule_filtering.

@Test
public void test_rule_filtering() {
    SessionSettings sessionSettings = new SessionSettings("User", SearchPath.pathWithPGCatalogAndDoc(), true, Set.of(MergeFilters.class), true);
    List<Rule<?>> rules = Optimizer.removeExcludedRules(List.of(new MergeFilters()), sessionSettings.excludedOptimizerRules());
    assertThat(rules.isEmpty(), is(true));
    rules = Optimizer.removeExcludedRules(List.of(new MoveFilterBeneathHashJoin()), sessionSettings.excludedOptimizerRules());
    assertThat(rules.size(), is(1));
}
Also used : MoveFilterBeneathHashJoin(io.crate.planner.optimizer.rule.MoveFilterBeneathHashJoin) MergeFilters(io.crate.planner.optimizer.rule.MergeFilters) SessionSettings(io.crate.metadata.settings.SessionSettings) Test(org.junit.Test)

Example 3 with SessionSettings

use of io.crate.metadata.settings.SessionSettings in project crate by crate.

the class RemoteCollectorTest method prepare.

@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);
    UUID jobId = UUID.randomUUID();
    RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 0, "remoteCollect", new Routing(Map.of("remoteNode", Map.of("dummyTable", IntArrayList.from(1)))), RowGranularity.DOC, Collections.singletonList(createReference("name", DataTypes.STRING)), Collections.emptyList(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
    transportJobAction = mock(TransportJobAction.class);
    TasksService tasksService = new TasksService(clusterService, new JobsLogs(() -> true));
    numBroadcastCalls = new AtomicInteger(0);
    transportKillJobsNodeAction = new TransportKillJobsNodeAction(tasksService, clusterService, mock(TransportService.class)) {

        @Override
        public void broadcast(KillJobsRequest request, ActionListener<Long> listener) {
            numBroadcastCalls.incrementAndGet();
        }
    };
    consumer = new TestingRowConsumer();
    remoteCollector = new RemoteCollector(jobId, new SessionSettings("dummyUser", SearchPath.createSearchPathFrom("dummySchema")), "localNode", "remoteNode", transportJobAction, transportKillJobsNodeAction, Runnable::run, tasksService, RamAccounting.NO_ACCOUNTING, consumer, collectPhase);
}
Also used : TransportJobAction(io.crate.execution.jobs.transport.TransportJobAction) TransportKillJobsNodeAction(io.crate.execution.jobs.kill.TransportKillJobsNodeAction) Routing(io.crate.metadata.Routing) TasksService(io.crate.execution.jobs.TasksService) SessionSettings(io.crate.metadata.settings.SessionSettings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) KillJobsRequest(io.crate.execution.jobs.kill.KillJobsRequest) JobsLogs(io.crate.execution.engine.collect.stats.JobsLogs) UUID(java.util.UUID) RoutedCollectPhase(io.crate.execution.dsl.phases.RoutedCollectPhase) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Before(org.junit.Before)

Example 4 with SessionSettings

use of io.crate.metadata.settings.SessionSettings in project crate by crate.

the class ShardUpsertRequestTest method test_streaming_with_returnvalues.

@Test
public void test_streaming_with_returnvalues() throws Exception {
    ShardId shardId = new ShardId("test", UUIDs.randomBase64UUID(), 1);
    String[] assignmentColumns = new String[] { "id", "name" };
    UUID jobId = UUID.randomUUID();
    Reference[] missingAssignmentColumns = new Reference[] { ID_REF, NAME_REF };
    ShardUpsertRequest request = new ShardUpsertRequest.Builder(new SessionSettings("dummyUser", SearchPath.createSearchPathFrom("dummySchema")), TimeValue.timeValueSeconds(30), DuplicateKeyAction.UPDATE_OR_FAIL, false, assignmentColumns, missingAssignmentColumns, null, jobId, false).newRequest(shardId);
    request.add(123, new ShardUpsertRequest.Item("99", null, new Object[] { 99, "Marvin" }, null, null, null));
    request.add(42, new ShardUpsertRequest.Item("99", new Symbol[0], new Object[] { 99, "Marvin" }, null, null, null));
    request.add(5, new ShardUpsertRequest.Item("42", new Symbol[] { Literal.of(42), Literal.of("Deep Thought") }, null, 2L, 1L, 5L));
    BytesStreamOutput out = new BytesStreamOutput();
    request.writeTo(out);
    StreamInput in = out.bytes().streamInput();
    ShardUpsertRequest request2 = new ShardUpsertRequest(in);
    assertThat(request, equalTo(request2));
}
Also used : Reference(io.crate.metadata.Reference) Symbol(io.crate.expression.symbol.Symbol) SessionSettings(io.crate.metadata.settings.SessionSettings) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) ShardId(org.elasticsearch.index.shard.ShardId) StreamInput(org.elasticsearch.common.io.stream.StreamInput) UUID(java.util.UUID) Test(org.junit.Test)

Example 5 with SessionSettings

use of io.crate.metadata.settings.SessionSettings in project crate by crate.

the class JobRequestTest method testJobRequestStreaming.

@Test
public void testJobRequestStreaming() throws Exception {
    JobRequest r1 = new JobRequest(UUID.randomUUID(), new SessionSettings("dummyUser", SearchPath.createSearchPathFrom("dummySchema")), "n1", Collections.emptyList(), true);
    BytesStreamOutput out = new BytesStreamOutput();
    r1.writeTo(out);
    JobRequest r2 = new JobRequest(out.bytes().streamInput());
    assertThat(r1.coordinatorNodeId(), is(r2.coordinatorNodeId()));
    assertThat(r1.jobId(), is(r2.jobId()));
    assertThat(r1.sessionSettings(), is(r2.sessionSettings()));
    assertThat(r1.nodeOperations().isEmpty(), is(true));
    assertThat(r1.enableProfiling(), is(r2.enableProfiling()));
}
Also used : SessionSettings(io.crate.metadata.settings.SessionSettings) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test)

Aggregations

SessionSettings (io.crate.metadata.settings.SessionSettings)5 Test (org.junit.Test)4 UUID (java.util.UUID)3 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)3 Symbol (io.crate.expression.symbol.Symbol)2 Reference (io.crate.metadata.Reference)2 StreamInput (org.elasticsearch.common.io.stream.StreamInput)2 ShardId (org.elasticsearch.index.shard.ShardId)2 RoutedCollectPhase (io.crate.execution.dsl.phases.RoutedCollectPhase)1 JobsLogs (io.crate.execution.engine.collect.stats.JobsLogs)1 TasksService (io.crate.execution.jobs.TasksService)1 KillJobsRequest (io.crate.execution.jobs.kill.KillJobsRequest)1 TransportKillJobsNodeAction (io.crate.execution.jobs.kill.TransportKillJobsNodeAction)1 TransportJobAction (io.crate.execution.jobs.transport.TransportJobAction)1 Routing (io.crate.metadata.Routing)1 MergeFilters (io.crate.planner.optimizer.rule.MergeFilters)1 MoveFilterBeneathHashJoin (io.crate.planner.optimizer.rule.MoveFilterBeneathHashJoin)1 TestingRowConsumer (io.crate.testing.TestingRowConsumer)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Before (org.junit.Before)1