You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/05/30 15:54:04 UTC

[GitHub] [hbase] openinx commented on a change in pull request #273: HBASE-22504 Optimize the MultiByteBuff#get(ByteBuffer, offset, len)

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

 ##########
 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:
   Please click the [Review changes], and select the [approve],  then I can merge this PR :-)  Thanks.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services