Search in sources :

Example 1 with ColumnIO

use of parquet.io.ColumnIO in project presto by prestodb.

the class ParquetTypeUtils method getDescriptor.

public static Optional<RichColumnDescriptor> getDescriptor(MessageType fileSchema, MessageType requestedSchema, List<String> path) {
    checkArgument(path.size() >= 1, "Parquet nested path should have at least one component");
    int level = path.size();
    for (PrimitiveColumnIO columnIO : getColumns(fileSchema, requestedSchema)) {
        ColumnIO[] fields = columnIO.getPath();
        if (fields.length <= level) {
            continue;
        }
        if (fields[level].getName().equalsIgnoreCase(path.get(level - 1))) {
            boolean match = true;
            for (int i = 0; i < level - 1; i++) {
                if (!fields[i + 1].getName().equalsIgnoreCase(path.get(i))) {
                    match = false;
                }
            }
            if (match) {
                ColumnDescriptor descriptor = columnIO.getColumnDescriptor();
                return Optional.of(new RichColumnDescriptor(descriptor.getPath(), columnIO.getType().asPrimitiveType(), descriptor.getMaxRepetitionLevel(), descriptor.getMaxDefinitionLevel()));
            }
        }
    }
    return empty();
}
Also used : ColumnDescriptor(parquet.column.ColumnDescriptor) ColumnIO(parquet.io.ColumnIO) PrimitiveColumnIO(parquet.io.PrimitiveColumnIO) PrimitiveColumnIO(parquet.io.PrimitiveColumnIO)

Aggregations

ColumnDescriptor (parquet.column.ColumnDescriptor)1 ColumnIO (parquet.io.ColumnIO)1 PrimitiveColumnIO (parquet.io.PrimitiveColumnIO)1