You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2019/11/10 08:43:20 UTC
[kylin] 02/02: Guava 11 compatibility
This is an automated email from the ASF dual-hosted git repository.
nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit efbdfeb065f2d4c7ca686b5b7cb4fd2507563b6f
Author: Xiaoyuan Gu <xi...@xyxys-MacBook-Pro.local>
AuthorDate: Mon Oct 21 17:29:03 2019 +0800
Guava 11 compatibility
---
.../org/apache/kylin/dict/AppendTrieDictionary.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java b/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java
index 8e89fd8..36c8c84 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/AppendTrieDictionary.java
@@ -92,8 +92,15 @@ public class AppendTrieDictionary<T> extends CacheDictionary<T> {
this.bytesConvert = metadata.bytesConverter;
// see: https://github.com/google/guava/wiki/CachesExplained
- CacheBuilder cacheBuilder = CacheBuilder.newBuilder().softValues().recordStats();
+ this.evictionThreshold = KylinConfig.getInstanceFromEnv().getDictionarySliceEvicationThreshold();
int cacheMaximumSize = KylinConfig.getInstanceFromEnv().getCachedDictMaxSize();
+ CacheBuilder cacheBuilder = CacheBuilder.newBuilder().softValues();
+
+ // To be compatible with Guava 11
+ boolean methodExists = methodExistsInClass(CacheBuilder.class, "recordStats");
+ if (methodExists) {
+ cacheBuilder = cacheBuilder.recordStats();
+ }
if (cacheMaximumSize > 0) {
cacheBuilder = cacheBuilder.maximumSize(cacheMaximumSize);
logger.info("Set dict cache maximum size to " + cacheMaximumSize);
@@ -115,7 +122,6 @@ public class AppendTrieDictionary<T> extends CacheDictionary<T> {
return slice;
}
});
- this.evictionThreshold = KylinConfig.getInstanceFromEnv().getDictionarySliceEvicationThreshold();
}
@Override
@@ -262,6 +268,17 @@ public class AppendTrieDictionary<T> extends CacheDictionary<T> {
}
}
+ private boolean methodExistsInClass(Class clazz, String method) {
+ boolean existence = false;
+ try {
+ clazz.getMethod(method);
+ existence = true;
+ } catch (NoSuchMethodException e) {
+ logger.info("Class " + clazz.getName() + " doesn't have method " + method);
+ }
+ return existence;
+ }
+
/**
* only for test
*