如何使用Google Cloud Dataflow将压缩文件写入Google Cloud Storage?

问题描述:

我正尝试在Google Dataflow程序中将Gzip文件写入Google Cloud Storage存储桶。常见问题解答说如何使用Google Cloud Dataflow将压缩文件写入Google Cloud Storage?

Does the TextIO source and sink support compressed files, such as GZip? 
Yes. Cloud Dataflow can read files compressed with gzip and bzip2. 

这是否意味着他们不支持写入GZip文件?

正确,我们目前没有内置的写gzip文件的支持。 然而,user-defined data format API,特别是FileBasedSink,应该很容易写出像你这样的接收器。

+0

谢谢。您可能想要解决[这里](https://cloud.google.com/dataflow/model/reading-and-writing-data#TextIO),因为文档提到您可以使用withCompressionType写入gzip文件 – user2254391

+0

我们将修复文档,谢谢! – jkff

+0

相关文档现在显示在以下位置:https://cloud.google.com/dataflow/model/text-io – Steven

在新梁库,你现在可以做到这一点更容易:

PDone d = c2.apply(TextIO.write() 
    .to("gs://path") 
    .withWritableByteChannelFactory(FileBasedSink.CompressionType.GZIP));