yl09099 commented on code in PR #2471:
URL: https://github.com/apache/uniffle/pull/2471#discussion_r2078778128


##########
client-spark/common/src/main/java/org/apache/uniffle/shuffle/ShuffleIdMappingManager.java:
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.uniffle.shuffle;
+
+import java.util.Comparator;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.uniffle.common.util.JavaUtils;
+
+/**
+ * We establish a Spark shuffleId and a stage attemptId attemptNumber, and the 
correspondence
+ * between them and the Uniffle shuffleId. The Uniffle shuffleId is 
incrementing forever. For
+ * example:
+ *
+ * <p>| spark shuffleId | shuffleId_stageId_attemptNumber | uniffle shuffleId |
+ *
+ * <p>| 0 | 0_0_0 | 0 |
+ *
+ * <p>| 0 | 0_0_1 | 1 |
+ *
+ * <p>| 0 | 0_0_2 | 2 |
+ *
+ * <p>| 0 | 0_0_3 | 3 |
+ *
+ * <p>| 1 | 1_1_0 | 4 |
+ *
+ * <p>| 1 | 1_1_1 | 5 |
+ *
+ * <p>...
+ */
+public class ShuffleIdMappingManager {
+  // Generate a new ShuffleID.
+  private AtomicInteger shuffleIdGenerator;
+  // appShuffleId -> app_stageid_attemptnumber -> newShuffleId.
+  private Map<Integer, Map<String, Integer>> shuffleIdMapping;
+  // Map the relationship between shuffleId and Determinate.
+  private Map<Integer, Boolean> shuffleDeterminateMap;
+
+  public ShuffleIdMappingManager() {
+    shuffleIdGenerator = new AtomicInteger(-1);
+    shuffleIdMapping = JavaUtils.newConcurrentMap();
+    shuffleDeterminateMap = JavaUtils.newConcurrentMap();
+  }
+
+  /**
+   * Create the shuffleId of uniffle based on the ShuffleID of Spark.
+   *
+   * @param shuffleId
+   * @return
+   */
+  public int createUniffleShuffleId(int shuffleId, String 
appShuffleIdentifier) {

Review Comment:
   > If so, I think it's not a good practise to use a simple string to declare 
this meaning. How about creating a independent class to involve this meaning?
   
   This unique scalar only serves an identification function and involves no 
business logic calculation. Isn't it a bit heavy to create a separate class.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to