/** * @return true if blocks should be evicted from the cache when an HFile * reader is closed, false if not */ public boolean shouldEvictOnClose() { return isBlockCacheEnabled() && this.evictOnClose; }
/** * @return true if blocks in this file should be flagged as in-memory */ public boolean isInMemory() { return isBlockCacheEnabled() && this.inMemory; }
/** * @return true if blocks should be compressed in the cache, false if not */ public boolean shouldCacheCompressed() { return isBlockCacheEnabled() && this.cacheCompressed; }
/** * @return true if blocks should be evicted from the cache when an HFile * reader is closed, false if not */ public boolean shouldEvictOnClose() { return isBlockCacheEnabled() && this.evictOnClose; }
/** * @return true if this {@link BlockCategory} should be compressed in blockcache, false otherwise */ public boolean shouldCacheCompressed(BlockCategory category) { if (!isBlockCacheEnabled()) return false; switch (category) { case DATA: return this.cacheDataCompressed; default: return false; } }
/** * Should we cache a block of a particular category? We always cache * important blocks such as index blocks, as long as the block cache is * available. */ public boolean shouldCacheBlockOnRead(BlockCategory category) { boolean shouldCache = isBlockCacheEnabled() && (cacheDataOnRead || category == BlockCategory.INDEX || category == BlockCategory.BLOOM); return shouldCache; }
/** * @return true if bloom blocks should be written to the cache when an HFile * is written, false if not */ public boolean shouldCacheBloomsOnWrite() { return isBlockCacheEnabled() && this.cacheBloomsOnWrite; }
/** * Returns whether the blocks of this HFile should be cached on read or not. * @return true if blocks should be cached on read, false if not */ public boolean shouldCacheDataOnRead() { return isBlockCacheEnabled() && cacheDataOnRead; }
/** * @return true if data blocks should be written to the cache when an HFile is * written, false if not */ public boolean shouldCacheDataOnWrite() { return isBlockCacheEnabled() && this.cacheDataOnWrite; }
/** * @return true if index blocks should be written to the cache when an HFile * is written, false if not */ public boolean shouldCacheIndexesOnWrite() { return isBlockCacheEnabled() && this.cacheIndexesOnWrite; }
/** * @return true if index blocks should be written to the cache when an HFile * is written, false if not */ public boolean shouldCacheIndexesOnWrite() { return isBlockCacheEnabled() && this.cacheIndexesOnWrite; }
/** * @return true if bloom blocks should be written to the cache when an HFile * is written, false if not */ public boolean shouldCacheBloomsOnWrite() { return isBlockCacheEnabled() && this.cacheBloomsOnWrite; }
/** * @return true if data blocks should be compressed in the cache, false if not */ public boolean shouldCacheDataCompressed() { return isBlockCacheEnabled() && this.cacheDataCompressed; }
/** * @return true if blocks should be prefetched into the cache on open, false if not */ public boolean shouldPrefetchOnOpen() { return isBlockCacheEnabled() && this.prefetchOnOpen; }
/** * @return true if data blocks should be written to the cache when an HFile is * written, false if not */ public boolean shouldCacheDataOnWrite() { return isBlockCacheEnabled() && this.cacheDataOnWrite; }
/** * Returns whether the DATA blocks of this HFile should be cached on read or not (we always * cache the meta blocks, the INDEX and BLOOM blocks). * @return true if blocks should be cached on read, false if not */ public boolean shouldCacheDataOnRead() { return isBlockCacheEnabled() && cacheDataOnRead; }
/** * @return True if cache data blocks in L1 tier (if more than one tier in block cache deploy). */ public boolean isCacheDataInL1() { return isBlockCacheEnabled() && this.cacheDataInL1; }
/** * @return true if blocks in this file should be flagged as in-memory */ public boolean isInMemory() { return isBlockCacheEnabled() && this.inMemory; }
@Test public void testNoCompression() throws IOException { CacheConfig cacheConf = Mockito.mock(CacheConfig.class); Mockito.when(cacheConf.isBlockCacheEnabled()).thenReturn(false); HFileBlock block = createTestV2Block(NONE, includesMemstoreTS, false).getBlockForCaching(cacheConf); assertEquals(4000, block.getUncompressedSizeWithoutHeader()); assertEquals(4004, block.getOnDiskSizeWithoutHeader()); assertTrue(block.isUnpacked()); }
@Test public void testCacheConfigDefaultLRUBlockCache() { CacheConfig.instantiateBlockCache(this.conf); CacheConfig cc = new CacheConfig(this.conf); assertTrue(cc.isBlockCacheEnabled()); assertTrue(CacheConfig.DEFAULT_IN_MEMORY == cc.isInMemory()); basicBlockCacheOps(cc, false, true); assertTrue(cc.getBlockCache() instanceof LruBlockCache); }