Skip to content

Commit

Permalink
Parquet code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenxiao committed Sep 18, 2020
1 parent 4b8021f commit 20b72bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
import com.facebook.presto.parquet.reader.ShortDecimalColumnReader;
import com.facebook.presto.parquet.reader.TimestampColumnReader;
import com.facebook.presto.spi.PrestoException;
import org.apache.parquet.schema.OriginalType;

import java.util.Optional;

import static com.facebook.presto.parquet.ParquetTypeUtils.createDecimalType;
import static com.facebook.presto.parquet.ParquetTypeUtils.isTimeStampMicrosType;
import static com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED;
import static org.apache.parquet.schema.OriginalType.DECIMAL;
import static org.apache.parquet.schema.OriginalType.TIMESTAMP_MICROS;

public class ColumnReaderFactory
{
Expand All @@ -56,7 +57,7 @@ private ColumnReaderFactory()
public static ColumnReader createReader(RichColumnDescriptor descriptor, boolean batchReadEnabled)
{
// decimal is not supported in batch readers
if (batchReadEnabled && descriptor.getPrimitiveType().getOriginalType() != OriginalType.DECIMAL) {
if (batchReadEnabled && descriptor.getPrimitiveType().getOriginalType() != DECIMAL) {
final boolean isNested = descriptor.getPath().length > 1;
switch (descriptor.getPrimitiveType().getPrimitiveTypeName()) {
case BOOLEAN:
Expand All @@ -83,7 +84,7 @@ public static ColumnReader createReader(RichColumnDescriptor descriptor, boolean
case INT32:
return createDecimalColumnReader(descriptor).orElse(new IntColumnReader(descriptor));
case INT64:
if (OriginalType.TIMESTAMP_MICROS.equals(descriptor.getPrimitiveType().getOriginalType())) {
if (TIMESTAMP_MICROS.equals(descriptor.getPrimitiveType().getOriginalType())) {
return new LongTimestampMicrosColumnReader(descriptor);
}
return createDecimalColumnReader(descriptor).orElse(new LongColumnReader(descriptor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.parquet.schema.DecimalMetadata;
import org.apache.parquet.schema.GroupType;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.schema.OriginalType;

import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -42,6 +41,7 @@
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.stream.Collectors.joining;
import static org.apache.parquet.schema.OriginalType.DECIMAL;
import static org.apache.parquet.schema.OriginalType.TIMESTAMP_MICROS;
import static org.apache.parquet.schema.Type.Repetition.REPEATED;

public final class ParquetTypeUtils
Expand Down Expand Up @@ -332,6 +332,6 @@ public static List<String> columnPathFromSubfield(Subfield subfield)

public static boolean isTimeStampMicrosType(ColumnDescriptor descriptor)
{
return OriginalType.TIMESTAMP_MICROS.equals(descriptor.getPrimitiveType().getOriginalType());
return TIMESTAMP_MICROS.equals(descriptor.getPrimitiveType().getOriginalType());
}
}

0 comments on commit 20b72bd

Please sign in to comment.