prashantpogde commented on code in PR #7200:
URL: https://github.com/apache/ozone/pull/7200#discussion_r1761787608
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -662,6 +663,61 @@ public PendingKeysDeletion getPendingDeletionKeys(final
int count)
.getPendingDeletionKeys(count, ozoneManager.getOmSnapshotManager());
}
+ @Override
+ public List<Table.KeyValue<String, String>> getRenamesKeyEntries(
+ String volume, String bucket, String startKey, int count) throws
IOException {
+ // Bucket prefix would be empty if volume is empty i.e. either null or "".
+ Optional<String> bucketPrefix = Optional.ofNullable(volume).map(vol ->
vol.isEmpty() ? null : vol)
+ .map(vol -> metadataManager.getBucketKeyPrefix(vol, bucket));
+ List<Table.KeyValue<String, String>> renamedEntries = new ArrayList<>();
+ try (TableIterator<String, ? extends Table.KeyValue<String, String>>
+ renamedKeyIter =
metadataManager.getSnapshotRenamedTable().iterator(bucketPrefix.orElse(""))) {
+
+ /* Seeking to the start key if it not null. The next key picked up would
be ensured to start with the bucket
+ prefix, {@link
org.apache.hadoop.hdds.utils.db.Table#iterator(bucketPrefix)} would ensure this.
+ */
+ if (startKey != null) {
+ renamedKeyIter.seek(startKey);
+ }
+ int currentCount = 0;
+ while (renamedKeyIter.hasNext() && currentCount < count) {
+ Table.KeyValue<String, String> kv = renamedKeyIter.next();
+ if (kv != null) {
+ renamedEntries.add(Table.newKeyValue(kv.getKey(), kv.getValue()));
+ currentCount++;
+ }
+ }
+ }
+ return renamedEntries;
+ }
+
+ @Override
+ public List<Table.KeyValue<String, List<OmKeyInfo>>> getDeletedKeyEntries(
+ String volume, String bucket, String startKey, int count) throws
IOException {
+ // Bucket prefix would be empty if volume is empty i.e. either null or "".
+ Optional<String> bucketPrefix = Optional.ofNullable(volume).map(vol ->
vol.isEmpty() ? null : vol)
+ .map(vol -> metadataManager.getBucketKeyPrefix(vol, bucket));
+ List<Table.KeyValue<String, List<OmKeyInfo>>> deletedKeyEntries = new
ArrayList<>(count);
+ try (TableIterator<String, ? extends Table.KeyValue<String,
RepeatedOmKeyInfo>>
+ delKeyIter =
metadataManager.getDeletedTable().iterator(bucketPrefix.orElse(""))) {
+
+ /* Seeking to the start key if it not null. The next key picked up would
be ensured to start with the bucket
+ prefix, {@link
org.apache.hadoop.hdds.utils.db.Table#iterator(bucketPrefix)} would ensure this.
+ */
+ if (startKey != null) {
+ delKeyIter.seek(startKey);
+ }
+ int currentCount = 0;
+ while (delKeyIter.hasNext() && currentCount < count) {
Review Comment:
where are you updating current_count ?
--
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]