Copilot commented on code in PR #12036:
URL: https://github.com/apache/ozone/pull/12036#discussion_r4567642714
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/diff/MergeJoinSnapDiffWriter.java:
##########
@@ -429,6 +429,9 @@ private static List<DiffReportEntry>
resolveReportEntries(DiffType diffType,
String targetPath = buildChildPath(targetParentPaths.get(i),
targetNames.get(i));
if (sourcePath != null && targetPath != null) {
reportEntries.add(getDiffReportEntry(RENAME, sourcePath,
targetPath));
+ } else if (sourcePath != null) {
+ // Moved under a directory deleted before its children were purged:
gone from the to-snapshot.
+ reportEntries.add(getDiffReportEntry(DELETE, sourcePath));
} else {
reportEntries.add(null);
}
Review Comment:
`resolveReportEntries` is operating in a rename-resolution context (it emits
`RENAME` entries), but it can now also emit `DELETE` entries. To avoid future
confusion/incorrect assumptions by maintainers, please document this explicitly
(eg, method-level comment/Javadoc or a clarifying inline comment explaining
that unresolved rename targets are intentionally downgraded to `DELETE`). Also
consider making the inline comment less scenario-specific (eg, 'target path
could not be resolved in to-snapshot') since the code condition is based on
resolution failure, not strictly on purge timing.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/diff/TestMergeJoinSnapDiffWriter.java:
##########
@@ -270,6 +272,42 @@ void testFsoPathResolutionAndOrdering(boolean ordering)
throws Exception {
}
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testRenameIntoDeletedDirectoryReportsDeleteOfSource(boolean ordering)
throws Exception {
+ byte[] sig = signature("s");
+ try (SnapDiffJobStore store = newStore(true)) {
+ // From: file "a" and directories "b" and "c" under the bucket, file "a"
under "c",
+ // and file 302 whose parent 400 has no edge.
+ // To: those files are moved under "b". "b" and "c" are deleted before
their children
+ // are purged, so neither has a to edge. File 302's source path cannot
be resolved.
+ store.putFromEdge(BUCKET_OBJECT_ID, 300L, nameBytes("b"));
+ store.putOldList(300L, entry(BUCKET_OBJECT_ID, "b", true, sig));
+ store.putOldList(301L, entry(BUCKET_OBJECT_ID, "a", false, sig));
+ store.putNewList(301L, entry(300L, "a", false, sig));
+ store.putOldList(302L, entry(400L, "c", false, sig));
+ store.putNewList(302L, entry(300L, "c", false, sig));
+ store.putFromEdge(BUCKET_OBJECT_ID, 310L, nameBytes("c"));
+ store.putOldList(310L, entry(BUCKET_OBJECT_ID, "c", true, sig));
+ store.putOldList(311L, entry(310L, "a", false, sig));
+ store.putNewList(311L, entry(300L, "a", false, sig));
+ store.flushWrites();
+
+ List<DiffReportEntry> entries = runWriteReportWithManager(store,
BUCKET_OBJECT_ID, true,
+ mockManagerWithRealDeleteRetention(), ordering);
+ assertThat(entries).containsExactlyInAnyOrder(
+ SnapshotDiffReportOzone.getDiffReportEntry(DELETE, "b"),
+ SnapshotDiffReportOzone.getDiffReportEntry(DELETE, "a"),
+ SnapshotDiffReportOzone.getDiffReportEntry(DELETE, "c"),
+ SnapshotDiffReportOzone.getDiffReportEntry(DELETE, "c/a"));
+ if (ordering) {
+ assertThat(entries).containsSubsequence(
+ SnapshotDiffReportOzone.getDiffReportEntry(DELETE, "c/a"),
+ SnapshotDiffReportOzone.getDiffReportEntry(DELETE, "c"));
+ }
Review Comment:
The test repeats `SnapshotDiffReportOzone.getDiffReportEntry(DELETE, ...)`
several times. To reduce duplication and make the intent clearer, consider
adding a small helper in the test (eg, `deleteEntry(String path)`) or
statically importing `SnapshotDiffReportOzone.getDiffReportEntry` and using a
consistent local factory for expected entries.
--
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]