use of parquet.column.ColumnDescriptor in project presto by prestodb.
the class ParquetPredicateUtils method getDictionariesByColumnOrdinal.
private static Map<Integer, ParquetDictionaryDescriptor> getDictionariesByColumnOrdinal(BlockMetaData blockMetadata, ParquetDataSource dataSource, MessageType requestedSchema, TupleDomain<HiveColumnHandle> effectivePredicate) {
ImmutableMap.Builder<Integer, ParquetDictionaryDescriptor> dictionaries = ImmutableMap.builder();
for (int ordinal = 0; ordinal < blockMetadata.getColumns().size(); ordinal++) {
ColumnChunkMetaData columnChunkMetaData = blockMetadata.getColumns().get(ordinal);
for (int i = 0; i < requestedSchema.getColumns().size(); i++) {
ColumnDescriptor columnDescriptor = requestedSchema.getColumns().get(i);
if (isColumnPredicate(columnDescriptor, effectivePredicate) && columnChunkMetaData.getPath().equals(ColumnPath.get(columnDescriptor.getPath())) && isOnlyDictionaryEncodingPages(columnChunkMetaData.getEncodings())) {
try {
int totalSize = toIntExact(columnChunkMetaData.getTotalSize());
byte[] buffer = new byte[totalSize];
dataSource.readFully(columnChunkMetaData.getStartingPos(), buffer);
Optional<ParquetDictionaryPage> dictionaryPage = readDictionaryPage(buffer, columnChunkMetaData.getCodec());
dictionaries.put(ordinal, new ParquetDictionaryDescriptor(columnDescriptor, dictionaryPage));
} catch (IOException ignored) {
}
break;
}
}
}
return dictionaries.build();
}
Aggregations