Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ public class NodePartitionMap
private final List<InternalNode> partitionToNode;
private final int[] bucketToPartition;
private final ToIntFunction<Split> splitToBucket;
private final boolean cacheable;

public NodePartitionMap(List<InternalNode> partitionToNode, ToIntFunction<Split> splitToBucket)
{
this.partitionToNode = ImmutableList.copyOf(requireNonNull(partitionToNode, "partitionToNode is null"));
this.bucketToPartition = IntStream.range(0, partitionToNode.size()).toArray();
this.splitToBucket = requireNonNull(splitToBucket, "splitToBucket is null");
this.cacheable = false;
}

public NodePartitionMap(List<InternalNode> partitionToNode, int[] bucketToPartition, ToIntFunction<Split> splitToBucket)
public NodePartitionMap(List<InternalNode> partitionToNode, int[] bucketToPartition, ToIntFunction<Split> splitToBucket, boolean cacheable)
{
this.bucketToPartition = requireNonNull(bucketToPartition, "bucketToPartition is null");
this.partitionToNode = ImmutableList.copyOf(requireNonNull(partitionToNode, "partitionToNode is null"));
this.splitToBucket = requireNonNull(splitToBucket, "splitToBucket is null");
this.cacheable = cacheable;
}

public List<InternalNode> getPartitionToNode()
Expand All @@ -78,6 +81,6 @@ public BucketNodeMap asBucketNodeMap()
for (int partition : bucketToPartition) {
bucketToNode.add(partitionToNode.get(partition));
}
return new FixedBucketNodeMap(splitToBucket, bucketToNode.build(), false);
return new FixedBucketNodeMap(splitToBucket, bucketToNode.build(), cacheable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,21 @@ public NodePartitionMap getNodePartitioningMap(Session session, PartitioningHand

List<InternalNode> bucketToNode;
NodeSelectionStrategy nodeSelectionStrategy = connectorBucketNodeMap.getNodeSelectionStrategy();
boolean cacheable;
switch (nodeSelectionStrategy) {
case HARD_AFFINITY:
bucketToNode = getFixedMapping(connectorBucketNodeMap);
cacheable = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might miss something, but why is hard affinity not cacheable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard affinity is for connectors that use its own storage like Raptor, we don't want to do cache for them

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sounds good. I thought hard affinity could also apply for disaggregated storage (though should never be more preferable than soft affinity), but let's not worry about it for now.

break;
case SOFT_AFFINITY:
bucketToNode = getFixedMapping(connectorBucketNodeMap);
cacheable = true;
break;
case NO_PREFERENCE:
bucketToNode = createArbitraryBucketToNode(
nodeScheduler.createNodeSelector(connectorId).selectRandomNodes(getMaxTasksPerStage(session)),
connectorBucketNodeMap.getBucketCount());
cacheable = false;
break;
default:
throw new PrestoException(NODE_SELECTION_NOT_SUPPORTED, format("Unsupported node selection strategy %s", nodeSelectionStrategy));
Expand All @@ -158,7 +164,7 @@ public NodePartitionMap getNodePartitioningMap(Session session, PartitioningHand
.mapToObj(partitionId -> nodeToPartition.inverse().get(partitionId))
.collect(toImmutableList());

return new NodePartitionMap(partitionToNode, bucketToPartition, getSplitToBucket(session, partitioningHandle));
return new NodePartitionMap(partitionToNode, bucketToPartition, getSplitToBucket(session, partitioningHandle), cacheable);
}

public BucketNodeMap getBucketNodeMap(Session session, PartitioningHandle partitioningHandle, boolean preferDynamic)
Expand Down