我们正在使用Apache Beam处理具有动态文件名的从pubsub源到GCS接收器的流数据。我们能够写文本文件,但不能写wav文件。
我们能够写出使用StringUtf8Coder的字节数组字符串(linear16 wav编码),但使用ByteArrayEncoder会出现编译错误
//这项工作:
pipelineBeginStage
.apply(
FileIO.<String, KamiAppData>writeDynamic()
.by((SerializableFunction<KamiAppData, String>) input -> input.GCSurl)
.via(
Contextful.fn((SerializableFunction<KamiAppData, String>) input -> input.audioStream),
TextIO.sink())
.to(outputBucket)
.withNaming(url -> FileNaming.getNaming(url, "wav"))
.withDestinationCoder(StringUtf8Coder.of())
.withNumShards(1));
//这会产生编译错误:
pipelineBeginStage
.apply(
FileIO.<String, KamiAppData>writeDynamic()
.by((SerializableFunction<KamiAppData, String>) input -> input.GCSurl)
.via(
Contextful.fn((SerializableFunction<KamiAppData, byte[]>) input -> input.audioStream.getBytes()),
TextIO.sink())
.to(outputBucket)
.withNaming(url -> FileNaming.getNaming(url, "wav"))
.withDestinationCoder(ByteArrayCoder.of())
.withNumShards(1));
我们得到的错误是:
cannot resolve method 'via(org.apache.beam.sdk.transforms.Contextful.Fn<InputT,OutputT>>,org.apache.beam.sdk.TextIO.Sink)'
我们如何使用Apache Beam API进行编译并将音频写入文件?
答案 0 :(得分:0)
安东在上面评论中的解释对我来说很清楚。
只需添加它以使其与字节类型一起使用,您可能需要实现自己的N = 1 integral = 12.6889
N = 2 integral = 8.39917
N = 4 integral = 7.97521
N = 8 integral = 9.24233
N = 16 integral = 9.75632
N = 32 integral = 9.87064
N = 64 integral = 9.46945
N = 128 integral = 9.27281
N = 256 integral = 9.27395
N = 512 integral = 9.17546
N = 1024 integral = 9.19097
N = 2048 integral = 9.26203
N = 4096 integral = 9.37979
N = 8192 integral = 9.36167
N = 16384 integral = 9.28918
N = 32768 integral = 9.29766
N = 65536 integral = 9.31101
N = 131072 integral = 9.3227
N = 262144 integral = 9.32588
N = 524288 integral = 9.32805
N = 1048576 integral = 9.32726
N = 2097152 integral = 9.32722
N = 4194304 integral = 9.331
N = 8388608 integral = 9.33082
N = 16777216 integral = 9.33174
N = 33554432 integral = 9.33164
N = 67108864 integral = 9.33303
N = 134217728 integral = 9.33283
N = 268435456 integral = 9.33327
N = 536870912 integral = 9.33325
N = 1073741824 integral = 9.33333
类。