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_r335297778
########## 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: Pardon me here. So where does the initial increment happen? RamCache#putIfAbsent will do a retain anyway. ---------------------------------------------------------------- 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