Skip to content

HDDS-15387. Selectively deserialize KeyInfo/DirectoryInfo fields for snapshot diff#10603

Draft
SaketaChalamchala wants to merge 3 commits into
apache:masterfrom
SaketaChalamchala:HDDS-15387
Draft

HDDS-15387. Selectively deserialize KeyInfo/DirectoryInfo fields for snapshot diff#10603
SaketaChalamchala wants to merge 3 commits into
apache:masterfrom
SaketaChalamchala:HDDS-15387

Conversation

@SaketaChalamchala

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Developed with the help of Cursor AI.

This PR is intended as the foundation for a more efficient snapshot diff (HDDS-9154).
This PR adds a SnapshotDiffValueParser with methods to deserialize required fields only from KeyInfo and DirectoryInfo for snapshot diff report generation.
The list of fields that are deserialized:

From KeyInfo

  • Required for all fileTable/keyTable entries under consideration : keyName, objectID, parentID
    • updateID is deserialized optionally only for full snapshot diffs.
  • For diff candidates that pass updateID/sequenceNumber gating fields required to build a compare signature(used to compare entries from the snapshots participating in the diff):
    • Fields indicating content change: dataSize, fileChecksum, latest block location
    • Fields indicating meaningful metadata change: metadata, acls, tags

From DirectoryInfo

  • Required for all fileTable/keyTable entries under consideration : name, objectID, parentID
    • updateID is deserialized optionally only for full snapshot diffs.
  • For diff candidates that pass updateID/sequenceNumber gating fields required to build a compare signature:
    • Fields indicating meaningful metadata change: metadata, acls,

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15387

How was this patch tested?

Unit Test

…lds for diff generation from Key/DirectoryInfo.
@SaketaChalamchala SaketaChalamchala added the snapshot https://issues.apache.org/jira/browse/HDDS-6517 label Jun 24, 2026
@adoroszlai adoroszlai changed the title HDDS-15387. SnapshotDiffValueParser to parse required Key/DirectoryInfo fields for snapshot diff generation. HDDS-15387. Selectively deserialize KeyInfo/DirectoryInfo fields for snapshot diff Jun 25, 2026
@jojochuang jojochuang requested a review from Copilot June 25, 2026 15:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces SnapshotDiffValueParser, a low-level Protobuf parser intended to support more efficient snapshot diff report generation by selectively deserializing only needed KeyInfo / DirectoryInfo fields and computing lightweight “compare signatures”.

Changes:

  • Added SnapshotDiffValueParser to parse required ID/name fields and compute compare signatures directly from persisted Protobuf bytes.
  • Added unit tests covering required-field parsing, updateID inclusion toggling, and signature sensitivity to metadata vs. volatile timestamps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffValueParser.java New selective Protobuf parsing + signature computation for KeyInfo/DirectoryInfo.
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotDiffValueParser.java New unit tests validating parsing behavior and some signature properties.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


package org.apache.hadoop.ozone.om.snapshot;

import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest.HSYNC_FIELD_NUMBER;
Comment on lines +101 to +105
case KeyInfo.METADATA_FIELD_NUMBER:
MetadataEntry metadataEntry = parseMetadataEntry(input.readBytes().toByteArray());
if (metadataEntry != null) {
updateDigestWithRawBytes(digest, fieldNumber, metadataEntry.getDigest());
if (metadataEntry.hasHsync()) {
Comment on lines +177 to +181
case DirectoryInfo.METADATA_FIELD_NUMBER:
MetadataEntry metadataEntry = parseMetadataEntry(input.readBytes().toByteArray());
if (metadataEntry != null) {
updateDigestWithRawBytes(digest, fieldNumber, metadataEntry.getDigest());
}
Comment on lines +52 to +57
@Test
void testKeyInfoParserSignatureAndUpdateId() throws Exception {
OmKeyInfo keyInfo = createKeyInfo(100L, 200L, 1024L, createChecksum((byte) 1),
createMetadata("meta", "one"), createTags("tag", "one"), createAcls(),
Collections.singletonList(createKeyLocationGroup(1L)));
byte[] rawData = OmKeyInfo.getCodec().toPersistedFormat(keyInfo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot https://issues.apache.org/jira/browse/HDDS-6517

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants