hemantk-12 commented on code in PR #4190:
URL: https://github.com/apache/ozone/pull/4190#discussion_r1102200036
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -113,54 +134,154 @@ public SnapshotDiffReport getSnapshotDiffReport(final
String volume,
final BucketLayout bucketLayout = getBucketLayout(volume, bucket,
fromSnapshot.getMetadataManager());
- /*
- * The reason for having ObjectID to KeyName mapping instead of OmKeyInfo
- * is to reduce the memory footprint.
- */
- final Map<Long, String> oldObjIdToKeyMap = new HashMap<>();
- // Long --> const. length
- // String --> var. length "/dir1/dir2/dir3/dir4/dir5/key1"
- final Map<Long, String> newObjIdToKeyMap = new HashMap<>();
-
- final Set<Long> objectIDsToCheck = new HashSet<>();
-
- // add to object ID map for key/file.
-
- final Table<String, OmKeyInfo> fsKeyTable = fromSnapshot
- .getMetadataManager().getKeyTable(bucketLayout);
- final Table<String, OmKeyInfo> tsKeyTable = toSnapshot
- .getMetadataManager().getKeyTable(bucketLayout);
- final Set<String> deltaFilesForKeyOrFileTable =
- getDeltaFiles(fromSnapshot, toSnapshot,
- Collections.singletonList(fsKeyTable.getName()),
- fsInfo, tsInfo, volume, bucket);
-
- addToObjectIdMap(fsKeyTable, tsKeyTable, deltaFilesForKeyOrFileTable,
- oldObjIdToKeyMap, newObjIdToKeyMap, objectIDsToCheck, false);
-
- if (bucketLayout.isFileSystemOptimized()) {
- // add to object ID map for directory.
- final Table<String, OmDirectoryInfo> fsDirTable =
- fromSnapshot.getMetadataManager().getDirectoryTable();
- final Table<String, OmDirectoryInfo> tsDirTable =
- toSnapshot.getMetadataManager().getDirectoryTable();
- final Set<String> deltaFilesForDirTable =
+ // TODO: This should comes from request itself.
+ String requestId = UUID.randomUUID().toString();
+
+ ColumnFamilyHandle fromSnapshotColumnFamily = null;
+ ColumnFamilyHandle toSnapshotColumnFamily = null;
+ ColumnFamilyHandle objectIDsColumnFamily = null;
+ ColumnFamilyHandle diffReportColumnFamily = null;
+
+ try {
+ // RequestId is prepended to column family name to make it unique
+ // for request.
+ fromSnapshotColumnFamily = db.get().createColumnFamily(
+ new ColumnFamilyDescriptor(
+ codecRegistry.asRawData(requestId + "-fromSnapshot"),
+ new ManagedColumnFamilyOptions()));
+ toSnapshotColumnFamily = db.get().createColumnFamily(
+ new ColumnFamilyDescriptor(
+ codecRegistry.asRawData(requestId + "-toSnapshot"),
+ new ManagedColumnFamilyOptions()));
+ objectIDsColumnFamily = db.get().createColumnFamily(
+ new ColumnFamilyDescriptor(
+ codecRegistry.asRawData(requestId + "-objectIDs"),
+ new ManagedColumnFamilyOptions()));
+ diffReportColumnFamily = db.get().createColumnFamily(
+ new ColumnFamilyDescriptor(
+ codecRegistry.asRawData(requestId + "-diffReport"),
+ new ManagedColumnFamilyOptions()));
+
+ // ObjectId to keyName map to keep key info for fromSnapshot.
+ // objectIdToKeyNameMap is used to identify what keys were touched
+ // in which snapshot and to know the difference if operation was
+ // creation, deletion, modify or rename.
+ // Stores only keyName instead of OmKeyInfo to reduce the memory
+ // footprint.
+ final PersistentMap<Long, String> objectIdToKeyNameMapForFromSnapshot =
+ new RocksDbPersistentMap<>(db,
+ fromSnapshotColumnFamily,
+ codecRegistry,
+ Long.class,
+ String.class);
+
+ // ObjectId to keyName map to keep key info for toSnapshot.
+ final PersistentMap<Long, String> objectIdToKeyNameMapForToSnapshot =
+ new RocksDbPersistentMap<>(db,
+ toSnapshotColumnFamily,
+ codecRegistry,
+ Long.class,
+ String.class);
+
+ // Set of unique objectId between fromSnapshot and toSnapshot.
+ final PersistentSet<Long> objectIDsToCheckMap =
Review Comment:
Yes, if you look at the implementation of
[RocksDbPersistentSet](https://github.com/apache/ozone/pull/4190/files#diff-3fd97e8db55b5b2c5840e959a0439a45e917f7e9c53afe5a60f6d5e6b7203b96R51).
I'm using set entry as key for RocksDB and value is empty byte array.
--
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]