jeongyooneo commented on a change in pull request #191: [NEMO-332] Refactor
RunTimePass
URL: https://github.com/apache/incubator-nemo/pull/191#discussion_r252133096
##########
File path:
common/src/main/java/org/apache/nemo/common/partitioner/Partitioner.java
##########
@@ -46,40 +47,34 @@
K partition(Object element);
/**
- * Gets appropriate partitioner for an edge.
- *
- * @param runtimeEdge the runtime edge.
- * @return the partitioner for the edge.
+ * @param edgeProperties edge properties.
+ * @param dstProperties vertex properties.
+ * @return the partitioner.
*/
- static Partitioner getPartitioner(final RuntimeEdge runtimeEdge) {
- final StageEdge stageEdge = (StageEdge) runtimeEdge;
- final PartitionerProperty.Value partitionerPropertyValue =
- (PartitionerProperty.Value)
runtimeEdge.getPropertyValueOrRuntimeException(PartitionerProperty.class);
- final int dstParallelism =
- stageEdge.getDstIRVertex().getPropertyValue(ParallelismProperty.class)
- .orElseThrow(() -> new RuntimeException("No parallelism in edge " +
runtimeEdge.getId()));
-
+ static Partitioner getPartitioner(final
ExecutionPropertyMap<EdgeExecutionProperty> edgeProperties,
+ final
ExecutionPropertyMap<VertexExecutionProperty> dstProperties) {
+ final PartitionerProperty.Type type =
+ edgeProperties.get(PartitionerProperty.class).get().left();
final Partitioner partitioner;
- switch (partitionerPropertyValue) {
- case IntactPartitioner:
+ switch (type) {
+ case Intact:
partitioner = new IntactPartitioner();
break;
- case HashPartitioner:
- final KeyExtractor hashKeyExtractor =
- (KeyExtractor)
runtimeEdge.getPropertyValueOrRuntimeException(KeyExtractorProperty.class);
- partitioner = new HashPartitioner(dstParallelism, hashKeyExtractor);
- break;
- case DataSkewHashPartitioner:
- final KeyExtractor dataSkewKeyExtractor =
- (KeyExtractor)
runtimeEdge.getPropertyValueOrRuntimeException(KeyExtractorProperty.class);
- partitioner = new DataSkewHashPartitioner(dstParallelism,
dataSkewKeyExtractor);
- break;
- case DedicatedKeyPerElementPartitioner:
+ case DedicatedKeyPerElement:
partitioner = new DedicatedKeyPerElementPartitioner();
break;
+ case Hash:
+ final int numOfPartitions =
edgeProperties.get(PartitionerProperty.class).get().right();
+ // If AUTO, use the number of destination parallelism to minimize the
number of partitions
Review comment:
Maybe copy this comment to the definition of AUTO_NUMBER_OF_PARTITIONS?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services