zuston commented on code in PR #2751:
URL: https://github.com/apache/uniffle/pull/2751#discussion_r3298094423


##########
client-spark/spark4/src/main/java-spark4_1/org/apache/spark/shuffle/compat/Spark4Compat.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.spark.shuffle.compat;
+
+import scala.Option;
+import scala.math.Ordering;
+
+import org.apache.spark.Aggregator;
+import org.apache.spark.Partitioner;
+import org.apache.spark.TaskContext;
+import org.apache.spark.scheduler.MapStatus;
+import org.apache.spark.serializer.Serializer;
+import org.apache.spark.shuffle.checksum.RowBasedChecksum;
+import org.apache.spark.storage.BlockManagerId;
+import org.apache.spark.util.collection.ExternalSorter;
+
+/**
+ * Compatibility shim for Spark 4.1.x. Selected by the build via the
+ * {@code src/main/java-spark4_1} source root under the {@code spark4.1} 
profile.
+ *
+ * <p>Spark 4.1 added a {@code checksumVal} parameter to {@code 
MapStatus.apply} and a
+ * {@code rowBasedChecksums} parameter to {@link ExternalSorter}'s 
constructor. Both have Scala
+ * defaults but are required from Java; pass disabled defaults (0L and an 
empty array).
+ *
+ * <p>Mirror of {@code java-spark4_0/.../Spark4Compat.java}; keep the public 
surface in lock-step.
+ */
+public final class Spark4Compat {
+
+  private Spark4Compat() {}
+
+  public static MapStatus mapStatus(
+      BlockManagerId loc, long[] uncompressedSizes, long mapTaskId) {
+    return MapStatus.apply(loc, uncompressedSizes, mapTaskId, 0L);
+  }
+
+  public static <K, V, C> ExternalSorter<K, V, C> newExternalSorter(
+      TaskContext context,
+      Option<Aggregator<K, V, C>> aggregator,
+      Option<Partitioner> partitioner,
+      Option<Ordering<K>> ordering,
+      Serializer serializer) {
+    // Spark 4.1's ExternalSorter requires a non-null RowBasedChecksum[]; pass 
an empty
+    // array to disable row-based checksums.
+    return new ExternalSorter<>(
+        context, aggregator, partitioner, ordering, serializer, new 
RowBasedChecksum[0]);

Review Comment:
   Shall we support the row-based checksum in the future? Can you share some 
contexts about this mechanism? 



-- 
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