You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xi...@apache.org on 2021/05/24 23:24:21 UTC

[incubator-pinot] branch fixing_spi_comparison created (now 34acf9a)

This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a change to branch fixing_spi_comparison
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git.


      at 34acf9a  Fixing comparison and hashcode for Schema, FieldSpec and ColumnMetadata

This branch includes the following new commits:

     new 34acf9a  Fixing comparison and hashcode for Schema, FieldSpec and ColumnMetadata

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[incubator-pinot] 01/01: Fixing comparison and hashcode for Schema, FieldSpec and ColumnMetadata

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch fixing_spi_comparison
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git

commit 34acf9aa6c81d73bb4230e639e834f3cfdf095bc
Author: Xiang Fu <xi...@gmail.com>
AuthorDate: Mon May 24 16:23:44 2021 -0700

    Fixing comparison and hashcode for Schema, FieldSpec and ColumnMetadata
---
 .../local/segment/index/metadata/ColumnMetadata.java | 19 ++++++++++---------
 .../java/org/apache/pinot/spi/data/FieldSpec.java    |  4 +++-
 .../main/java/org/apache/pinot/spi/data/Schema.java  |  4 ++++
 .../org/apache/pinot/spi/utils/EqualityUtils.java    | 20 ++++++++++++++++++++
 4 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/metadata/ColumnMetadata.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/metadata/ColumnMetadata.java
index 7ebe8fa..6e9f22c 100644
--- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/metadata/ColumnMetadata.java
+++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/metadata/ColumnMetadata.java
@@ -24,6 +24,7 @@ import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.pinot.common.metadata.segment.ColumnPartitionMetadata;
 import org.apache.pinot.segment.local.partition.PartitionFunctionFactory;
 import org.apache.pinot.segment.local.segment.creator.TextIndexType;
@@ -605,15 +606,15 @@ public class ColumnMetadata {
           && hasInvertedIndex() == columnMetadata.hasInvertedIndex() && isSingleValue() == columnMetadata
           .isSingleValue() && isVirtual() == columnMetadata.isVirtual() && getMaxNumberOfMultiValues() == columnMetadata
           .getMaxNumberOfMultiValues() && getTotalNumberOfEntries() == columnMetadata.getTotalNumberOfEntries()
-          && isAutoGenerated() == columnMetadata.isAutoGenerated() && getDefaultNullValueString() == columnMetadata
-          .getDefaultNullValueString() && getTimeUnit() == (columnMetadata.getTimeUnit())
-          && getPaddingCharacter() == columnMetadata.getPaddingCharacter() && minValue == (columnMetadata.getMinValue())
-          && maxValue == (columnMetadata.getMaxValue()) && getPartitionFunction() == (columnMetadata
-          .getPartitionFunction()) && getNumPartitions() == columnMetadata.getNumPartitions()
-          && getPartitions() == (columnMetadata.getPartitions()) && getDateTimeFormat() == (columnMetadata
-          .getDateTimeFormat()) && getDateTimeGranularity() == (columnMetadata.getDateTimeGranularity())
-          && hasFSTIndex() == columnMetadata.hasFSTIndex() && getTextIndexType()
-          .equals(columnMetadata.getTextIndexType());
+          && isAutoGenerated() == columnMetadata.isAutoGenerated() && StringUtils
+          .equals(getDefaultNullValueString(), columnMetadata.getDefaultNullValueString())
+          && getTimeUnit() == (columnMetadata.getTimeUnit()) && getPaddingCharacter() == columnMetadata
+          .getPaddingCharacter() && minValue == (columnMetadata.getMinValue()) && maxValue == (columnMetadata
+          .getMaxValue()) && getPartitionFunction() == (columnMetadata.getPartitionFunction())
+          && getNumPartitions() == columnMetadata.getNumPartitions() && getPartitions() == (columnMetadata
+          .getPartitions()) && getDateTimeFormat() == (columnMetadata.getDateTimeFormat())
+          && getDateTimeGranularity() == (columnMetadata.getDateTimeGranularity()) && hasFSTIndex() == columnMetadata
+          .hasFSTIndex() && getTextIndexType().equals(columnMetadata.getTextIndexType());
     }
     return false;
   }
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java
index f77facb..f966f9b 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java
@@ -339,7 +339,8 @@ public abstract class FieldSpec implements Comparable<FieldSpec>, Serializable {
     return EqualityUtils.isEqual(_name, that._name) && EqualityUtils.isEqual(_dataType, that._dataType) && EqualityUtils
         .isEqual(_isSingleValueField, that._isSingleValueField) && EqualityUtils
         .isEqual(getStringValue(_defaultNullValue), getStringValue(that._defaultNullValue)) && EqualityUtils
-        .isEqual(_maxLength, that._maxLength) && EqualityUtils.isEqual(_transformFunction, that._transformFunction);
+        .isEqual(_maxLength, that._maxLength) && EqualityUtils.isEqual(_transformFunction, that._transformFunction)
+        && EqualityUtils.isEqual(_virtualColumnProvider, that._virtualColumnProvider);
   }
 
   @Override
@@ -350,6 +351,7 @@ public abstract class FieldSpec implements Comparable<FieldSpec>, Serializable {
     result = EqualityUtils.hashCodeOf(result, getStringValue(_defaultNullValue));
     result = EqualityUtils.hashCodeOf(result, _maxLength);
     result = EqualityUtils.hashCodeOf(result, _transformFunction);
+    result = EqualityUtils.hashCodeOf(result, _virtualColumnProvider);
     return result;
   }
 
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java b/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java
index 40b55d1..25b29ad 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java
@@ -641,6 +641,8 @@ public final class Schema implements Serializable {
         .isEqualIgnoreOrder(_metricFieldSpecs, that._metricFieldSpecs) && EqualityUtils
         .isEqual(_timeFieldSpec, that._timeFieldSpec) && EqualityUtils
         .isEqualIgnoreOrder(_dateTimeFieldSpecs, that._dateTimeFieldSpecs) && EqualityUtils
+        .isEqualIgnoreOrder(_complexFieldSpecs, that._complexFieldSpecs) && EqualityUtils
+        .isEqualMap(_fieldSpecMap, that._fieldSpecMap) && EqualityUtils
         .isEqual(_primaryKeyColumns, that._primaryKeyColumns);
   }
 
@@ -673,6 +675,8 @@ public final class Schema implements Serializable {
     result = EqualityUtils.hashCodeOf(result, _metricFieldSpecs);
     result = EqualityUtils.hashCodeOf(result, _timeFieldSpec);
     result = EqualityUtils.hashCodeOf(result, _dateTimeFieldSpecs);
+    result = EqualityUtils.hashCodeOf(result, _complexFieldSpecs);
+    result = EqualityUtils.hashCodeOf(result, _fieldSpecMap);
     result = EqualityUtils.hashCodeOf(result, _primaryKeyColumns);
     return result;
   }
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/EqualityUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/EqualityUtils.java
index 8839975..01110f5 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/EqualityUtils.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/EqualityUtils.java
@@ -22,8 +22,10 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
+import org.apache.pinot.spi.data.FieldSpec;
 
 
 /**
@@ -74,6 +76,9 @@ public class EqualityUtils {
 
   public static boolean isEqual(@Nullable Object left, @Nullable Object right) {
     if (left != null && right != null) {
+      if ((left instanceof Map) && (right instanceof Map)) {
+        return EqualityUtils.isEqualMap((Map)left, (Map)right);
+      }
       return left.equals(right);
     } else {
       return left == right;
@@ -84,6 +89,21 @@ public class EqualityUtils {
     return Arrays.deepEquals(left, right);
   }
 
+  public static boolean isEqualMap(@Nullable Map left, @Nullable Map right) {
+    if (left != null && right != null) {
+      if (left.size() != right.size()) {
+        return false;
+      }
+      for (Object key : left.keySet()) {
+        if ((!right.containsKey(key)) || (!EqualityUtils.isEqual(left.get(key), right.get(key)))) {
+          return false;
+        }
+      }
+      return true;
+    }
+    return left == right;
+  }
+
   @SuppressWarnings("unchecked")
   public static boolean isEqualIgnoreOrder(@Nullable List left, @Nullable List right) {
     if (left != null && right != null) {

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org