hemantk-12 commented on code in PR #5177:
URL: https://github.com/apache/ozone/pull/5177#discussion_r1297632003
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -1397,31 +1393,39 @@ long generateDiffReport(
DiffReportEntry entry =
SnapshotDiffReportOzone.getDiffReportEntry(DELETE, key);
deleteDiffs.add(codecRegistry.asRawData(entry));
- } else if (Arrays.equals(oldKeyName, newKeyName)) { // Key modified.
+ } else if (isDirectoryObject &&
+ Arrays.equals(oldKeyName, newKeyName)) {
String key = resolveBucketRelativePath(isFSOBucket,
newParentIdPathMap, newKeyName);
DiffReportEntry entry =
SnapshotDiffReportOzone.getDiffReportEntry(MODIFY, key);
modifyDiffs.add(codecRegistry.asRawData(entry));
- } else { // Key Renamed.
+ } else {
+ // Key Renamed.
+ String keyPrefix = getTablePrefix(tablePrefix,
+ (isDirectoryObject ? fsDirTable : fsTable).getName());
String oldKey = resolveBucketRelativePath(isFSOBucket,
oldParentIdPathMap, oldKeyName);
- String newKey = resolveBucketRelativePath(isFSOBucket,
- newParentIdPathMap, newKeyName);
- renameDiffs.add(codecRegistry.asRawData(
- SnapshotDiffReportOzone.getDiffReportEntry(RENAME, oldKey,
- newKey)));
-
// Check if block location is same or not. If it is not same,
// key must have been overridden as well.
- if (isObjectModified(snapshotDiffObject.getOldKeyName(),
- snapshotDiffObject.getNewKeyName(),
- snapshotDiffObject.isDirectory() ? fsDirTable : fsTable,
- snapshotDiffObject.isDirectory() ? tsDirTable : tsTable)) {
+ boolean isObjectModified = false;
Review Comment:
I see it can't be simple if-else. But I'll still suggest to extract out`
isObjectModified()` to a boolean variable.
```suggestion
boolean isObjectModified = isObjectModified(
keyPrefix + codecRegistry.asObject(oldKeyName, String.class),
keyPrefix + codecRegistry.asObject(newKeyName, String.class),
isDirectoryObject ? fsDirTable : fsTable,
isDirectoryObject ? tsDirTable : tsTable);
if (isObjectModified) {
// Here, oldKey name is returned as modified. Modified key
name is
// based on base snapshot (from snapshot).
modifyDiffs.add(codecRegistry.asRawData(
SnapshotDiffReportOzone.getDiffReportEntry(MODIFY,
oldKey)));
}
if (!isObjectModified || !Arrays.equals(oldKeyName, newKeyName))
{
String newKey = resolveBucketRelativePath(isFSOBucket,
newParentIdPathMap, newKeyName);
renameDiffs.add(codecRegistry.asRawData(
SnapshotDiffReportOzone.getDiffReportEntry(RENAME, oldKey,
newKey)));
}
}
```
--
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]