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

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 965775a  Core: Use equals instead of reference equality (#2714)
965775a is described below

commit 965775a2abbf158b9621122b7322b20d8161584c
Author: Eduard Tudenhöfner <[email protected]>
AuthorDate: Fri Jun 18 18:46:34 2021 +0200

    Core: Use equals instead of reference equality (#2714)
    
    See also https://errorprone.info/bugpattern/ReferenceEquality
---
 .../src/main/java/org/apache/iceberg/parquet/ParquetAvro.java    | 9 +++++----
 .../src/main/java/org/apache/iceberg/parquet/PruneColumns.java   | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvro.java 
b/parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvro.java
index 669269a..ed6a6ca 100644
--- a/parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvro.java
+++ b/parquet/src/main/java/org/apache/iceberg/parquet/ParquetAvro.java
@@ -32,6 +32,7 @@ import org.apache.avro.generic.GenericFixed;
 import org.apache.avro.specific.SpecificData;
 import org.apache.iceberg.avro.AvroSchemaVisitor;
 import org.apache.iceberg.avro.UUIDConversion;
+import org.apache.iceberg.relocated.com.google.common.base.Objects;
 import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.types.TypeUtil;
@@ -252,7 +253,7 @@ class ParquetAvro {
 
         newFields.add(copyField(field, type));
 
-        if (field.schema() != type) {
+        if (!Objects.equal(field.schema(), type)) {
           hasChange = true;
         }
       }
@@ -274,7 +275,7 @@ class ParquetAvro {
 
     @Override
     public Schema array(Schema array, Schema element) {
-      if (array.getElementType() != element) {
+      if (!Objects.equal(array.getElementType(), element)) {
         return Schema.createArray(element);
       }
       return array;
@@ -282,7 +283,7 @@ class ParquetAvro {
 
     @Override
     public Schema map(Schema map, Schema value) {
-      if (map.getValueType() != value) {
+      if (!Objects.equal(map.getValueType(), value)) {
         return Schema.createMap(value);
       }
       return map;
@@ -318,7 +319,7 @@ class ParquetAvro {
 
       int length = types.size();
       for (int i = 0; i < length; i += 1) {
-        if (types.get(i) != replacements.get(i)) {
+        if (!Objects.equal(types.get(i), replacements.get(i))) {
           return false;
         }
       }
diff --git a/parquet/src/main/java/org/apache/iceberg/parquet/PruneColumns.java 
b/parquet/src/main/java/org/apache/iceberg/parquet/PruneColumns.java
index 42598ac..fa784a5 100644
--- a/parquet/src/main/java/org/apache/iceberg/parquet/PruneColumns.java
+++ b/parquet/src/main/java/org/apache/iceberg/parquet/PruneColumns.java
@@ -21,6 +21,7 @@ package org.apache.iceberg.parquet;
 
 import java.util.List;
 import java.util.Set;
+import org.apache.iceberg.relocated.com.google.common.base.Objects;
 import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.parquet.schema.GroupType;
@@ -102,7 +103,7 @@ class PruneColumns extends ParquetTypeVisitor<Type> {
     if (elementId != null && selectedIds.contains(elementId)) {
       return list;
     } else if (element != null) {
-      if (element != originalElement) {
+      if (!Objects.equal(element, originalElement)) {
         Integer listId = getId(list);
         // the element type was projected
         Type listType = Types.list(list.getRepetition())
@@ -129,7 +130,7 @@ class PruneColumns extends ParquetTypeVisitor<Type> {
       return map;
     } else if (value != null) {
       Integer mapId = getId(map);
-      if (value != originalValue) {
+      if (!Objects.equal(value, originalValue)) {
         Type mapType =  Types.map(map.getRepetition())
             .key(originalKey)
             .value(value)

Reply via email to