use of com.facebook.presto.hive.HiveCompressionCodec in project presto by prestodb.
the class PageFileWriterFactory method createFileWriter.
@Override
public Optional<HiveFileWriter> createFileWriter(Path path, List<String> inputColumnNames, StorageFormat storageFormat, Properties schema, JobConf configuration, ConnectorSession session, Optional<EncryptionInformation> encryptionInformation) {
if (!storageFormat.getOutputFormat().equals(PAGEFILE.getOutputFormat())) {
return Optional.empty();
}
HiveCompressionCodec compression = HiveCompressionCodec.valueOf(configuration.get(PAGE_FILE_COMPRESSION));
if (!compression.isSupportedStorageFormat(PAGEFILE)) {
throw new PrestoException(GENERIC_USER_ERROR, format("%s compression is not supported for %s", compression.name(), PAGEFILE.getOutputFormat()));
}
PagesSerde pagesSerde = createPagesSerdeForPageFile(blockEncodingSerde, Optional.of(compression));
try {
FileSystem fileSystem = hdfsEnvironment.getFileSystem(session.getUser(), path, configuration);
DataSink dataSink = dataSinkFactory.createDataSink(session, fileSystem, path);
Callable<Void> rollbackAction = () -> {
fileSystem.delete(path, false);
return null;
};
return Optional.of(new PageFileWriter(dataSink, pagesSerde, compression, getPageFileStripeMaxSize(session), rollbackAction));
} catch (IOException e) {
throw new PrestoException(HIVE_WRITER_OPEN_ERROR, "Error creating pagefile", e);
}
}
Aggregations