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 2015/09/19 01:47:11 UTC

[35/50] [abbrv] incubator-kylin git commit: KYLIN-958 ignore more non-structral change in DataModel

KYLIN-958 ignore more non-structral change in DataModel

Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/419798d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/419798d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/419798d7

Branch: refs/heads/master
Commit: 419798d7b3b14f168b5b49abad0b5d18d1cfbdfc
Parents: c4b4b11
Author: shaofengshi <sh...@apache.org>
Authored: Wed Sep 9 13:40:23 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Wed Sep 9 13:40:23 2015 +0800

----------------------------------------------------------------------
 .../kylin/metadata/model/DataModelDesc.java     | 85 ++++++++++----------
 1 file changed, 44 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/419798d7/metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java b/metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java
index cb1e784..78feec4 100644
--- a/metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java
+++ b/metadata/src/main/java/org/apache/kylin/metadata/model/DataModelDesc.java
@@ -18,17 +18,17 @@
 
 package org.apache.kylin.metadata.model;
 
-import java.io.IOException;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Map;
 
 import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.kylin.common.persistence.ResourceStore;
 import org.apache.kylin.common.persistence.RootPersistentEntity;
-import org.apache.kylin.common.util.JsonUtil;
+import org.apache.kylin.common.util.JsonUtil;
 import org.apache.kylin.common.util.StringUtil;
 import org.apache.kylin.metadata.MetadataConstants;
 
@@ -36,12 +36,12 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect;
 import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.collect.Sets;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
 public class DataModelDesc extends RootPersistentEntity {
-    private static final Logger logger = LoggerFactory.getLogger(DataModelDesc.class);
+    private static final Logger logger = LoggerFactory.getLogger(DataModelDesc.class);
 
     public static enum RealizationCapacity {
         SMALL, MEDIUM, LARGE
@@ -219,41 +219,44 @@ public class DataModelDesc extends RootPersistentEntity {
         }
     }
 
-    /**
-     * Check whether two data model are compatible or not. Compatible means
-     * having the same structure. Tow models could be compatible even they
-     * have different UUID or last modified time.
-     * @param that model to compare with
-     * @return true if compatible, false otherwise.
-     */
-    public boolean compatibleWith(DataModelDesc that) {
-        if (this == that)
-            return true;
-
-        if (that == null)
-            return false;
-
-        try {
-            String thisRepr = excludeHeaderInfo(this);
-            String thatRepr = excludeHeaderInfo(that);
-            return StringUtils.equals(thisRepr, thatRepr);
-
-        } catch (IOException e) {
-            logger.error("Failed to serialize DataModelDesc to string", e);
-            return false;
-        }
-    }
-
-    private String excludeHeaderInfo(DataModelDesc modelDesc) throws IOException {
-        // make a copy
-        String repr = JsonUtil.writeValueAsString(modelDesc);
-        DataModelDesc copy = JsonUtil.readValue(repr, DataModelDesc.class);
-
-        copy.setUuid(null);
-        copy.setLastModified(0);
-        return JsonUtil.writeValueAsString(copy);
-    }
-
+    /**
+     * Check whether two data model are compatible or not. Compatible means
+     * having the same structure. Tow models could be compatible even they
+     * have different UUID or last modified time.
+     * @param that model to compare with
+     * @return true if compatible, false otherwise.
+     */
+    public boolean compatibleWith(DataModelDesc that) {
+        if (this == that)
+            return true;
+
+        if (that == null)
+            return false;
+
+        try {
+            String thisRepr = excludeHeaderInfo(this);
+            String thatRepr = excludeHeaderInfo(that);
+            return StringUtils.equals(thisRepr, thatRepr);
+
+        } catch (IOException e) {
+            logger.error("Failed to serialize DataModelDesc to string", e);
+            return false;
+        }
+    }
+
+    private String excludeHeaderInfo(DataModelDesc modelDesc) throws IOException {
+        // make a copy
+        String repr = JsonUtil.writeValueAsString(modelDesc);
+        DataModelDesc copy = JsonUtil.readValue(repr, DataModelDesc.class);
+
+        copy.setUuid(null);
+        copy.setLastModified(0);
+        copy.setCapacity(RealizationCapacity.MEDIUM);
+        copy.setFilterCondition(null);
+        copy.setPartitionDesc(null);
+        return JsonUtil.writeValueAsString(copy);
+    }
+
     @Override
     public String toString() {
         return "DataModelDesc [name=" + name + "]";