Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
package org.apache.parquet.tools.util;

import java.util.ArrayList;
import java.util.Arrays;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -30,6 +27,7 @@
import com.google.common.base.Strings;

import org.apache.parquet.column.ColumnDescriptor;
import org.apache.parquet.column.statistics.*;
import org.apache.parquet.hadoop.metadata.BlockMetaData;
import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
import org.apache.parquet.hadoop.metadata.FileMetaData;
Expand All @@ -42,6 +40,9 @@
import org.apache.parquet.schema.Type;
import org.apache.parquet.schema.Type.Repetition;

import static org.apache.parquet.tools.command.DumpCommand.binaryToBigInteger;
import static org.apache.parquet.tools.command.DumpCommand.binaryToString;

public class MetadataUtils {
public static final double BAD_COMPRESSION_RATIO_CUTOFF = 0.97;
public static final double GOOD_COMPRESSION_RATIO_CUTOFF = 1.2;
Expand Down Expand Up @@ -149,6 +150,63 @@ private static void showDetails(PrettyPrintWriter out, ColumnChunkMetaData meta,
out.format(" FPO:%d", foff);
out.format(" SZ:%d/%d/%.2f", tsize, usize, ratio);
out.format(" VC:%d", count);

if (!meta.getStatistics().isEmpty()) {
Statistics statistics = meta.getStatistics();

if (statistics.hasNonNullValue()) {
String maxValue = null;
String minValue = null;
switch (meta.getType()) {
case BINARY:
BinaryStatistics binaryStatistics = (BinaryStatistics) statistics;
minValue = String.format("%s", binaryToString(binaryStatistics.genericGetMin()));
maxValue = String.format("%s", binaryToString(binaryStatistics.genericGetMax()));
break;
case BOOLEAN:
BooleanStatistics booleanStatistics = (BooleanStatistics) statistics;
minValue = String.format("%s", booleanStatistics.genericGetMin());
maxValue = String.format("%s", booleanStatistics.genericGetMax());
break;
case DOUBLE:
DoubleStatistics doubleStatistics = (DoubleStatistics) statistics;
minValue = String.format("%s", doubleStatistics.genericGetMin());
maxValue = String.format("%s", doubleStatistics.genericGetMax());
break;
case FLOAT:
FloatStatistics floatStatistics = (FloatStatistics) statistics;
minValue = String.format("%s", floatStatistics.genericGetMin());
maxValue = String.format("%s", floatStatistics.genericGetMax());
break;
case INT32:
IntStatistics int32Statistics = (IntStatistics) statistics;
minValue = String.format("%s", int32Statistics.genericGetMin());
maxValue = String.format("%s", int32Statistics.genericGetMax());
break;
case INT64:
LongStatistics int64Statistics = (LongStatistics) statistics;
minValue = String.format("%s", int64Statistics.genericGetMin());
maxValue = String.format("%s", int64Statistics.genericGetMax());
break;
case INT96:
BinaryStatistics int96Statistics = (BinaryStatistics) statistics;
minValue = String.format("%s", binaryToBigInteger(int96Statistics.genericGetMin()));
maxValue = String.format("%s", binaryToBigInteger(int96Statistics.genericGetMax()));
break;
case FIXED_LEN_BYTE_ARRAY:
BinaryStatistics fixLenByteArrStatistics = (BinaryStatistics) statistics;
minValue = String.format("%s", binaryToString(fixLenByteArrStatistics.genericGetMin()));
maxValue = String.format("%s", binaryToString(fixLenByteArrStatistics.genericGetMax()));
break;
}

out.format(" MIN:%s", minValue);
out.format(" MAX:%s", maxValue);
}

out.format(" NN:%d", meta.getStatistics().getNumNulls());
}

if (!encodings.isEmpty()) out.format(" ENC:%s", encodings);
out.println();
}
Expand Down