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

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileWriterImpl.java
 ##########
 @@ -546,8 +545,13 @@ private void writeInlineBlocks(boolean closing) throws 
IOException {
   private void doCacheOnWrite(long offset) {
     cacheConf.getBlockCache().ifPresent(cache -> {
       HFileBlock cacheFormatBlock = blockWriter.getBlockForCaching(cacheConf);
-      cache.cacheBlock(new BlockCacheKey(name, offset, true, 
cacheFormatBlock.getBlockType()),
-          cacheFormatBlock);
+      try {
+        cache.cacheBlock(new BlockCacheKey(name, offset, true, 
cacheFormatBlock.getBlockType()),
+            cacheFormatBlock);
+      } finally {
+        // refCnt will auto increase when block add to Cache, see 
RAMCache#putIfAbsent
+        cacheFormatBlock.release();
 
 Review comment:
   Ya got it. 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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to