You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2021/08/08 19:55:44 UTC

[orc] branch branch-1.7 updated: ORC-922: Remove redundant conditional statements (#835)

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

dongjoon pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new 1ef88b3  ORC-922: Remove redundant conditional statements (#835)
1ef88b3 is described below

commit 1ef88b3f822811c11d79bffc9ebfe59837965071
Author: William Hyun <wi...@apache.org>
AuthorDate: Sun Aug 8 12:55:04 2021 -0700

    ORC-922: Remove redundant conditional statements (#835)
    
    ### What changes were proposed in this pull request?
    This PR aims to remove redundant conditional statements.
    
    ### Why are the changes needed?
    This will improve code quality.
    
    ### How was this patch tested?
    Pass the CIs.
    
    (cherry picked from commit a3d92ed813a4d4cc13594f4bc778582b1ff54dfc)
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../org/apache/orc/impl/ColumnStatisticsImpl.java  | 53 ++++------------------
 .../apache/orc/impl/RunLengthIntegerWriterV2.java  |  2 +-
 .../org/apache/orc/impl/writer/TreeWriterBase.java |  5 +-
 3 files changed, 11 insertions(+), 49 deletions(-)

diff --git a/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java b/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
index 7f8180e..fde1aac 100644
--- a/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
@@ -64,10 +64,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
     if (hasNull != that.hasNull) {
       return false;
     }
-    if (bytesOnDisk != that.bytesOnDisk) {
-      return false;
-    }
-    return true;
+    return bytesOnDisk == that.bytesOnDisk;
   }
 
   @Override
@@ -155,11 +152,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
 
       BooleanStatisticsImpl that = (BooleanStatisticsImpl) o;
 
-      if (trueCount != that.trueCount) {
-        return false;
-      }
-
-      return true;
+      return trueCount == that.trueCount;
     }
 
     @Override
@@ -294,11 +287,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
       if (maximum != that.maximum) {
         return false;
       }
-      if (sum != that.sum) {
-        return false;
-      }
-
-      return true;
+      return sum == that.sum;
     }
 
     @Override
@@ -500,11 +489,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
       if (hasMinimum != that.hasMinimum) {
         return false;
       }
-      if (overflow != that.overflow) {
-        return false;
-      }
-
-      return true;
+      return overflow == that.overflow;
     }
 
     @Override
@@ -658,11 +643,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
       if (Double.compare(that.maximum, maximum) != 0) {
         return false;
       }
-      if (Double.compare(that.sum, sum) != 0) {
-        return false;
-      }
-
-      return true;
+      return Double.compare(that.sum, sum) == 0;
     }
 
     @Override
@@ -915,11 +896,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
       if (minimum != null ? !minimum.equals(that.minimum) : that.minimum != null) {
         return false;
       }
-      if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null) {
-        return false;
-      }
-
-      return true;
+      return maximum != null ? maximum.equals(that.maximum) : that.maximum == null;
     }
 
     @Override
@@ -1079,11 +1056,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
 
       BinaryStatisticsImpl that = (BinaryStatisticsImpl) o;
 
-      if (sum != that.sum) {
-        return false;
-      }
-
-      return true;
+      return sum == that.sum;
     }
 
     @Override
@@ -1248,11 +1221,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
       if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null) {
         return false;
       }
-      if (sum != null ? !sum.equals(that.sum) : that.sum != null) {
-        return false;
-      }
-
-      return true;
+      return sum != null ? sum.equals(that.sum) : that.sum == null;
     }
 
     @Override
@@ -1628,11 +1597,7 @@ public class ColumnStatisticsImpl implements ColumnStatistics {
       if (minimum != that.minimum) {
         return false;
       }
-      if (maximum != that.maximum) {
-        return false;
-      }
-
-      return true;
+      return maximum == that.maximum;
     }
 
     @Override
diff --git a/java/core/src/java/org/apache/orc/impl/RunLengthIntegerWriterV2.java b/java/core/src/java/org/apache/orc/impl/RunLengthIntegerWriterV2.java
index abd9eab..2a22ea9 100644
--- a/java/core/src/java/org/apache/orc/impl/RunLengthIntegerWriterV2.java
+++ b/java/core/src/java/org/apache/orc/impl/RunLengthIntegerWriterV2.java
@@ -278,7 +278,7 @@ public class RunLengthIntegerWriterV2 implements IntegerWriter {
     final int headerSecondByte = variableRunLength & 0xff;
 
     // if the min value is negative toggle the sign
-    final boolean isNegative = min < 0 ? true : false;
+    final boolean isNegative = min < 0;
     if (isNegative) {
       min = -min;
     }
diff --git a/java/core/src/java/org/apache/orc/impl/writer/TreeWriterBase.java b/java/core/src/java/org/apache/orc/impl/writer/TreeWriterBase.java
index 69d5f61..1381ee5 100644
--- a/java/core/src/java/org/apache/orc/impl/writer/TreeWriterBase.java
+++ b/java/core/src/java/org/apache/orc/impl/writer/TreeWriterBase.java
@@ -140,10 +140,7 @@ public abstract class TreeWriterBase implements TreeWriter {
                                     boolean signed, boolean isDirectV2,
                                     WriterContext writer) {
     if (isDirectV2) {
-      boolean alignedBitpacking = false;
-      if (writer.getEncodingStrategy().equals(OrcFile.EncodingStrategy.SPEED)) {
-        alignedBitpacking = true;
-      }
+      boolean alignedBitpacking = writer.getEncodingStrategy().equals(OrcFile.EncodingStrategy.SPEED);
       return new RunLengthIntegerWriterV2(output, signed, alignedBitpacking);
     } else {
       return new RunLengthIntegerWriter(output, signed);