You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2023/12/16 14:01:54 UTC
(hbase) branch master updated: HBASE-20528 Revise collections copying from iteration to built-in function
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new b7c3f8c6e33 HBASE-20528 Revise collections copying from iteration to built-in function
b7c3f8c6e33 is described below
commit b7c3f8c6e33c34a1af8b88985b143ba71c4f3bad
Author: Jacky Ho <ja...@gmail.com>
AuthorDate: Sat Dec 16 21:48:36 2023 +0800
HBASE-20528 Revise collections copying from iteration to built-in function
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../src/main/java/org/apache/hadoop/hbase/client/Result.java | 4 +---
.../main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java | 5 ++---
.../java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java | 5 ++---
.../src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java | 5 ++---
4 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
index 86cdaaeef3c..6d1050196d8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
@@ -791,9 +791,7 @@ public class Result implements CellScannable, CellScanner {
}
prevRow = currentRow;
stale = stale || r.isStale();
- for (Cell c : r.rawCells()) {
- cells.add(c);
- }
+ Collections.addAll(cells, r.rawCells());
}
return Result.create(cells, null, stale);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
index 422a607dc85..c19bdec560b 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/AbstractHBaseTool.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.util;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -119,9 +120,7 @@ public abstract class AbstractHBaseTool implements Tool {
CommandLine cmd;
List<String> argsList = new ArrayList<>(args.length);
- for (String arg : args) {
- argsList.add(arg);
- }
+ Collections.addAll(argsList, args);
// For backward compatibility of args which can't be parsed as Option. See javadoc for
// processOldArgs(..)
processOldArgs(argsList);
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java
index 4ff4a5b95b9..3ccbaab4de1 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileInputFormat.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
@@ -148,9 +149,7 @@ public class HFileInputFormat extends FileInputFormat<NullWritable, Cell> {
for (FileStatus status : super.listStatus(job)) {
if (status.isDirectory()) {
FileSystem fs = status.getPath().getFileSystem(job.getConfiguration());
- for (FileStatus match : fs.listStatus(status.getPath(), HIDDEN_FILE_FILTER)) {
- result.add(match);
- }
+ Collections.addAll(result, fs.listStatus(status.getPath(), HIDDEN_FILE_FILTER));
} else {
result.add(status);
}
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
index 21070de60e2..37e99c096e5 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -130,9 +131,7 @@ public class WALPlayer extends Configured implements Tool {
Configuration conf = context.getConfiguration();
String[] tables = conf.getStrings(TABLES_KEY);
this.multiTableSupport = conf.getBoolean(MULTI_TABLES_SUPPORT, false);
- for (String table : tables) {
- tableSet.add(table);
- }
+ Collections.addAll(tableSet, tables);
}
}