Hi Akka Stream Users,
I'm fairly new to Akka Streams, and only just getting starting understanding some of its concepts.
One problem I'm having is trying to understand how Tuples are handled in a stream. In my scenario I have a Source emitting Tuple2 of (ZipEntry(), ByteString()). ZipEntry contains basic information (name, date created) about the zip file, and the ByteString contains the extracted text of the zip file.
I'm comfortable getting a stream performing a delimit of a ByteString with the following.
Source.map(_._2).via(Framing.delimiter(ByteString("\n"), Int.MaxValue)))
However, what I would like to be able to do is maintain the ZipEntry information alongside the ByteString for each new row created through the delimiter. That way I can process the stream further using groupBy etc.
Example Source --> Sink
Source input:
(ZipEntry(name1.txt, date1), ByteString(58, 49, ..., 54, 58, ..., 48, 48, ...) )
(ZipEntry(name2.txt, date2), ByteString(49, 58, ..., 58, 54, ..., 48, 48, ...) )
Sink output:
(ZipEntry(name1.txt, date), ByteString(58, 49, ...) )
(ZipEntry(name1.txt, date), ByteString(54, 58, ...) )
(ZipEntry(name1.txt, date), ByteString(48, 48, ...) )
...
(ZipEntry(name2.txt, date), ByteString(58, 49, ...) )
(ZipEntry(name2.txt, date), ByteString(54, 58, ...) )
(ZipEntry(name2.txt, date), ByteString(48, 48, ...) )
...
Should I be looking at a breaking it down into a RunnableGraph?
Any help/pointers to documentation on the correct approach would be appreciated.
Thanks
Paul