You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2023/03/21 05:24:14 UTC

[incubator-paimon] branch master updated: [refactor] simplify String operations and add JDK version into README (#672)

This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new c024de9e2 [refactor] simplify String operations and add JDK version into README (#672)
c024de9e2 is described below

commit c024de9e2e42e6e7f23248736dbef7acb2a2b917
Author: legendtkl <ta...@bytedance.com>
AuthorDate: Tue Mar 21 13:24:08 2023 +0800

    [refactor] simplify String operations and add JDK version into README (#672)
---
 README.md                                                             | 1 +
 .../src/main/java/org/apache/paimon/benchmark/Benchmark.java          | 4 ++--
 .../apache/paimon/benchmark/metric/cpu/ProcfsBasedProcessTree.java    | 4 +---
 .../src/main/java/org/apache/paimon/utils/Preconditions.java          | 2 +-
 paimon-common/src/main/java/org/apache/paimon/utils/StringUtils.java  | 2 +-
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 0a4869df3..8aa9c138d 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ Paimon tracks issues in GitHub and prefers to receive contributions as pull requ
 <b style="color:red">Please make sure you are subscribed to the mailing list you are posting to!</b> If you are not subscribed to the mailing list, your message will either be rejected (dev@ list) or you won't receive the response (user@ list).
 
 ## Building
+JDK 8 is required for building the project.
 
 - Run the `mvn clean package -DskipTests` command to build the project.
 - Run the `mvn spotless:apply` to format the project (both Java and Scala).
diff --git a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/Benchmark.java b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/Benchmark.java
index cace7e9f6..c5f137a9f 100644
--- a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/Benchmark.java
+++ b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/Benchmark.java
@@ -70,7 +70,7 @@ public class Benchmark {
 
         String queriesValue = line.getOptionValue(QUERIES.getOpt());
         List<Query> queries = Query.load(location);
-        if (!"all".equals(queriesValue.toLowerCase())) {
+        if (!"all".equalsIgnoreCase(queriesValue)) {
             List<String> wantedQueries =
                     Arrays.stream(queriesValue.split(","))
                             .map(String::trim)
@@ -80,7 +80,7 @@ public class Benchmark {
 
         String sinksValue = line.getOptionValue(SINKS.getOpt());
         List<Sink> sinks = Sink.load(location);
-        if (!"all".equals(sinksValue.toLowerCase())) {
+        if (!"all".equalsIgnoreCase(sinksValue)) {
             List<String> wantedSinks =
                     Arrays.stream(sinksValue.split(","))
                             .map(String::trim)
diff --git a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/ProcfsBasedProcessTree.java b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/ProcfsBasedProcessTree.java
index 47473e513..b1a9b3fd8 100644
--- a/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/ProcfsBasedProcessTree.java
+++ b/paimon-benchmark/paimon-cluster-benchmark/src/main/java/org/apache/paimon/benchmark/metric/cpu/ProcfsBasedProcessTree.java
@@ -702,9 +702,7 @@ public class ProcfsBasedProcessTree {
                 fReader =
                         new InputStreamReader(
                                 new FileInputStream(
-                                        new File(
-                                                new File(procfsDir, pid.toString()),
-                                                PROCFS_CMDLINE_FILE)),
+                                        new File(new File(procfsDir, pid), PROCFS_CMDLINE_FILE)),
                                 Charset.forName("UTF-8"));
             } catch (FileNotFoundException f) {
                 // The process vanished in the interim!
diff --git a/paimon-common/src/main/java/org/apache/paimon/utils/Preconditions.java b/paimon-common/src/main/java/org/apache/paimon/utils/Preconditions.java
index b90ea3b95..1dcaf12fd 100644
--- a/paimon-common/src/main/java/org/apache/paimon/utils/Preconditions.java
+++ b/paimon-common/src/main/java/org/apache/paimon/utils/Preconditions.java
@@ -280,7 +280,7 @@ public final class Preconditions {
             if (placeholderStart == -1) {
                 break;
             }
-            builder.append(template.substring(templateStart, placeholderStart));
+            builder.append(template, templateStart, placeholderStart);
             builder.append(args[i++]);
             templateStart = placeholderStart + 2;
         }
diff --git a/paimon-common/src/main/java/org/apache/paimon/utils/StringUtils.java b/paimon-common/src/main/java/org/apache/paimon/utils/StringUtils.java
index 971b3a008..5cf7f2085 100644
--- a/paimon-common/src/main/java/org/apache/paimon/utils/StringUtils.java
+++ b/paimon-common/src/main/java/org/apache/paimon/utils/StringUtils.java
@@ -291,7 +291,7 @@ public class StringUtils {
         increase *= max < 0 ? 16 : max > 64 ? 64 : max;
         final StringBuilder buf = new StringBuilder(text.length() + increase);
         while (end != INDEX_NOT_FOUND) {
-            buf.append(text.substring(start, end)).append(replacement);
+            buf.append(text, start, end).append(replacement);
             start = end + replLength;
             if (--max == 0) {
                 break;