Search in sources :

Example 6 with ExchangeSourceHandle

use of io.trino.spi.exchange.ExchangeSourceHandle in project trino by trinodb.

the class TestStageTaskSourceFactory method testSourceDistributionTaskSource.

@Test
public void testSourceDistributionTaskSource() {
    TaskSource taskSource = createSourceDistributionTaskSource(ImmutableList.of(), ImmutableListMultimap.of(), 2, 0, 3 * STANDARD_WEIGHT, 1000);
    assertFalse(taskSource.isFinished());
    assertEquals(taskSource.getMoreTasks(), ImmutableList.of());
    assertTrue(taskSource.isFinished());
    Split split1 = createSplit(1);
    Split split2 = createSplit(2);
    Split split3 = createSplit(3);
    taskSource = createSourceDistributionTaskSource(ImmutableList.of(split1), ImmutableListMultimap.of(), 2, 0, 2 * STANDARD_WEIGHT, 1000);
    assertEquals(taskSource.getMoreTasks(), ImmutableList.of(new TaskDescriptor(0, ImmutableListMultimap.of(PLAN_NODE_1, split1), ImmutableListMultimap.of(), new NodeRequirements(Optional.of(CATALOG), ImmutableSet.of(), DataSize.of(4, GIGABYTE)))));
    assertTrue(taskSource.isFinished());
    taskSource = createSourceDistributionTaskSource(ImmutableList.of(split1, split2, split3), ImmutableListMultimap.of(), 3, 0, 2 * STANDARD_WEIGHT, 1000);
    List<TaskDescriptor> tasks = readAllTasks(taskSource);
    assertThat(tasks).hasSize(2);
    assertThat(tasks.get(0).getSplits().values()).hasSize(2);
    assertThat(tasks.get(1).getSplits().values()).hasSize(1);
    assertThat(tasks).allMatch(taskDescriptor -> taskDescriptor.getNodeRequirements().equals(new NodeRequirements(Optional.of(CATALOG), ImmutableSet.of(), DataSize.of(4, GIGABYTE))));
    assertThat(tasks).allMatch(taskDescriptor -> taskDescriptor.getExchangeSourceHandles().isEmpty());
    assertThat(flattenSplits(tasks)).hasSameEntriesAs(ImmutableMultimap.of(PLAN_NODE_1, split1, PLAN_NODE_1, split2, PLAN_NODE_1, split3));
    assertTrue(taskSource.isFinished());
    ImmutableListMultimap<PlanNodeId, ExchangeSourceHandle> replicatedSources = ImmutableListMultimap.of(PLAN_NODE_2, new TestingExchangeSourceHandle(0, 1));
    taskSource = createSourceDistributionTaskSource(ImmutableList.of(split1, split2, split3), replicatedSources, 2, 0, 2 * STANDARD_WEIGHT, 1000);
    tasks = readAllTasks(taskSource);
    assertThat(tasks).hasSize(2);
    assertThat(tasks.get(0).getSplits().values()).hasSize(2);
    assertThat(tasks.get(1).getSplits().values()).hasSize(1);
    assertThat(tasks).allMatch(taskDescriptor -> taskDescriptor.getNodeRequirements().equals(new NodeRequirements(Optional.of(CATALOG), ImmutableSet.of(), DataSize.of(4, GIGABYTE))));
    assertThat(tasks).allMatch(taskDescriptor -> taskDescriptor.getExchangeSourceHandles().equals(replicatedSources));
    assertThat(flattenSplits(tasks)).hasSameEntriesAs(ImmutableMultimap.of(PLAN_NODE_1, split1, PLAN_NODE_1, split2, PLAN_NODE_1, split3));
    assertTrue(taskSource.isFinished());
    // non remotely accessible splits
    ImmutableList<Split> splits = ImmutableList.of(createSplit(1, "host1:8080", "host2:8080"), createSplit(2, "host2:8080"), createSplit(3, "host1:8080", "host3:8080"), createSplit(4, "host3:8080", "host1:8080"), createSplit(5, "host1:8080", "host2:8080"), createSplit(6, "host2:8080", "host3:8080"), createSplit(7, "host3:8080", "host4:8080"));
    taskSource = createSourceDistributionTaskSource(splits, ImmutableListMultimap.of(), 3, 0, 2 * STANDARD_WEIGHT, 1000);
    tasks = readAllTasks(taskSource);
    assertThat(tasks).hasSize(4);
    assertThat(tasks.stream()).allMatch(taskDescriptor -> taskDescriptor.getExchangeSourceHandles().isEmpty());
    assertThat(flattenSplits(tasks)).hasSameEntriesAs(Multimaps.index(splits, split -> PLAN_NODE_1));
    assertThat(tasks).allMatch(task -> task.getSplits().values().stream().allMatch(split -> {
        HostAddress requiredAddress = getOnlyElement(task.getNodeRequirements().getAddresses());
        return split.getAddresses().contains(requiredAddress);
    }));
    assertTrue(taskSource.isFinished());
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) QueryId(io.trino.spi.QueryId) Arrays(java.util.Arrays) ArbitraryDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.ArbitraryDistributionTaskSource) ListMultimap(com.google.common.collect.ListMultimap) SingleDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.SingleDistributionTaskSource) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) SplitWeight(io.trino.spi.SplitWeight) CatalogName(io.trino.connector.CatalogName) HashMultimap(com.google.common.collect.HashMultimap) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Map(java.util.Map) Assert.assertFalse(org.testng.Assert.assertFalse) ImmutableSet(com.google.common.collect.ImmutableSet) IdentityHashMap(java.util.IdentityHashMap) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) SplitSource(io.trino.split.SplitSource) Objects(java.util.Objects) DataSize(io.airlift.units.DataSize) List(java.util.List) ClassLayout(org.openjdk.jol.info.ClassLayout) SizeOf.sizeOf(io.airlift.slice.SizeOf.sizeOf) Split(io.trino.metadata.Split) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Optional(java.util.Optional) Assertions.assertThat(org.assertj.guava.api.Assertions.assertThat) ExchangeSourceHandle(io.trino.spi.exchange.ExchangeSourceHandle) HostAddress(io.trino.spi.HostAddress) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) SizeOf.estimatedSizeOf(io.airlift.slice.SizeOf.estimatedSizeOf) Assert.assertEquals(org.testng.Assert.assertEquals) Multimap(com.google.common.collect.Multimap) OptionalInt(java.util.OptionalInt) ExchangeId.createRandomExchangeId(io.trino.spi.exchange.ExchangeId.createRandomExchangeId) Multimaps(com.google.common.collect.Multimaps) HashDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.HashDistributionTaskSource) GIGABYTE(io.airlift.units.DataSize.Unit.GIGABYTE) ImmutableList(com.google.common.collect.ImmutableList) Multimaps.toMultimap(com.google.common.collect.Multimaps.toMultimap) SourceDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.SourceDistributionTaskSource) Objects.requireNonNull(java.util.Objects.requireNonNull) Lifespan(io.trino.execution.Lifespan) Exchange(io.trino.spi.exchange.Exchange) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) DynamicBucketNodeMap(io.trino.execution.scheduler.group.DynamicBucketNodeMap) TableExecuteContextManager(io.trino.execution.TableExecuteContextManager) ConnectorSplit(io.trino.spi.connector.ConnectorSplit) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) ExchangeContext(io.trino.spi.exchange.ExchangeContext) TestingExchangeSourceHandle(io.trino.execution.scheduler.TestingExchange.TestingExchangeSourceHandle) Assert.assertTrue(org.testng.Assert.assertTrue) BYTE(io.airlift.units.DataSize.Unit.BYTE) ExchangeManager(io.trino.spi.exchange.ExchangeManager) ExchangeSourceHandle(io.trino.spi.exchange.ExchangeSourceHandle) TestingExchangeSourceHandle(io.trino.execution.scheduler.TestingExchange.TestingExchangeSourceHandle) Split(io.trino.metadata.Split) ConnectorSplit(io.trino.spi.connector.ConnectorSplit) HostAddress(io.trino.spi.HostAddress) ArbitraryDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.ArbitraryDistributionTaskSource) SingleDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.SingleDistributionTaskSource) HashDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.HashDistributionTaskSource) SourceDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.SourceDistributionTaskSource) TestingExchangeSourceHandle(io.trino.execution.scheduler.TestingExchange.TestingExchangeSourceHandle) Test(org.testng.annotations.Test)

Example 7 with ExchangeSourceHandle

use of io.trino.spi.exchange.ExchangeSourceHandle in project trino by trinodb.

the class TestStageTaskSourceFactory method testArbitraryDistributionTaskSource.

@Test
public void testArbitraryDistributionTaskSource() {
    ExchangeManager splittingExchangeManager = new TestingExchangeManager(true);
    ExchangeManager nonSplittingExchangeManager = new TestingExchangeManager(false);
    TaskSource taskSource = new ArbitraryDistributionTaskSource(new IdentityHashMap<>(), ImmutableListMultimap.of(), ImmutableListMultimap.of(), DataSize.of(3, BYTE), DataSize.of(4, GIGABYTE));
    assertFalse(taskSource.isFinished());
    List<TaskDescriptor> tasks = taskSource.getMoreTasks();
    assertThat(tasks).isEmpty();
    assertTrue(taskSource.isFinished());
    TestingExchangeSourceHandle sourceHandle1 = new TestingExchangeSourceHandle(0, 1);
    TestingExchangeSourceHandle sourceHandle2 = new TestingExchangeSourceHandle(0, 2);
    TestingExchangeSourceHandle sourceHandle3 = new TestingExchangeSourceHandle(0, 3);
    TestingExchangeSourceHandle sourceHandle4 = new TestingExchangeSourceHandle(0, 4);
    TestingExchangeSourceHandle sourceHandle123 = new TestingExchangeSourceHandle(0, 123);
    TestingExchangeSourceHandle sourceHandle321 = new TestingExchangeSourceHandle(0, 321);
    Multimap<PlanNodeId, ExchangeSourceHandle> nonReplicatedSources = ImmutableListMultimap.of(PLAN_NODE_1, sourceHandle3);
    Exchange exchange = splittingExchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 3);
    taskSource = new ArbitraryDistributionTaskSource(new IdentityHashMap<>(ImmutableMap.of(sourceHandle3, exchange)), nonReplicatedSources, ImmutableListMultimap.of(), DataSize.of(3, BYTE), DataSize.of(4, GIGABYTE));
    tasks = taskSource.getMoreTasks();
    assertTrue(taskSource.isFinished());
    assertThat(tasks).hasSize(1);
    assertEquals(tasks, ImmutableList.of(new TaskDescriptor(0, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 3)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE)))));
    nonReplicatedSources = ImmutableListMultimap.of(PLAN_NODE_1, sourceHandle123);
    exchange = nonSplittingExchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 3);
    taskSource = new ArbitraryDistributionTaskSource(new IdentityHashMap<>(ImmutableMap.of(sourceHandle123, exchange)), nonReplicatedSources, ImmutableListMultimap.of(), DataSize.of(3, BYTE), DataSize.of(4, GIGABYTE));
    tasks = taskSource.getMoreTasks();
    assertEquals(tasks, ImmutableList.of(new TaskDescriptor(0, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 123)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE)))));
    nonReplicatedSources = ImmutableListMultimap.of(PLAN_NODE_1, sourceHandle123, PLAN_NODE_2, sourceHandle321);
    exchange = nonSplittingExchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 3);
    taskSource = new ArbitraryDistributionTaskSource(new IdentityHashMap<>(ImmutableMap.of(sourceHandle123, exchange, sourceHandle321, exchange)), nonReplicatedSources, ImmutableListMultimap.of(), DataSize.of(3, BYTE), DataSize.of(4, GIGABYTE));
    tasks = taskSource.getMoreTasks();
    assertEquals(tasks, ImmutableList.of(new TaskDescriptor(0, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 123)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(1, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_2, new TestingExchangeSourceHandle(0, 321)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE)))));
    nonReplicatedSources = ImmutableListMultimap.of(PLAN_NODE_1, sourceHandle1, PLAN_NODE_1, sourceHandle2, PLAN_NODE_2, sourceHandle4);
    exchange = splittingExchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 3);
    taskSource = new ArbitraryDistributionTaskSource(new IdentityHashMap<>(ImmutableMap.of(sourceHandle1, exchange, sourceHandle2, exchange, sourceHandle4, exchange)), nonReplicatedSources, ImmutableListMultimap.of(), DataSize.of(3, BYTE), DataSize.of(4, GIGABYTE));
    tasks = taskSource.getMoreTasks();
    assertEquals(tasks, ImmutableList.of(new TaskDescriptor(0, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 1), PLAN_NODE_1, new TestingExchangeSourceHandle(0, 2)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(1, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_2, new TestingExchangeSourceHandle(0, 3)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(2, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_2, new TestingExchangeSourceHandle(0, 1)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE)))));
    nonReplicatedSources = ImmutableListMultimap.of(PLAN_NODE_1, sourceHandle1, PLAN_NODE_1, sourceHandle3, PLAN_NODE_2, sourceHandle4);
    exchange = splittingExchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 3);
    taskSource = new ArbitraryDistributionTaskSource(new IdentityHashMap<>(ImmutableMap.of(sourceHandle1, exchange, sourceHandle3, exchange, sourceHandle4, exchange)), nonReplicatedSources, ImmutableListMultimap.of(), DataSize.of(3, BYTE), DataSize.of(4, GIGABYTE));
    tasks = taskSource.getMoreTasks();
    assertEquals(tasks, ImmutableList.of(new TaskDescriptor(0, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 1)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(1, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 3)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(2, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_2, new TestingExchangeSourceHandle(0, 3)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(3, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_2, new TestingExchangeSourceHandle(0, 1)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE)))));
    // with replicated sources
    nonReplicatedSources = ImmutableListMultimap.of(PLAN_NODE_1, sourceHandle1, PLAN_NODE_1, sourceHandle2, PLAN_NODE_1, sourceHandle4);
    Multimap<PlanNodeId, ExchangeSourceHandle> replicatedSources = ImmutableListMultimap.of(PLAN_NODE_2, sourceHandle321);
    exchange = splittingExchangeManager.createExchange(new ExchangeContext(new QueryId("query"), createRandomExchangeId()), 3);
    taskSource = new ArbitraryDistributionTaskSource(new IdentityHashMap<>(ImmutableMap.of(sourceHandle1, exchange, sourceHandle2, exchange, sourceHandle4, exchange, sourceHandle321, exchange)), nonReplicatedSources, replicatedSources, DataSize.of(3, BYTE), DataSize.of(4, GIGABYTE));
    tasks = taskSource.getMoreTasks();
    assertEquals(tasks, ImmutableList.of(new TaskDescriptor(0, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 1), PLAN_NODE_1, new TestingExchangeSourceHandle(0, 2), PLAN_NODE_2, new TestingExchangeSourceHandle(0, 321)), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(1, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 3), PLAN_NODE_2, sourceHandle321), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE))), new TaskDescriptor(2, ImmutableListMultimap.of(), ImmutableListMultimap.of(PLAN_NODE_1, new TestingExchangeSourceHandle(0, 1), PLAN_NODE_2, sourceHandle321), new NodeRequirements(Optional.empty(), ImmutableSet.of(), DataSize.of(4, GIGABYTE)))));
}
Also used : ExchangeManager(io.trino.spi.exchange.ExchangeManager) ArbitraryDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.ArbitraryDistributionTaskSource) ExchangeSourceHandle(io.trino.spi.exchange.ExchangeSourceHandle) TestingExchangeSourceHandle(io.trino.execution.scheduler.TestingExchange.TestingExchangeSourceHandle) QueryId(io.trino.spi.QueryId) IdentityHashMap(java.util.IdentityHashMap) TestingExchangeSourceHandle(io.trino.execution.scheduler.TestingExchange.TestingExchangeSourceHandle) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) Exchange(io.trino.spi.exchange.Exchange) ExchangeContext(io.trino.spi.exchange.ExchangeContext) ArbitraryDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.ArbitraryDistributionTaskSource) SingleDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.SingleDistributionTaskSource) HashDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.HashDistributionTaskSource) SourceDistributionTaskSource(io.trino.execution.scheduler.StageTaskSourceFactory.SourceDistributionTaskSource) Test(org.testng.annotations.Test)

Example 8 with ExchangeSourceHandle

use of io.trino.spi.exchange.ExchangeSourceHandle in project trino by trinodb.

the class TestingTaskSourceFactory method getHandlesForRemoteSources.

private static ListMultimap<PlanNodeId, ExchangeSourceHandle> getHandlesForRemoteSources(List<RemoteSourceNode> remoteSources, Multimap<PlanFragmentId, ExchangeSourceHandle> exchangeSourceHandles) {
    ImmutableListMultimap.Builder<PlanNodeId, ExchangeSourceHandle> result = ImmutableListMultimap.builder();
    for (RemoteSourceNode remoteSource : remoteSources) {
        checkArgument(remoteSource.getExchangeType() == REPLICATE, "expected exchange type to be REPLICATE, got: %s", remoteSource.getExchangeType());
        for (PlanFragmentId fragmentId : remoteSource.getSourceFragmentIds()) {
            Collection<ExchangeSourceHandle> handles = requireNonNull(exchangeSourceHandles.get(fragmentId), () -> "exchange source handle is missing for fragment: " + fragmentId);
            checkArgument(handles.size() == 1, "single exchange source handle is expected, got: %s", handles);
            result.putAll(remoteSource.getId(), handles);
        }
    }
    return result.build();
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) ExchangeSourceHandle(io.trino.spi.exchange.ExchangeSourceHandle) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) PlanFragmentId(io.trino.sql.planner.plan.PlanFragmentId)

Example 9 with ExchangeSourceHandle

use of io.trino.spi.exchange.ExchangeSourceHandle in project trino by trinodb.

the class StageTaskSourceFactory method getInputsForRemoteSources.

private static ListMultimap<PlanNodeId, ExchangeSourceHandle> getInputsForRemoteSources(List<RemoteSourceNode> remoteSources, Multimap<PlanFragmentId, ExchangeSourceHandle> exchangeSourceHandles) {
    ImmutableListMultimap.Builder<PlanNodeId, ExchangeSourceHandle> result = ImmutableListMultimap.builder();
    for (RemoteSourceNode remoteSource : remoteSources) {
        for (PlanFragmentId fragmentId : remoteSource.getSourceFragmentIds()) {
            Collection<ExchangeSourceHandle> handles = requireNonNull(exchangeSourceHandles.get(fragmentId), () -> "exchange source handle is missing for fragment: " + fragmentId);
            if (remoteSource.getExchangeType() == GATHER || remoteSource.getExchangeType() == REPLICATE) {
                checkArgument(handles.size() <= 1, "at most 1 exchange source handle is expected, got: %s", handles);
            }
            result.putAll(remoteSource.getId(), handles);
        }
    }
    return result.build();
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) ExchangeSourceHandle(io.trino.spi.exchange.ExchangeSourceHandle) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) PlanFragmentId(io.trino.sql.planner.plan.PlanFragmentId)

Example 10 with ExchangeSourceHandle

use of io.trino.spi.exchange.ExchangeSourceHandle in project trino by trinodb.

the class FileSystemExchange method createExchangeSourceHandles.

private List<ExchangeSourceHandle> createExchangeSourceHandles() {
    Multimap<Integer, FileStatus> partitionFiles = ArrayListMultimap.create();
    List<Integer> finishedTaskPartitions;
    synchronized (this) {
        finishedTaskPartitions = ImmutableList.copyOf(finishedSinks);
    }
    for (Integer taskPartition : finishedTaskPartitions) {
        URI committedAttemptPath = getCommittedAttemptPath(taskPartition);
        Map<Integer, FileStatus> partitions = getCommittedPartitions(committedAttemptPath);
        partitions.forEach(partitionFiles::put);
    }
    ImmutableList.Builder<ExchangeSourceHandle> result = ImmutableList.builder();
    for (Integer partitionId : partitionFiles.keySet()) {
        result.add(new FileSystemExchangeSourceHandle(partitionId, ImmutableList.copyOf(partitionFiles.get(partitionId)), secretKey.map(SecretKey::getEncoded)));
    }
    return result.build();
}
Also used : SecretKey(javax.crypto.SecretKey) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ExchangeSourceHandle(io.trino.spi.exchange.ExchangeSourceHandle) URI(java.net.URI)

Aggregations

ExchangeSourceHandle (io.trino.spi.exchange.ExchangeSourceHandle)10 Exchange (io.trino.spi.exchange.Exchange)6 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)6 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)5 Test (org.testng.annotations.Test)5 QueryId (io.trino.spi.QueryId)4 ExchangeContext (io.trino.spi.exchange.ExchangeContext)4 PlanFragmentId (io.trino.sql.planner.plan.PlanFragmentId)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ExchangeSinkHandle (io.trino.spi.exchange.ExchangeSinkHandle)3 ExchangeSinkInstanceHandle (io.trino.spi.exchange.ExchangeSinkInstanceHandle)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Multimap (com.google.common.collect.Multimap)2 Lifespan (io.trino.execution.Lifespan)2 ArbitraryDistributionTaskSource (io.trino.execution.scheduler.StageTaskSourceFactory.ArbitraryDistributionTaskSource)2 HashDistributionTaskSource (io.trino.execution.scheduler.StageTaskSourceFactory.HashDistributionTaskSource)2 SingleDistributionTaskSource (io.trino.execution.scheduler.StageTaskSourceFactory.SingleDistributionTaskSource)2 SourceDistributionTaskSource (io.trino.execution.scheduler.StageTaskSourceFactory.SourceDistributionTaskSource)2