jojochuang commented on code in PR #11083:
URL: https://github.com/apache/ozone/pull/11083#discussion_r3857384578


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/EntryValue.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.snapshot.diff;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * Compact intermediate value stored in the {@code newList}/{@code oldList}
+ * column families of the optimized snapshot diff. It keeps only the fields
+ * required to classify a diff entry in the later merge-join stage, avoiding 
the
+ * cost of holding a full {@code OmKeyInfo}/{@code OmDirectoryInfo}.
+ *
+ * <p>The fields are:
+ * <ul>
+ *   <li>{@code parentId} - parent object id (parent directory for FSO).</li>
+ *   <li>{@code name} - leaf name for FSO buckets, full key path for OBS.</li>
+ *   <li>{@code isDir} - whether the entry is a directory.</li>
+ *   <li>{@code signature} - SHA-256 compare signature computed by
+ *       {@code SnapshotDiffValueParser} over the meaningful fields.</li>
+ * </ul>
+ *
+ * <p>The wire layout is fixed so both the full diff and the DAG diff Stage 1
+ * readers produce identical bytes:
+ * <pre>
+ *   | parentId (8, big-endian) | isDir (1) | sigLen (4, big-endian) | 
signature | name (UTF-8, remaining) |
+ * </pre>
+ */
+public final class EntryValue {
+
+  private static final int PARENT_ID_BYTES = Long.BYTES;
+  private static final int IS_DIR_BYTES = 1;
+  private static final int SIG_LEN_BYTES = Integer.BYTES;
+  private static final int HEADER_BYTES = PARENT_ID_BYTES + IS_DIR_BYTES + 
SIG_LEN_BYTES;
+
+  private final long parentId;
+  private final String name;
+  private final boolean isDir;
+  private final byte[] signature;
+
+  public EntryValue(long parentId, String name, boolean isDir, byte[] 
signature) {
+    this.parentId = parentId;
+    this.name = name == null ? "" : name;
+    this.isDir = isDir;
+    this.signature = signature == null ? new byte[0] : signature;
+  }
+
+  public long getParentId() {
+    return parentId;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public boolean isDir() {
+    return isDir;
+  }
+
+  public byte[] getSignature() {
+    return Arrays.copyOf(signature, signature.length);
+  }

Review Comment:
   nore sure how this is going to be used, but a getter method should not be a 
O(n) operation. Either return signature object as is, or rename the method to 
copySignature().



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to