Skip to content

Commit

Permalink
KYLIN-4933 Support set cache strength for dict cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshengjun authored and hit-lacus committed Apr 6, 2021
1 parent 25b8a88 commit ca08012
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2709,4 +2709,7 @@ public int getDistCPMaxMapNum(){
return Integer.valueOf(getOptional("kylin.storage.distcp-max-map-num", "50"));
}

public String getKylinDictCacheStrength(){
return getOptional("kylin.dict.cache.strength", "soft");
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,20 @@ static DictionaryManager newInstance(KylinConfig config) throws IOException {

private DictionaryManager(KylinConfig config) {
this.config = config;
this.dictCache = CacheBuilder.newBuilder()//
.softValues()//
CacheStrength strength = CacheStrength.valueOf(config.getKylinDictCacheStrength());
CacheBuilder cacheBuilder = CacheBuilder.newBuilder();
switch (strength) {
case soft:
cacheBuilder.softValues();
break;
case week:
cacheBuilder.weakValues();
break;
case strong:
default:
break;
}
this.dictCache = cacheBuilder//
.removalListener(new RemovalListener<String, DictionaryInfo>() {
@Override
public void onRemoval(RemovalNotification<String, DictionaryInfo> notification) {
Expand Down Expand Up @@ -450,4 +462,7 @@ private ResourceStore getStore() {
return ResourceStore.getStore(config);
}

private enum CacheStrength{
week, soft, strong
}
}

0 comments on commit ca08012

Please sign in to comment.