Search in sources :

Example 1 with PrimitiveStringifier

use of org.apache.parquet.schema.PrimitiveStringifier in project parquet-mr by apache.

the class DumpCommand method dump.

public static void dump(PrettyPrintWriter out, ColumnReadStoreImpl crstore, ColumnDescriptor column, long page, long total, long offset) throws IOException {
    int dmax = column.getMaxDefinitionLevel();
    ColumnReader creader = crstore.getColumnReader(column);
    out.format("*** row group %d of %d, values %d to %d ***%n", page, total, offset, offset + creader.getTotalValueCount() - 1);
    for (long i = 0, e = creader.getTotalValueCount(); i < e; ++i) {
        int rlvl = creader.getCurrentRepetitionLevel();
        int dlvl = creader.getCurrentDefinitionLevel();
        out.format("value %d: R:%d D:%d V:", offset + i, rlvl, dlvl);
        if (dlvl == dmax) {
            PrimitiveStringifier stringifier = column.getPrimitiveType().stringifier();
            switch(column.getType()) {
                case FIXED_LEN_BYTE_ARRAY:
                case INT96:
                case BINARY:
                    out.print(stringifier.stringify(creader.getBinary()));
                    break;
                case BOOLEAN:
                    out.print(stringifier.stringify(creader.getBoolean()));
                    break;
                case DOUBLE:
                    out.print(stringifier.stringify(creader.getDouble()));
                    break;
                case FLOAT:
                    out.print(stringifier.stringify(creader.getFloat()));
                    break;
                case INT32:
                    out.print(stringifier.stringify(creader.getInteger()));
                    break;
                case INT64:
                    out.print(stringifier.stringify(creader.getLong()));
                    break;
            }
        } else {
            out.format("<null>");
        }
        out.println();
        creader.consume();
    }
}
Also used : PrimitiveStringifier(org.apache.parquet.schema.PrimitiveStringifier) ColumnReader(org.apache.parquet.column.ColumnReader)

Aggregations

ColumnReader (org.apache.parquet.column.ColumnReader)1 PrimitiveStringifier (org.apache.parquet.schema.PrimitiveStringifier)1