swamirishi commented on code in PR #7200:
URL: https://github.com/apache/ozone/pull/7200#discussion_r1765860141
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -662,6 +664,53 @@ public PendingKeysDeletion getPendingDeletionKeys(final
int count)
.getPendingDeletionKeys(count, ozoneManager.getOmSnapshotManager());
}
+ private <V, R> List<Table.KeyValue<String, R>> getTableEntries(String
startKey,
+ TableIterator<String, ? extends Table.KeyValue<String, V>>
tableIterator,
+ Function<V, R> valueFunction, int count) throws IOException {
+ List<Table.KeyValue<String, R>> entries = new ArrayList<>();
+ /* 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) {
+ tableIterator.seek(startKey);
+ }
+ int currentCount = 0;
+ while (tableIterator.hasNext() && currentCount < count) {
+ Table.KeyValue<String, V> kv = tableIterator.next();
+ if (kv != null) {
+ entries.add(Table.newKeyValue(kv.getKey(),
valueFunction.apply(kv.getValue())));
+ currentCount++;
+ }
+ }
+ return entries;
+ }
+
+
+ @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));
+ try (TableIterator<String, ? extends Table.KeyValue<String, String>>
+ renamedKeyIter =
metadataManager.getSnapshotRenamedTable().iterator(bucketPrefix.orElse(""))) {
+ return getTableEntries(startKey, renamedKeyIter, Function.identity(),
count);
+ }
+ }
+
+ @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);
Review Comment:
done
--
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]