openinx commented on a change in pull request #479: HBASE-22802 Avoid temp
ByteBuffer allocation in FileIOEngine#read
URL: https://github.com/apache/hbase/pull/479#discussion_r314163344
##########
File path:
hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
##########
@@ -53,6 +55,19 @@
private int markedItemIndex = -1;
private final int[] itemBeginPos;
+ private Iterator<ByteBuffer> buffsIterator = new Iterator<ByteBuffer>() {
+ @Override
+ public boolean hasNext() {
+ return curItemIndex <= limitedItemIndex &&
items[curItemIndex].hasRemaining();
Review comment:
One concern here, assume the following steps:
1. currentByteBuffer = it#next();
2. it#hasNext() must return true;
3. we write the current ByteBuffer & fullfill it, then its hasRemaining
will be false ....
4. it#hasNext() will return false because of the currBuff.hasRemaining is
false.
Say for the same ByteBuffer, the it#hasNext() will return different value.
In a general sense, if we don't have any Next(), then the it#hasNext() should
always have the same return value, I mean ?
Maybe we can remove the `&& items[curItemIndex].hasRemaining()` here, can
let the outside logic hande it ?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services