Repository: kylin Updated Branches: refs/heads/2.0.x-hbase0.98 e0783d791 -> 8ee94d8b6 (forced update)
minor, use soft reference in dict cache Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/36e4b190 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/36e4b190 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/36e4b190 Branch: refs/heads/2.0.x-hbase0.98 Commit: 36e4b19035caa17496818cf8a03fb20e08ae2a68 Parents: a7186ef Author: Li Yang <liy...@apache.org> Authored: Fri May 12 15:14:16 2017 +0800 Committer: Li Yang <liy...@apache.org> Committed: Fri May 12 15:14:16 2017 +0800 ---------------------------------------------------------------------- .../org/apache/kylin/dict/DictionaryManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/36e4b190/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java ---------------------------------------------------------------------- diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java index 427bd14..986f9c3 100644 --- a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java +++ b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryManager.java @@ -90,12 +90,15 @@ public class DictionaryManager { private DictionaryManager(KylinConfig config) { this.config = config; - this.dictCache = CacheBuilder.newBuilder().removalListener(new RemovalListener<String, DictionaryInfo>() { - @Override - public void onRemoval(RemovalNotification<String, DictionaryInfo> notification) { - DictionaryManager.logger.info("Dict with resource path " + notification.getKey() + " is removed due to " + notification.getCause()); - } - }).maximumSize(config.getCachedDictMaxEntrySize())// + this.dictCache = CacheBuilder.newBuilder()// + .softValues()// + .removalListener(new RemovalListener<String, DictionaryInfo>() { + @Override + public void onRemoval(RemovalNotification<String, DictionaryInfo> notification) { + DictionaryManager.logger.info("Dict with resource path " + notification.getKey() + " is removed due to " + notification.getCause()); + } + })// + .maximumSize(config.getCachedDictMaxEntrySize())// .expireAfterWrite(1, TimeUnit.DAYS).build(new CacheLoader<String, DictionaryInfo>() { @Override public DictionaryInfo load(String key) throws Exception { @@ -117,7 +120,7 @@ public class DictionaryManager { public DictionaryInfo getDictionaryInfo(final String resourcePath) throws IOException { try { DictionaryInfo result = dictCache.get(resourcePath); - if (result == NONE_INDICATOR) { + if (result == NONE_INDICATOR || result == null) { return null; } else { return result;