การใช้ SCIO จาก spotify
เพื่อเขียนงานสำหรับ Dataflow
ตามตัวอย่าง 2 รายการ เช่นg1 และ e .g2 เพื่อเขียนสตรีม PubSub
ไปที่ 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 มีวิธีใดที่จะบรรลุเป้าหมายนี้ หรือฉันจำเป็นต้องใช้การแปลงบางอย่างเพื่อให้สิ่งนี้เกิดขึ้น ใคร ๆ ก็สามารถช่วยเหลือได้ในเรื่องนี้