I'm trying to read an avro file with Source from akka Streams.
Source in akka streams read data like FileIO.FromPath(File), which will read and separate the lines based on (\n) character, where as for avro how does it work?
Flow :
object AvroFlow {
def apply(jobDate: String): Flow[GenericRecord, GenericRecord, NotUsed] = {
Flow[GenericRecord].map { rec => rec.put("date", "20190812") rec}
}
}
Graph:
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
})
}