swamirishi commented on code in PR #8203:
URL: https://github.com/apache/ozone/pull/8203#discussion_r2021319464
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStoreAbstractIterator.java:
##########
@@ -94,16 +98,25 @@ private void setCurrentEntry() {
@Override
public final boolean hasNext() {
- return rocksDBIterator.get().isValid() &&
- (prefix == null || startsWithPrefix(key()));
+ try {
+ if (!seekDoneAtleastOnce) {
+ throw new NoSuchElementException("Cannot check iterator hasNext before
seeking either to start of iter or " +
+ "seeking to a specific key");
+ }
+ return currentEntry != null &&
+ (prefix == null || startsWithPrefix(currentEntry.getKey()));
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
Review Comment:
key() call from iterator is what is inefficient. In the implementation of
this class it would be called from the iterator over and over again which would
involve a buffer copy. In byte array it would be direct buffer to indirect
buffer copy and in codec buffer it would be direct buffer to direct buffer copy
which is still inefficient and unnecessary.
--
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]