Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2081,21 +2081,18 @@ public DeleteKeysResult getPendingDeletionSubDirs(long volumeId, long bucketId,
Table<String, OmDirectoryInfo> dirTable = metadataManager.getDirectoryTable();
try (TableIterator<String,
? extends Table.KeyValue<String, OmDirectoryInfo>>
iterator = dirTable.iterator()) {
return gatherSubDirsWithIterator(parentInfo,
seekDirInDB, countEntries, iterator, remainingBufLimit);
iterator = dirTable.iterator(seekDirInDB)) {
return gatherSubDirsWithIterator(parentInfo, countEntries, iterator, remainingBufLimit);
}

}

private DeleteKeysResult gatherSubDirsWithIterator(OmKeyInfo parentInfo,
String seekDirInDB,
long countEntries,
TableIterator<String,
? extends Table.KeyValue<String, OmDirectoryInfo>> iterator, long remainingBufLimit)
throws IOException {
List<OmKeyInfo> directories = new ArrayList<>();
iterator.seek(seekDirInDB);
long consumedSize = 0;
boolean processedSubDirs = false;

Expand Down Expand Up @@ -2142,9 +2139,7 @@ public DeleteKeysResult getPendingDeletionSubFiles(long volumeId,

Table fileTable = metadataManager.getFileTable();
try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>>
iterator = fileTable.iterator()) {

iterator.seek(seekFileInDB);
iterator = fileTable.iterator(seekFileInDB)) {

while (iterator.hasNext() && remainingBufLimit > 0) {
Table.KeyValue<String, OmKeyInfo> entry = iterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1955,19 +1955,15 @@ public Set<String> getMultipartUploadKeys(
}
}

// prefixed iterator will only iterate until keys match the prefix
try (TableIterator<String, ? extends KeyValue<String, OmMultipartKeyInfo>>
iterator = getMultipartInfoTable().iterator()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't see this one became a problem in my stacktrace, but it should be fixed too.

There are 100+ of similar iterator usages. It would be a huge effort to try and update all of them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jojochuang, we can split and do it in multiple PRs. One PR per module should be doable.

iterator.seek(prefixKey);
iterator = getMultipartInfoTable().iterator(prefixKey)) {

while (iterator.hasNext()) {
KeyValue<String, OmMultipartKeyInfo> entry = iterator.next();
if (entry.getKey().startsWith(prefixKey)) {
// If it is marked for abort, skip it.
if (!aborted.contains(entry.getKey())) {
response.add(entry.getKey());
}
} else {
break;
// If it is marked for abort, skip it.
if (!aborted.contains(entry.getKey())) {
response.add(entry.getKey());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,7 @@ private static boolean checkSubDirectoryExists(OmKeyInfo omKeyInfo,
omKeyInfo.getObjectID(), "");
try (TableIterator<String, ? extends
Table.KeyValue<String, OmDirectoryInfo>>
iterator = dirTable.iterator()) {

iterator.seek(seekDirInDB);
iterator = dirTable.iterator(seekDirInDB)) {

if (iterator.hasNext()) {
Table.KeyValue<String, OmDirectoryInfo> entry = iterator.next();
Expand Down Expand Up @@ -952,9 +950,7 @@ private static boolean checkSubFileExists(OmKeyInfo omKeyInfo,
String seekFileInDB = metaMgr.getOzonePathKey(volumeId, bucketId,
omKeyInfo.getObjectID(), "");
try (TableIterator<String, ? extends Table.KeyValue<String, OmKeyInfo>>
iterator = fileTable.iterator()) {

iterator.seek(seekFileInDB);
iterator = fileTable.iterator(seekFileInDB)) {

if (iterator.hasNext()) {
Table.KeyValue<String, OmKeyInfo> entry = iterator.next();
Expand Down