ramkrish86 commented on a change in pull request #273: HBASE-22504 Optimize the 
MultiByteBuff#get(ByteBuffer, offset, len)
URL: https://github.com/apache/hbase/pull/273#discussion_r289044128
 
 

 ##########
 File path: 
hbase-common/src/main/java/org/apache/hadoop/hbase/nio/MultiByteBuff.java
 ##########
 @@ -1020,24 +1019,28 @@ public void asSubByteBuffer(int offset, int length, 
ObjectIntPair<ByteBuffer> pa
     }
     pair.setFirst(ByteBuffer.wrap(dst));
     pair.setSecond(0);
-    return;
   }
 
   /**
    * Copies the content from an this MBB to a ByteBuffer
-   * @param out the ByteBuffer to which the copy has to happen
-   * @param sourceOffset the offset in the MBB from which the elements has
-   * to be copied
+   * @param out the ByteBuffer to which the copy has to happen, its position 
will be advanced.
+   * @param sourceOffset the offset in the MBB from which the elements has to 
be copied
    * @param length the length in the MBB upto which the elements has to be 
copied
    */
   @Override
-  public void get(ByteBuffer out, int sourceOffset,
-      int length) {
+  public void get(ByteBuffer out, int sourceOffset, int length) {
     checkRefCount();
-      // Not used from real read path actually. So not going with
-      // optimization
-    for (int i = 0; i < length; ++i) {
-      out.put(this.get(sourceOffset + i));
+    int itemIndex = getItemIndex(sourceOffset);
+    ByteBuffer in = this.items[itemIndex];
+    sourceOffset = sourceOffset - this.itemBeginPos[itemIndex];
+    while (length > 0) {
 
 Review comment:
   LGTM.

----------------------------------------------------------------
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

Reply via email to