使用 SCIO fromspotify
为 编写作业Dataflow
,遵循 2 个示例e.g1和e.g2PubSub
将流写入到GCS
,但以下代码出现以下错误
错误
Exception in thread "main" java.lang.IllegalArgumentException: Write can only be applied to a Bounded PCollection
代码
object StreamingPubSub {
def main(cmdlineArgs: Array[String]): Unit = {
// set up example wiring
val (opts, args) = ScioContext.parseArguments[ExampleOptions](cmdlineArgs)
val dataflowUtils = new DataflowExampleUtils(opts)
dataflowUtils.setup()
val sc = ScioContext(opts)
sc.pubsubTopic(opts.getPubsubTopic)
.timestampBy {
_ => new Instant(System.currentTimeMillis() - (scala.math.random * RAND_RANGE).toLong)
}
.withFixedWindows((Duration.standardHours(1)))
.groupBy(_ => Unit)
.toWindowed
.toSCollection
.saveAsTextFile(args("output"))
val result = sc.close()
// CTRL-C to cancel the streaming pipeline
dataflowUtils.waitToFinish(result.internal)
}
}
我可能将窗口概念与 Bounded PCollection 混合在一起,有没有办法实现这一点,或者我需要应用一些变换来实现这一点,任何人都可以在这方面提供帮助