forked from trinodb/trino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splits from the same buckets are scheduled to the same node to allow bucketed execution. Previously, NodeSelector#computeAssignments takes NodePartitionMap, which contains extra information. This commit introduces BucketNodeMap to represent the mapping in a separate class. This also opens opportunities for engine to schedule bucket execution in a more flexible way.
- Loading branch information
Showing
10 changed files
with
182 additions
and
42 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
presto-main/src/main/java/com/facebook/presto/execution/scheduler/BucketNodeMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.facebook.presto.execution.scheduler; | ||
|
||
import com.facebook.presto.metadata.Split; | ||
import com.facebook.presto.spi.Node; | ||
|
||
import java.util.Optional; | ||
import java.util.function.ToIntFunction; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public abstract class BucketNodeMap | ||
{ | ||
private final ToIntFunction<Split> splitToBucket; | ||
|
||
public BucketNodeMap(ToIntFunction<Split> splitToBucket) | ||
{ | ||
this.splitToBucket = requireNonNull(splitToBucket, "splitToBucket is null"); | ||
} | ||
|
||
public abstract int getBucketCount(); | ||
|
||
public abstract Optional<Node> getAssignedNode(int bucketedId); | ||
|
||
public final Optional<Node> getAssignedNode(Split split) | ||
{ | ||
return getAssignedNode(splitToBucket.applyAsInt(split)); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
presto-main/src/main/java/com/facebook/presto/execution/scheduler/FixedBucketNodeMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.facebook.presto.execution.scheduler; | ||
|
||
import com.facebook.presto.metadata.Split; | ||
import com.facebook.presto.spi.Node; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.function.ToIntFunction; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.base.Verify.verify; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
// the bucket to node mapping is fixed and pre-assigned | ||
public class FixedBucketNodeMap | ||
extends BucketNodeMap | ||
{ | ||
private final Map<Integer, Node> bucketToNode; | ||
private final int bucketCount; | ||
|
||
public FixedBucketNodeMap(ToIntFunction<Split> splitToBucket, Map<Integer, Node> bucketToNode) | ||
{ | ||
super(splitToBucket); | ||
requireNonNull(bucketToNode, "bucketToNode is null"); | ||
this.bucketToNode = ImmutableMap.copyOf(bucketToNode); | ||
bucketCount = bucketToNode.keySet().stream() | ||
.mapToInt(Integer::intValue) | ||
.max() | ||
.getAsInt() + 1; | ||
} | ||
|
||
@Override | ||
public Optional<Node> getAssignedNode(int bucketedId) | ||
{ | ||
checkArgument(bucketedId >= 0 && bucketedId < bucketCount); | ||
Node node = bucketToNode.get(bucketedId); | ||
verify(node != null); | ||
return Optional.of(node); | ||
} | ||
|
||
@Override | ||
public int getBucketCount() | ||
{ | ||
return bucketCount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.