【发布时间】:2019-06-18 20:23:24
【问题描述】:
我正在尝试使用来自 akka Streams 的 Source 读取 avro 文件。
akka 流中的源读取类似 FileIO.FromPath(File) 的数据,它将根据 (\n) 字符读取和分隔行,而 avro 是如何工作的?
流程:
object AvroFlow {
def apply(jobDate: String): Flow[GenericRecord, GenericRecord, NotUsed] = {
Flow[GenericRecord].map { rec => rec.put("date", "20190812") rec}
}
}
图表:
object AvroRunner {
def build (src: Source[GenericRecord, NotUsed],
flw: Flow[GenericRecord, GenericRecord, NotUsed],
snk:Flow[GenericRecord, Future[Done])
: AvroRunner = {
new AvroRunner(srtc,flw,snk)
}
}
class AvroRunner private(src: Source[GenericRecord, NotUsed],
flw: Flow[GenericRecord, GenericRecord, NotUsed],
snk:Flow[GenericRecord, Future[Done]){
import scala.concurrent.ExecutionContext.Implicits.global
val GraphRunner = RunnableGraph.fromGraph(GraphDSL.create() {implicit builder =>
import GraphDSL.Implicits._
src ~> flw ~> snk
ClosedShape
})
}
【问题讨论】:
标签: scala io akka avro akka-stream