anoopsjohn commented on a change in pull request #268: HBASE-22491 Separate the 
heap HFileBlock and offheap HFileBlock because the heap block won't need refCnt 
and save into prevBlocks list before shipping
URL: https://github.com/apache/hbase/pull/268#discussion_r293201438
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java
 ##########
 @@ -2084,7 +2078,26 @@ static String toStringHeader(ByteBuff buf) throws 
IOException {
                    " onDiskDataSizeWithHeader " + onDiskDataSizeWithHeader;
   }
 
-  public HFileBlock deepCloneOnHeap() {
-    return new HFileBlock(this, true);
+  private static HFileBlockBuilder createBuilder(HFileBlock blk){
+    return new HFileBlockBuilder()
+          .withBlockType(blk.blockType)
+          .withOnDiskSizeWithoutHeader(blk.onDiskSizeWithoutHeader)
+          .withUncompressedSizeWithoutHeader(blk.uncompressedSizeWithoutHeader)
+          .withPrevBlockOffset(blk.prevBlockOffset)
+          .withByteBuff(blk.buf.duplicate()) // Duplicate the buffer.
+          .withOffset(blk.offset)
+          .withOnDiskDataSizeWithHeader(blk.onDiskDataSizeWithHeader)
+          .withNextBlockOnDiskSize(blk.nextBlockOnDiskSize)
+          .withHFileContext(blk.fileContext)
+          .withByteBuffAllocator(blk.allocator);
+  }
+
+  static HFileBlock shallowClone(HFileBlock blk) {
+    return createBuilder(blk).withShared(!blk.buf.hasArray()).build();
 
 Review comment:
   blk.buf.hasArray() -> Instead use blk.isShared()

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