You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2025/08/06 06:49:51 UTC

[PR] [SPARK-53138] Split common-utils Java code into a new module [spark]

pan3793 opened a new pull request, #51868:
URL: https://github.com/apache/spark/pull/51868

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This PR splits the Java code of `common/utils` into a new module `common/utils-java`, except for:
   
   - `common/utils/src/main/java/org/apache/spark/storage/StorageLevelMapper.java`
   - `common/utils/src/main/java/org/apache/spark/SparkThrowable.java`
   
   A few utility methods are rewritten in Java to avoid depending on `scala-library`.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   To make YARN ESS (`common/network-yarn`) scala-free again.
   
   Read the discussion of SPARK-52942 (https://github.com/apache/spark/pull/51650) for more details.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
   
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   ```
   $ build/mvn -pl common/network-yarn -am clean package -DskipTests -Pyarn
   ...
   [INFO] --- shade:3.6.0:shade (default) @ spark-network-yarn_2.13 ---
   [INFO] Including org.apache.spark:spark-network-shuffle_2.13:jar:4.1.0-SNAPSHOT in the shaded jar.
   [INFO] Including org.apache.spark:spark-network-common_2.13:jar:4.1.0-SNAPSHOT in the shaded jar.
   [INFO] Including io.netty:netty-all:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-buffer:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-codec:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-codec-dns:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-codec-http:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-codec-http2:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-codec-socks:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-common:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-handler:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-native-unix-common:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-handler-proxy:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-resolver:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-resolver-dns:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-classes-epoll:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-classes-kqueue:jar:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-native-epoll:jar:linux-riscv64:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-native-epoll:jar:linux-aarch_64:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-native-kqueue:jar:osx-aarch_64:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.123.Final in the shaded jar.
   [INFO] Including io.netty:netty-tcnative-boringssl-static:jar:linux-x86_64:2.0.72.Final in the shaded jar.
   [INFO] Including io.netty:netty-tcnative-classes:jar:2.0.72.Final in the shaded jar.
   [INFO] Including io.netty:netty-tcnative-boringssl-static:jar:windows-x86_64:2.0.72.Final in the shaded jar.
   [INFO] Including io.netty:netty-tcnative-boringssl-static:jar:linux-aarch_64:2.0.72.Final in the shaded jar.
   [INFO] Including io.netty:netty-tcnative-boringssl-static:jar:osx-aarch_64:2.0.72.Final in the shaded jar.
   [INFO] Including io.netty:netty-tcnative-boringssl-static:jar:osx-x86_64:2.0.72.Final in the shaded jar.
   [INFO] Including org.fusesource.leveldbjni:leveldbjni-all:jar:1.8 in the shaded jar.
   [INFO] Including org.rocksdb:rocksdbjni:jar:9.8.4 in the shaded jar.
   [INFO] Including com.fasterxml.jackson.core:jackson-databind:jar:2.19.2 in the shaded jar.
   [INFO] Including com.fasterxml.jackson.core:jackson-core:jar:2.19.2 in the shaded jar.
   [INFO] Including com.fasterxml.jackson.core:jackson-annotations:jar:2.19.2 in the shaded jar.
   [INFO] Including org.apache.commons:commons-crypto:jar:1.1.0 in the shaded jar.
   [INFO] Including com.google.crypto.tink:tink:jar:1.16.0 in the shaded jar.
   [INFO] Including com.google.code.gson:gson:jar:2.11.0 in the shaded jar.
   [INFO] Including org.apache.spark:spark-common-utils-java_2.13:jar:4.1.0-SNAPSHOT in the shaded jar.
   [INFO] Including org.apache.xbean:xbean-asm9-shaded:jar:4.27 in the shaded jar.
   [INFO] Including org.apache.ivy:ivy:jar:2.5.3 in the shaded jar.
   [INFO] Including oro:oro:jar:2.0.8 in the shaded jar.
   [INFO] Including org.slf4j:jul-to-slf4j:jar:2.0.17 in the shaded jar.
   [INFO] Including org.slf4j:jcl-over-slf4j:jar:2.0.17 in the shaded jar.
   [INFO] Including org.apache.logging.log4j:log4j-slf4j2-impl:jar:2.24.3 in the shaded jar.
   [INFO] Including org.apache.logging.log4j:log4j-api:jar:2.24.3 in the shaded jar.
   [INFO] Including org.apache.logging.log4j:log4j-core:jar:2.24.3 in the shaded jar.
   [INFO] Including org.apache.logging.log4j:log4j-1.2-api:jar:2.24.3 in the shaded jar.
   [INFO] Including org.apache.logging.log4j:log4j-layout-template-json:jar:2.24.3 in the shaded jar.
   [INFO] Including org.apache.commons:commons-lang3:jar:3.18.0 in the shaded jar.
   [INFO] Including io.dropwizard.metrics:metrics-core:jar:4.2.32 in the shaded jar.
   [INFO] Including org.roaringbitmap:RoaringBitmap:jar:1.3.0 in the shaded jar.
   [INFO] Including com.google.code.findbugs:jsr305:jar:3.0.0 in the shaded jar.
   [INFO] Including org.spark-project.spark:unused:jar:1.0.0 in the shaded jar.
   ...
   ```
   
   Now, YARN ESS jar is scala-free, rocksdbjni and netty contribute the major size.
   ```
   $ ll common/network-yarn/target/scala-2.13/spark-4.1.0-SNAPSHOT-yarn-shuffle.jar                 
   -rw-r--r--@ 1 chengpan  staff    94M Aug  6 14:17 common/network-yarn/target/scala-2.13/spark-4.1.0-SNAPSHOT-yarn-shuffle.jar
   $ jar tf common/network-yarn/target/scala-2.13/spark-4.1.0-SNAPSHOT-yarn-shuffle.jar | grep scala
   <no-output>
   $ ll ~/.m2/repository/org/rocksdb/rocksdbjni/9.8.4/rocksdbjni-9.8.4.jar         
   -rw-r--r--@ 1 chengpan  staff    68M Jan 12  2025 /Users/chengpan/.m2/repository/org/rocksdb/rocksdbjni/9.8.4/rocksdbjni-9.8.4.jar
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   No.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #51868:
URL: https://github.com/apache/spark/pull/51868#discussion_r2260027907


##########
.github/workflows/build_and_test.yml:
##########
@@ -242,7 +242,7 @@ jobs:
         # Note that the modules below are from sparktestsupport/modules.py.
         modules:
           - >-
-            core, unsafe, kvstore, avro, utils,
+            core, unsafe, kvstore, avro, utils, utils-java,

Review Comment:
   Seems branch-3.5 does not have the Maven daily test, I changed `maven_test.yml` in 21c892f99bcac44b28038ab1a0fd1034d09d3bc4, please help check.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #51868:
URL: https://github.com/apache/spark/pull/51868#issuecomment-3173130264

   If there are no objections within 24 hours, I will merge this one


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #51868:
URL: https://github.com/apache/spark/pull/51868#discussion_r2256340148


##########
common/network-yarn/pom.xml:
##########
@@ -48,7 +48,7 @@
     <dependency>
       <groupId>org.apache.spark</groupId>
       <artifactId>spark-tags_${scala.binary.version}</artifactId>
-      <scope>test</scope>
+      <scope>provided</scope>

Review Comment:
   this does not change the output of artifacts, but is required to fix the scaladocs packaging
   ```
   [INFO] --- scala:4.9.5:doc-jar (attach-scaladocs) @ spark-network-yarn_2.13 ---
   scaladoc error: fatal error: object scala in compiler mirror not found.
   ```
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138] Split common-utils Java code into a new module [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #51868:
URL: https://github.com/apache/spark/pull/51868#discussion_r2256033135


##########
common/utils-java/src/main/java/org/apache/spark/network/util/JavaUtils.java:
##########
@@ -607,4 +604,58 @@ public static String join(List<Object> arr, String sep) {
     }
     return joiner.toString();
   }
+
+  /**
+   * Indicates whether Spark is currently running unit tests.
+   */
+  public static boolean isTesting() {
+    return System.getenv("SPARK_TESTING") != null || System.getProperty("spark.testing") != null;
+  }
+
+  /**
+   * The `os.name` system property.
+   */
+  public static String osName = System.getProperty("os.name");
+
+  /**
+   * The `os.version` system property.
+   */
+  public static String osVersion = System.getProperty("os.version");
+
+  /**
+   * The `java.version` system property.
+   */
+  public static String javaVersion = Runtime.version().toString();
+
+  /**
+   * The `os.arch` system property.
+   */
+  public static String osArch = System.getProperty("os.arch");
+
+  /**
+   * Whether the underlying operating system is Windows.
+   */
+  public static boolean isWindows = osName.regionMatches(true, 0, "Windows", 0, 7);
+
+  /**
+   * Whether the underlying operating system is Mac OS X.
+   */
+  public static boolean isMac = osName.regionMatches(true, 0, "Mac OS X", 0, 8);
+
+  /**
+   * Whether the underlying operating system is Mac OS X and processor is Apple Silicon.
+   */
+  public static boolean isMacOnAppleSilicon = isMac && osArch.equals("aarch64");
+
+  /**
+   * Whether the underlying operating system is Linux.
+   */
+  public static boolean isLinux = osName.regionMatches(true, 0, "Linux", 0, 5);
+
+  /**
+   * Whether the underlying operating system is UNIX.
+   */
+  public static boolean isUnix = Stream.of("AIX", "HP-UX", "Irix", "Linux", "Mac OS X", "Solaris",
+    "SunOS", "FreeBSD", "OpenBSD", "NetBSD")
+    .anyMatch(prefix -> osName.regionMatches(true, 0, prefix, 0, prefix.length()));

Review Comment:
   not sure if the style is right here



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #51868:
URL: https://github.com/apache/spark/pull/51868#issuecomment-3159312376

   this is ready for review, cc @LuciferYang @mridulm @dongjoon-hyun 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #51868:
URL: https://github.com/apache/spark/pull/51868#issuecomment-3177803171

   Merged into master for Apache Spark 4.1.0. Thanks @pan3793 and @dongjoon-hyun 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang closed pull request #51868: [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module
URL: https://github.com/apache/spark/pull/51868


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #51868:
URL: https://github.com/apache/spark/pull/51868#issuecomment-3166988915

   Rebased to resolve conflicts


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138] Split common-utils Java code into a new module [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #51868:
URL: https://github.com/apache/spark/pull/51868#discussion_r2256037639


##########
common/variant/src/main/java/org/apache/spark/types/variant/VariantUtil.java:
##########
@@ -19,6 +19,7 @@
 
 import org.apache.spark.QueryContext;
 import org.apache.spark.SparkRuntimeException;

Review Comment:
   `common/variant` still depends on `common/utils`(Scala) because this is a Scala 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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #51868:
URL: https://github.com/apache/spark/pull/51868#discussion_r2259978715


##########
.github/workflows/build_and_test.yml:
##########
@@ -242,7 +242,7 @@ jobs:
         # Note that the modules below are from sparktestsupport/modules.py.
         modules:
           - >-
-            core, unsafe, kvstore, avro, utils,
+            core, unsafe, kvstore, avro, utils, utils-java,

Review Comment:
   Similar changes should be incorporated into the maven_test.yml file. Meanwhile, both of these files should be utilized for the daily tests of branch-4.0/3.5. It is necessary to consider compatibility issues arising from the absence of certain modules in the relevant branches.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-53138][CORE][BUILD] Split common-utils Java code into a new module [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #51868:
URL: https://github.com/apache/spark/pull/51868#issuecomment-3173120248

   Rebased to resolve conflicts


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org