use of com.facebook.presto.orc.WriterEncryptionGroup in project presto by prestodb.
the class OrcFileWriterFactory method createDwrfEncryption.
private Optional<DwrfWriterEncryption> createDwrfEncryption(Optional<EncryptionInformation> encryptionInformation, List<String> fileColumnNames, List<Type> types) {
if (!encryptionInformation.isPresent()) {
return Optional.empty();
}
if (!encryptionInformation.get().getDwrfEncryptionMetadata().isPresent()) {
return Optional.empty();
}
DwrfEncryptionMetadata dwrfEncryptionMetadata = encryptionInformation.get().getDwrfEncryptionMetadata().get();
List<OrcType> orcTypes = OrcType.createOrcRowType(0, fileColumnNames, types);
Map<String, Integer> columnNamesMap = IntStream.range(0, fileColumnNames.size()).boxed().collect(toImmutableMap(fileColumnNames::get, index -> index));
Map<Integer, Slice> keyMap = dwrfEncryptionMetadata.toKeyMap(orcTypes, columnNamesMap);
ImmutableListMultimap.Builder<Slice, Integer> encryptionGroupsBuilder = ImmutableListMultimap.builder();
keyMap.entrySet().stream().forEach(entry -> encryptionGroupsBuilder.put(entry.getValue(), entry.getKey()));
ImmutableListMultimap<Slice, Integer> encryptionGroups = encryptionGroupsBuilder.build();
List<WriterEncryptionGroup> writerEncryptionGroups = encryptionGroups.keySet().stream().map(key -> new WriterEncryptionGroup(encryptionGroups.get(key), key)).collect(toImmutableList());
return Optional.of(new DwrfWriterEncryption(toKeyProvider(dwrfEncryptionMetadata.getEncryptionProvider()), writerEncryptionGroups));
}
Aggregations