From ac718c5d8040ef287c82e2455471dbe57347e010 Mon Sep 17 00:00:00 2001 From: xingrufei Date: Fri, 6 Aug 2021 21:07:15 +0800 Subject: [PATCH] Use collection to store path.getName() string --- .../hbase/backup/mapreduce/MapReduceBackupCopyJob.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java index f8a7e1459fa..a099a3b528f 100644 --- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java +++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceBackupCopyJob.java @@ -23,6 +23,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigDecimal; import java.util.Arrays; +import java.util.Deque; +import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -331,11 +333,13 @@ public class MapReduceBackupCopyJob implements BackupCopyJob { private Text getKey(Path path) { int level = conf.getInt(NUMBER_OF_LEVELS_TO_PRESERVE_KEY, 1); int count = 0; + Deque paths = new LinkedList<>(); StringBuilder relPath = new StringBuilder(); while (count++ < level) { - relPath.insert(0, Path.SEPARATOR + path.getName()); + paths.addFirst(Path.SEPARATOR + path.getName()); path = path.getParent(); } + paths.forEach(relPath::append); return new Text(relPath.toString()); }