openinx commented on a change in pull request #678: HBASE-23107 Avoid temp byte 
array creation when doing cacheDataOnWrite
URL: https://github.com/apache/hbase/pull/678#discussion_r334215487
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java
 ##########
 @@ -548,6 +547,8 @@ private void doCacheOnWrite(long offset) {
       HFileBlock cacheFormatBlock = blockWriter.getBlockForCaching(cacheConf);
       cache.cacheBlock(new BlockCacheKey(name, offset, true, 
cacheFormatBlock.getBlockType()),
           cacheFormatBlock);
+      // refCnt will auto increase when block add to Cache, see 
RAMCache#putIfAbsent
+      cacheFormatBlock.release();
 
 Review comment:
   Better to release the cacheFormatBlock in the finally block ?  Say even if 
we encounter some exception when cache#cacheBlock, the byte buffer allocated 
from ByteBuffAllocator can still have the chance to release ( return back to 
the pool ) .. 

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


With regards,
Apache Git Services

Reply via email to