From f18ac8157b254324f442252349e84548cbe328de Mon Sep 17 00:00:00 2001 From: chenheng Date: Sat, 2 Jul 2016 09:04:15 +0800 Subject: [PATCH] HBASE-15844 We should respect hfile.block.index.cacheonwrite when write intermediate index Block --- .../org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java index 4f97c0a50da..e44b4c920ef 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java @@ -883,6 +883,11 @@ public class HFileBlockIndex { if (midKeyMetadata != null) blockStream.write(midKeyMetadata); blockWriter.writeHeaderAndData(out); + if (cacheConf != null) { + HFileBlock blockForCaching = blockWriter.getBlockForCaching(cacheConf); + cacheConf.getBlockCache().cacheBlock(new BlockCacheKey(nameForCaching, + rootLevelIndexPos, true, blockForCaching.getBlockType()), blockForCaching); + } } // Add root index block size @@ -978,7 +983,7 @@ public class HFileBlockIndex { byte[] curFirstKey = curChunk.getBlockKey(0); blockWriter.writeHeaderAndData(out); - if (cacheConf != null) { + if (getCacheOnWrite()) { HFileBlock blockForCaching = blockWriter.getBlockForCaching(cacheConf); cacheConf.getBlockCache().cacheBlock(new BlockCacheKey(nameForCaching, beginOffset, true, blockForCaching.getBlockType()), blockForCaching);