Hi Endre,

Thank you for an answer, i found working for me solution. Which looks like 
this:

I tweak jawn async json parse to be able to handle such json structure in 
streaming way, so i can convert Source[ByteString] into Source[(String, 
JValue)], where string is a name of json array. Now i can convert JValue 
into objects using map, later i pass this source (contentStream) via 

Source.fromGraph(GraphDSL.create(Sink.head[Seq[ObjA]]) { implicit builder => ds 
=>
  val B = builder.add(Broadcast[Any](2))
  contentStream ~> B
  B ~> Flow[Any].collect { case a: ObjA => a }.fold(Seq.empty[ObjA]) { (acc, a) 
=> acc :+ a } ~> ds
  val out = B ~> Flow[Any].collect { case b: ObjB => b }
  SourceShape(out.outlet)
})


what gives me Source[ObjB, Future[Seq[ObjA]]]


This way i can access both source and mat value when i run the graph.


Regards,

Kyrylo



On Monday, February 22, 2016 at 1:05:33 PM UTC+1, Akka Team wrote:
>
> Hi,
>
> This is not an easy task, I am not sure how to do it with built-in 
> combinators (you can do such custom stages but they are quite advanced and 
> we have not yet openly documented all APIs that is needed for these kind of 
> stages). But the largest issue will be that Source[A] and Source[B] will 
> not be independent, so you cannot read a single element from Source[B] 
> before you have read *all* the elements from Source[A] since your original 
> input is strictly sequential. 
>
> -Endre
>
> On Wed, Feb 10, 2016 at 3:47 PM, Kyrylo Stokoz <k.st...@gmail.com 
> <javascript:>> wrote:
>
>> Hi,
>>
>> I have an http server that accept post request where http entity is 
>> chuncked and can be quite big, basically entity is a json of the following 
>> format:
>>
>> {code}
>>  {
>>    "shortlist" : [ { serialized objA } ], // up to 100items
>>    "verylonglist": [{serialized objB}], // up to ~5M
>> }
>> {code}
>>
>> I was thinking in to have something like this (
>> https://github.com/knutwalker/akka-stream-json) to convert bytestring 
>> source into source[objA].
>> Is there an easy/nice way how to create sources for every array in json? 
>> i.e split one Source[ByteString] into several Source[ObjA] and Source[ObjB]?
>>
>> Any suggestion welcome...
>>
>> Thanks,
>> Kyrylo
>>
>>
>> -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com
> Twitter: @akkateam
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to