Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ public class CacheConfig implements PropagatingConfigurationObserver {
/** Whether blocks of a file should be evicted when the file is closed */
private volatile boolean evictOnClose;

/**
* Whether blocks of a parent region should be evicted from cache when the region splits or
* merges.
*/
private volatile boolean evictOnSplit;

/** Whether data blocks should be stored in compressed and/or encrypted form in the cache */
private boolean cacheDataCompressed;

Expand Down Expand Up @@ -202,17 +208,18 @@ public CacheConfig(Configuration conf, ColumnFamilyDescriptor family, BlockCache
// if they are enabled in the global configuration.
this.cacheDataOnWrite =
conf.getBoolean(CACHE_BLOCKS_ON_WRITE_KEY, DEFAULT_CACHE_DATA_ON_WRITE)
|| (family == null ? false : family.isCacheDataOnWrite());
|| (family != null && family.isCacheDataOnWrite());
this.cacheIndexesOnWrite =
conf.getBoolean(CACHE_INDEX_BLOCKS_ON_WRITE_KEY, DEFAULT_CACHE_INDEXES_ON_WRITE)
|| (family == null ? false : family.isCacheIndexesOnWrite());
|| (family != null && family.isCacheIndexesOnWrite());
this.cacheBloomsOnWrite =
conf.getBoolean(CACHE_BLOOM_BLOCKS_ON_WRITE_KEY, DEFAULT_CACHE_BLOOMS_ON_WRITE)
|| (family == null ? false : family.isCacheBloomsOnWrite());
|| (family != null && family.isCacheBloomsOnWrite());
this.evictOnClose = conf.getBoolean(EVICT_BLOCKS_ON_CLOSE_KEY, DEFAULT_EVICT_ON_CLOSE)
|| (family == null ? false : family.isEvictBlocksOnClose());
|| (family != null && family.isEvictBlocksOnClose());
this.evictOnSplit = conf.getBoolean(EVICT_BLOCKS_ON_SPLIT_KEY, DEFAULT_EVICT_ON_SPLIT);
this.prefetchOnOpen = conf.getBoolean(PREFETCH_BLOCKS_ON_OPEN_KEY, DEFAULT_PREFETCH_ON_OPEN)
|| (family == null ? false : family.isPrefetchBlocksOnOpen());
|| (family != null && family.isPrefetchBlocksOnOpen());
this.cacheCompactedDataOnWrite = conf.getBoolean(CACHE_COMPACTED_BLOCKS_ON_WRITE_KEY,
DEFAULT_CACHE_COMPACTED_BLOCKS_ON_WRITE);
this.cacheCompactedDataOnWriteThreshold = getCacheCompactedBlocksOnWriteThreshold(conf);
Expand All @@ -233,6 +240,7 @@ public CacheConfig(CacheConfig cacheConf) {
this.cacheIndexesOnWrite = cacheConf.cacheIndexesOnWrite;
this.cacheBloomsOnWrite = cacheConf.cacheBloomsOnWrite;
this.evictOnClose = cacheConf.evictOnClose;
this.evictOnSplit = cacheConf.evictOnSplit;
this.cacheDataCompressed = cacheConf.cacheDataCompressed;
this.prefetchOnOpen = cacheConf.prefetchOnOpen;
this.cacheCompactedDataOnWrite = cacheConf.cacheCompactedDataOnWrite;
Expand All @@ -250,6 +258,7 @@ private CacheConfig() {
this.cacheIndexesOnWrite = false;
this.cacheBloomsOnWrite = false;
this.evictOnClose = false;
this.evictOnSplit = false;
this.cacheDataCompressed = false;
this.prefetchOnOpen = false;
this.cacheCompactedDataOnWrite = false;
Expand Down Expand Up @@ -349,14 +358,17 @@ public boolean shouldEvictOnClose() {
}

/**
* Only used for testing.
* @param evictOnClose whether blocks should be evicted from the cache when an HFile reader is
* closed
*/
public void setEvictOnClose(boolean evictOnClose) {
this.evictOnClose = evictOnClose;
}

public boolean shouldEvictOnSplit() {
return this.evictOnSplit;
}

/** Returns true if data blocks should be compressed in the cache, false if not */
public boolean shouldCacheDataCompressed() {
return this.cacheDataOnRead && this.cacheDataCompressed;
Expand Down Expand Up @@ -481,8 +493,9 @@ public String toString() {
return "cacheDataOnRead=" + shouldCacheDataOnRead() + ", cacheDataOnWrite="
+ shouldCacheDataOnWrite() + ", cacheIndexesOnWrite=" + shouldCacheIndexesOnWrite()
+ ", cacheBloomsOnWrite=" + shouldCacheBloomsOnWrite() + ", cacheEvictOnClose="
+ shouldEvictOnClose() + ", cacheDataCompressed=" + shouldCacheDataCompressed()
+ ", prefetchOnOpen=" + shouldPrefetchOnOpen();
+ shouldEvictOnClose() + ", cacheEvictOnSplit=" + shouldEvictOnSplit()
+ ", cacheDataCompressed=" + shouldCacheDataCompressed() + ", prefetchOnOpen="
+ shouldPrefetchOnOpen();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (cacheConfig == null) { %>
<tr>
<td>Cache DATA on Write</td>
<td><%= cacheConfig.shouldCacheDataOnWrite() %></td>
<td>True if DATA blocks are cached on write.</td>
<td>True if DATA blocks are cached on write</td>
</tr>
<tr>
<td>Cache INDEX on Write</td>
Expand All @@ -58,6 +58,12 @@ if (cacheConfig == null) { %>
<td>True if blocks are evicted from cache when an HFile
reader is closed</td>
</tr>
<tr>
<td>Evict blocks on Split</td>
<td><%= cacheConfig.shouldEvictOnSplit() %></td>
<td>True if blocks of the parent region are evicted
from the cache when splits or merges</td>
</tr>
<tr>
<td>Cache DATA in compressed format</td>
<td><%= cacheConfig.shouldCacheDataCompressed() %></td>
Expand Down