If you need the results from the substreams you’ll have to merge them back into 
the mainstream and aggregate them there:

transactions.groupBy(100, 
...).fold(...).mergeSubstreams.grouped(100).to(Sink.head)

Regards,

Roland

> 26 apr 2016 kl. 17:36 skrev debasish <ghosh.debas...@gmail.com>:
> 
> Viktor -
> 
> Here's the same stuff that works for akka-streams version 
> akka-stream-experimental 1.0 RC4. .. 
> https://gist.github.com/debasishg/4d596c1f26d4759ed65e281bb2e6fd2c ..
> 
> The upgrade that I am having trouble with is defining netTxn (pls see the 
> gist). The groupBy works like a charm in the older version. But in the newer 
> version it returns a Subflow and I was stumped how to get hold of each of the 
> substreams and fold them using a Monoid on a fold sink. Konrad's solution was 
> to use the to method of subflow. But somehow it's not giving the desired 
> result .. help ?
> 
> Thanks.
> 
> 
> On Tuesday, April 26, 2016 at 8:46:11 PM UTC+5:30, √ wrote:
> What are you expecting to be returned?
> 
> -- 
> Cheers,
> √
> 
> On Apr 26, 2016 3:49 PM, "Debasish Ghosh" <ghosh.d...@gmail.com 
> <javascript:>> wrote:
> Thanks Konrad for the pointer .. when I run the graph I get a NotUsed .. 
> That's not hwat I get with the earlier implementation. Please have a look at 
> the gist .. 
> https://gist.github.com/debasishg/a42e867bb2bc8ad18243597178bbce93 
> <https://gist.github.com/debasishg/a42e867bb2bc8ad18243597178bbce93> .. what 
> am I doing wrong.
> 
> Thanks.
> 
> On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski <konrad....@typesafe.com 
> <javascript:>> wrote:
> (I did a quick mock Transaction type, your Monoid should work fine there ofc).
> 
> -- Konrad
> 
> On Sunday, 24 April 2016 21:42:43 UTC+2, debasish wrote:
> Hi -
> 
> I am trying to migrate some akka-streams code from an earlier version 
> (akka-stream-experimental 1.0.RC4) .. please have a look at the following ..
> 
> /**
>  * Create multiple streams out of a single stream. The stream "transactions" 
> is being
>  * demultiplexed into many streams split by account number. Each of the 
> sub-streams are
>  * then materialized to the fold sink "txnSink", which folds each of the 
> transaction
>  * substreams to compute the net value of the transaction for that account
>  */
>  val netTxn: Source[RunnableGraph[Future[Transaction]], Unit] = 
>    transactions.map(validate).groupBy(_.accountNo).map { case (a, s) => 
> s.toMat(txnSink)(Keep.right) }
> 
> I am trying to create substreams based on a field accountNo within a 
> Transaction. Then I pass each substream to toMat with a Sink which is a fold 
> Sink defined as below ..
> 
> /**
>  * Would like to fold transactions through monoid append
>  */
>  val txnSink: Sink[Transaction, Future[Transaction]] =
>    Sink.fold[Transaction, Transaction](TransactionMonoid.zero)(_ |+| _)
> 
> The idea is to apply a monoid over each substream and do some netting on 
> transactions belonging to the same accountNo.
> 
> How can I migrate this to 2.4.4 ? Now groupBy returns a Subflow and I am not 
> sure how to apply each of the substreams to the materializer. One option that 
> works will be to create a Map[String, Transaction] upfront and then directly 
> apply the monoid to the Map in the main stream and not create any substream. 
> But I would like to have the substreams fro some other purpose as well.
> 
> Any help will be appreciated ..
> 
> Regards.
> - Debasish
> 
> 
> 
> 
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <https://groups.google.com/group/akka-user>
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Akka User List" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/akka-user/YhJfghLqnhw/unsubscribe 
> <https://groups.google.com/d/topic/akka-user/YhJfghLqnhw/unsubscribe>.
> To unsubscribe from this group and all its topics, 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 
> <https://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> 
> -- 
> Debasish Ghosh
> http://manning.com/ghosh2 <http://manning.com/ghosh2>
> http://manning.com/ghosh <http://manning.com/ghosh>
> 
> Twttr: @debasishg
> Blog: http://debasishg.blogspot.com <http://debasishg.blogspot.com/>
> Code: http://github.com/debasishg <http://github.com/debasishg>
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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 
> <https://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> -- 
> >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/>
> >>>>>>>>>> Check the FAQ: 
> >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html>
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user 
> >>>>>>>>>> <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 
> <mailto:akka-user+unsubscr...@googlegroups.com>.
> To post to this group, send email to akka-user@googlegroups.com 
> <mailto:akka-user@googlegroups.com>.
> Visit this group at https://groups.google.com/group/akka-user 
> <https://groups.google.com/group/akka-user>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
>>>>>>>>>>      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