swamirishi commented on code in PR #7200:
URL: https://github.com/apache/ozone/pull/7200#discussion_r1762010556
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/snapshot/OMSnapshotMoveDeletedKeysResponse.java:
##########
@@ -224,35 +224,35 @@ public static RepeatedOmKeyInfo createRepeatedOmKeyInfo(
return result;
}
- private RepeatedOmKeyInfo createRepeatedOmKeyInfo(
- SnapshotMoveKeyInfos snapshotMoveKeyInfos,
- OMMetadataManager metadataManager) throws IOException {
+ public static RepeatedOmKeyInfo
createMergedRepeatedOmKeyInfoFromDeletedTableEntry(
+ SnapshotMoveKeyInfos snapshotMoveKeyInfos, OMMetadataManager
metadataManager) throws IOException {
String dbKey = snapshotMoveKeyInfos.getKey();
- List<KeyInfo> keyInfoList = snapshotMoveKeyInfos.getKeyInfosList();
+ List<OmKeyInfo> keyInfoList = new ArrayList<>();
+ for (KeyInfo info : snapshotMoveKeyInfos.getKeyInfosList()) {
+ OmKeyInfo fromProtobuf = OmKeyInfo.getFromProtobuf(info);
+ keyInfoList.add(fromProtobuf);
+ }
// When older version of keys are moved to the next snapshot's deletedTable
// The newer version might also be in the next snapshot's deletedTable and
// it might overwrite. This is to avoid that and also avoid having
- // orphans blocks.
+ // orphans blocks. Checking the last keyInfoList size omKeyInfo versions,
+ // this is to avoid redundant additions if the last n versions match.
RepeatedOmKeyInfo result = metadataManager.getDeletedTable().get(dbKey);
-
- for (KeyInfo keyInfo : keyInfoList) {
- OmKeyInfo omKeyInfo = OmKeyInfo.getFromProtobuf(keyInfo);
- if (result == null) {
- result = new RepeatedOmKeyInfo(omKeyInfo);
- } else if (!isSameAsLatestOmKeyInfo(omKeyInfo, result)) {
- result.addOmKeyInfo(omKeyInfo);
- }
+ if (result == null) {
+ result = new RepeatedOmKeyInfo(keyInfoList);
+ } else if (!isSameAsLatestOmKeyInfo(keyInfoList, result)) {
+ keyInfoList.forEach(result::addOmKeyInfo);
}
-
return result;
}
- private boolean isSameAsLatestOmKeyInfo(OmKeyInfo omKeyInfo,
- RepeatedOmKeyInfo result) {
+ private static boolean isSameAsLatestOmKeyInfo(List<OmKeyInfo> omKeyInfos,
Review Comment:
This is called by the createMergedRepeatedOmKeyInfoFromDeletedTableEntry
static function used by multiple response methods. Previously it was just
checking for the latest version. The potential downside is it would end up
adding previous versions over and over again.
--
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]