Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
auden-woolfson committed Jan 29, 2025
1 parent 8f01651 commit 6eaa5a5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}

0 comments on commit 6eaa5a5

Please sign in to comment.