HBASE-15844 We should respect hfile.block.index.cacheonwrite when write intermediate index Block

This commit is contained in:
chenheng 2016-07-02 09:04:15 +08:00
parent 7121bc41e7
commit f18ac8157b
1 changed files with 6 additions and 1 deletions

View File

@ -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);