You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/11/30 22:58:28 UTC
kylin git commit: KYLIN-1875 fix ParameterDesc equals() & hashcode()
Repository: kylin
Updated Branches:
refs/heads/KYLIN-1875 b7433453d -> 4737454ed
KYLIN-1875 fix ParameterDesc equals() & hashcode()
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/4737454e
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/4737454e
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/4737454e
Branch: refs/heads/KYLIN-1875
Commit: 4737454ed7b25cfbaf3854b4768b779fb28070fb
Parents: b743345
Author: Yang Li <li...@apache.org>
Authored: Thu Dec 1 06:58:08 2016 +0800
Committer: Yang Li <li...@apache.org>
Committed: Thu Dec 1 06:58:08 2016 +0800
----------------------------------------------------------------------
.../kylin/metadata/model/FunctionDesc.java | 1 +
.../kylin/metadata/model/ParameterDesc.java | 36 +++++++++++++++-----
2 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/4737454e/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
index 5818791..14be718 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/FunctionDesc.java
@@ -248,6 +248,7 @@ public class FunctionDesc {
final int prime = 31;
int result = 1;
result = prime * result + ((expression == null) ? 0 : expression.hashCode());
+ result = prime * result + ((returnType == null) ? 0 : returnType.hashCode());
result = prime * result + ((isCount() || parameter == null) ? 0 : parameter.hashCode());
return result;
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/4737454e/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
index 329799f..4a95fea 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/model/ParameterDesc.java
@@ -22,8 +22,10 @@ import java.io.UnsupportedEncodingException;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableList;
/**
*/
@@ -36,9 +38,10 @@ public class ParameterDesc {
private String value;
@JsonProperty("next_parameter")
+ @JsonInclude(JsonInclude.Include.NON_NULL)
private ParameterDesc nextParameter;
- private List<TblColRef> colRefs;
+ private List<TblColRef> colRefs = ImmutableList.of();
public String getType() {
return type;
@@ -89,21 +92,36 @@ public class ParameterDesc {
ParameterDesc that = (ParameterDesc) o;
- if (nextParameter != null ? !nextParameter.equals(that.nextParameter) : that.nextParameter != null)
- return false;
if (type != null ? !type.equals(that.type) : that.type != null)
return false;
- if (value != null ? !value.equals(that.value) : that.value != null)
- return false;
-
- return true;
+
+ ParameterDesc p = this, q = that;
+ int refi = 0, refj = 0;
+ for (; p != null && q != null; p = p.nextParameter, q = q.nextParameter) {
+ if (p.isColumnType()) {
+ if (q.isColumnType() == false)
+ return false;
+ if (refi >= this.colRefs.size() || refj >= that.colRefs.size())
+ return false;
+ if (this.colRefs.get(refi).equals(that.colRefs.get(refj)) == false)
+ return false;
+ refi++;
+ refj++;
+ } else {
+ if (q.isColumnType() == true)
+ return false;
+ if (p.value.equals(q.value) == false)
+ return false;
+ }
+ }
+
+ return p == null && q == null;
}
@Override
public int hashCode() {
int result = type != null ? type.hashCode() : 0;
- result = 31 * result + (value != null ? value.hashCode() : 0);
- result = 31 * result + (nextParameter != null ? nextParameter.hashCode() : 0);
+ result = 31 * result + (colRefs != null ? colRefs.hashCode() : 0);
return result;
}