XbaoWu commented on code in PR #6736:
URL: https://github.com/apache/hadoop/pull/6736#discussion_r1567230524


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SerialNumberManager.java:
##########
@@ -115,6 +119,36 @@ public static StringTable getStringTable() {
     return map;
   }
 
+  // returns serial snapshot of current values for a save.
+  public static StringTable getSerialStringTable() {
+    // approximate size for capacity.
+    int size = 0;
+    for (final SerialNumberManager snm : values) {
+      size += snm.size();
+    }
+
+    int tableMaskBits = getMaskBits();
+    StringTable map = new StringTable(size, 0);
+    Set<String> entrySet = new HashSet<String>();
+    AtomicInteger index = new AtomicInteger();
+
+    Map <Integer, String> entryMap = new TreeMap<Integer, String>();
+    for (final SerialNumberManager snm : values) {
+      final int mask = snm.getMask(tableMaskBits);
+      for (Entry<Integer, String> entry : snm.entrySet()) {
+        entryMap.put(entry.getKey() | mask, entry.getValue());
+      }
+    }
+
+    entryMap.forEach((key, value) -> {
+      if(entrySet.add(value)){
+        map.put(index.incrementAndGet(), value);

Review Comment:
   incrementAndGet method is executed when the fsimage file is persisted to 
ensure that the index is continuous.



-- 
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: common-issues-unsubscr...@hadoop.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to