From 6eaa5a5d045767139d607074da944ac117ee9174 Mon Sep 17 00:00:00 2001
From: auden-woolfson <auden.woolfson@ibm.com>
Date: Wed, 29 Jan 2025 09:21:10 -0800
Subject: [PATCH] refactor

---
 ...meAndTimestampMicrosNestedBatchReader.java |  2 --
 .../batchreader/decoders/ValuesDecoder.java   |  5 ++++-
 ...pMicrosDeltaBinaryPackedValuesDecoder.java | 14 -------------
 ...eAndTimestampMicrosPlainValuesDecoder.java | 21 +------------------
 ...stampMicrosRLEDictionaryValuesDecoder.java | 14 -------------
 5 files changed, 5 insertions(+), 51 deletions(-)

diff --git a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/Int64TimeAndTimestampMicrosNestedBatchReader.java b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/Int64TimeAndTimestampMicrosNestedBatchReader.java
index e779a6dcf372d..652915453b4a3 100644
--- a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/Int64TimeAndTimestampMicrosNestedBatchReader.java
+++ b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/Int64TimeAndTimestampMicrosNestedBatchReader.java
@@ -16,11 +16,9 @@
 import com.facebook.presto.common.block.Block;
 import com.facebook.presto.common.block.LongArrayBlock;
 import com.facebook.presto.common.block.RunLengthEncodedBlock;
-import com.facebook.presto.common.type.TimestampWithTimeZoneType;
 import com.facebook.presto.parquet.RichColumnDescriptor;
 import com.facebook.presto.parquet.batchreader.decoders.ValuesDecoder.Int64TimeAndTimestampMicrosValuesDecoder;
 import com.facebook.presto.parquet.reader.ColumnChunk;
-import org.apache.parquet.schema.LogicalTypeAnnotation;
 
 import java.io.IOException;
 import java.util.Optional;
diff --git a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/ValuesDecoder.java b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/ValuesDecoder.java
index 610efce2e357f..96a83d83c9026 100644
--- a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/ValuesDecoder.java
+++ b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/ValuesDecoder.java
@@ -62,8 +62,11 @@ void readNext(long[] values, int offset, int length)
 
         void skip(int length)
                 throws IOException;
+    }
 
-        boolean getWithTimezone();
+    interface PackFunction
+    {
+        long pack(long millis);
     }
 
     interface TimestampValuesDecoder
diff --git a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/delta/Int64TimeAndTimestampMicrosDeltaBinaryPackedValuesDecoder.java b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/delta/Int64TimeAndTimestampMicrosDeltaBinaryPackedValuesDecoder.java
index dd1a70e8c559d..a8c7b8a6442d2 100644
--- a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/delta/Int64TimeAndTimestampMicrosDeltaBinaryPackedValuesDecoder.java
+++ b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/delta/Int64TimeAndTimestampMicrosDeltaBinaryPackedValuesDecoder.java
@@ -38,14 +38,11 @@ public class Int64TimeAndTimestampMicrosDeltaBinaryPackedValuesDecoder
 
     private final PackFunction packFunction;
 
-    private final boolean withTimezone;
-
     public Int64TimeAndTimestampMicrosDeltaBinaryPackedValuesDecoder(int valueCount, ByteBufferInputStream bufferInputStream, boolean withTimezone)
             throws IOException
     {
         innerReader = new DeltaBinaryPackingValuesReader();
         innerReader.initFromPage(valueCount, bufferInputStream);
-        this.withTimezone = withTimezone;
         this.packFunction = withTimezone ? millis -> packDateTimeWithZone(millis, UTC_KEY) : millis -> millis;
     }
 
@@ -74,15 +71,4 @@ public long getRetainedSizeInBytes()
         // Not counting innerReader since it's in another library.
         return INSTANCE_SIZE;
     }
-
-    @Override
-    public boolean getWithTimezone()
-    {
-        return withTimezone;
-    }
-
-    private interface PackFunction
-    {
-        long pack(long millis);
-    }
 }
diff --git a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/plain/Int64TimeAndTimestampMicrosPlainValuesDecoder.java b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/plain/Int64TimeAndTimestampMicrosPlainValuesDecoder.java
index 1bd2865cd08b6..96b76d5f20878 100644
--- a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/plain/Int64TimeAndTimestampMicrosPlainValuesDecoder.java
+++ b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/plain/Int64TimeAndTimestampMicrosPlainValuesDecoder.java
@@ -33,8 +33,6 @@ public class Int64TimeAndTimestampMicrosPlainValuesDecoder
 
     private int bufferOffset;
 
-    private final boolean withTimezone;
-
     private final PackFunction packFunction;
 
     public Int64TimeAndTimestampMicrosPlainValuesDecoder(byte[] byteBuffer, int bufferOffset, int length)
@@ -47,13 +45,7 @@ public Int64TimeAndTimestampMicrosPlainValuesDecoder(byte[] byteBuffer, int buff
         this.byteBuffer = byteBuffer;
         this.bufferOffset = bufferOffset;
         this.bufferEnd = bufferOffset + length;
-        this.withTimezone = withTimezone;
-        if (withTimezone) {
-            packFunction = millis -> packDateTimeWithZone(millis, UTC_KEY);
-        }
-        else {
-            packFunction = millis -> millis;
-        }
+        this.packFunction = withTimezone ? millis -> packDateTimeWithZone(millis, UTC_KEY) : millis -> millis;
     }
 
     @Override
@@ -87,15 +79,4 @@ public long getRetainedSizeInBytes()
     {
         return INSTANCE_SIZE + sizeOf(byteBuffer);
     }
-
-    @Override
-    public boolean getWithTimezone()
-    {
-        return withTimezone;
-    }
-
-    private interface PackFunction
-    {
-        long pack(long millis);
-    }
 }
diff --git a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder.java b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder.java
index 6fcd23e1ce121..c94d88f896805 100644
--- a/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder.java
+++ b/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder.java
@@ -36,15 +36,12 @@ public class Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder
 
     private final LongDictionary dictionary;
 
-    private final boolean withTimezone;
-
     private final PackFunction packFunction;
 
     public Int64TimeAndTimestampMicrosRLEDictionaryValuesDecoder(int bitWidth, InputStream inputStream, LongDictionary dictionary, boolean withTimezone)
     {
         super(Integer.MAX_VALUE, bitWidth, inputStream);
         this.dictionary = dictionary;
-        this.withTimezone = withTimezone;
         this.packFunction = withTimezone ? millis -> packDateTimeWithZone(millis, UTC_KEY) : millis -> millis;
     }
 
@@ -124,15 +121,4 @@ public long getRetainedSizeInBytes()
     {
         return INSTANCE_SIZE + (dictionary == null ? 0 : dictionary.getRetainedSizeInBytes()) + sizeOf(currentBuffer);
     }
-
-    @Override
-    public boolean getWithTimezone()
-    {
-        return withTimezone;
-    }
-
-    private interface PackFunction
-    {
-        long pack(long millis);
-    }
 }