Re: [akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Debasish Ghosh
There's no toMat in SubFlow .. which groupBy returns ..

On Tue, Apr 26, 2016 at 10:03 PM, Viktor Klang 
wrote:

> Sorry if I'm being daft, but shouldn't it be doing: 
> transactions.groupBy(maxSubstreams
> = 100, _.accountNo).toMat(txnSink, Keep.right)
>
> On Tue, Apr 26, 2016 at 6:05 PM, Debasish Ghosh 
> wrote:
>
>> Roland -
>>
>> I need to merge into a fold sink w/ a Monoid. Consider the following
>> example ..
>>
>> case class Transaction(id: String, accountNo: String, debitCredit:
>> TransactionType, amount: Amount, date: Date = today)
>>
>> and I have the following list of Transactions ..
>>
>> val txns =
>> Seq(
>>   Transaction("t-1", "a-1", Debit, 1000),
>>   Transaction("t-2", "a-2", Debit, 1000),
>>   Transaction("t-3", "a-3", Credit, 1000),
>>   Transaction("t-4", "a-1", Credit, 1000),
>>   Transaction("t-5", "a-1", Debit, 1000),
>>   Transaction("t-6", "a-2", Debit, 1000),
>>   Transaction("t-7", "a-3", Credit, 1000),
>>   Transaction("t-8", "a-3", Debit, 1000),
>>   Transaction("t-9", "a-2", Credit, 1000),
>>   Transaction("t-10", "a-2", Debit, 1000),
>>   Transaction("t-11", "a-1", Credit, 1000),
>>   Transaction("t-12", "a-3", Debit, 1000)
>> )
>>
>> I do a group by accountNo, which gives me 3 substreams. Each substream
>> needs to go into a fold sink where I fold using a Monoid. The Monoid has
>> the logic of merging transactions belonging to the same accountNo. The
>> logic that u suggest will not do this. I need to access the substreams
>> separately. That's why I did a groupBy (similar to SQL groupBy). And I
>> could do this in the 1.0 version.
>>
>> Any workaround that u suggest ?
>>
>> Thanks.
>>
>> On Tue, Apr 26, 2016 at 9:18 PM, Roland Kuhn  wrote:
>>
>>> 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 :
>>>
>>> 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"  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 ..
> what am I doing wrong.
>
> Thanks.
>
> On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski <
> konrad@typesafe.com> 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
>>> 

Re: [akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Viktor Klang
Sorry if I'm being daft, but shouldn't it be doing:
transactions.groupBy(maxSubstreams
= 100, _.accountNo).toMat(txnSink, Keep.right)

On Tue, Apr 26, 2016 at 6:05 PM, Debasish Ghosh 
wrote:

> Roland -
>
> I need to merge into a fold sink w/ a Monoid. Consider the following
> example ..
>
> case class Transaction(id: String, accountNo: String, debitCredit:
> TransactionType, amount: Amount, date: Date = today)
>
> and I have the following list of Transactions ..
>
> val txns =
> Seq(
>   Transaction("t-1", "a-1", Debit, 1000),
>   Transaction("t-2", "a-2", Debit, 1000),
>   Transaction("t-3", "a-3", Credit, 1000),
>   Transaction("t-4", "a-1", Credit, 1000),
>   Transaction("t-5", "a-1", Debit, 1000),
>   Transaction("t-6", "a-2", Debit, 1000),
>   Transaction("t-7", "a-3", Credit, 1000),
>   Transaction("t-8", "a-3", Debit, 1000),
>   Transaction("t-9", "a-2", Credit, 1000),
>   Transaction("t-10", "a-2", Debit, 1000),
>   Transaction("t-11", "a-1", Credit, 1000),
>   Transaction("t-12", "a-3", Debit, 1000)
> )
>
> I do a group by accountNo, which gives me 3 substreams. Each substream
> needs to go into a fold sink where I fold using a Monoid. The Monoid has
> the logic of merging transactions belonging to the same accountNo. The
> logic that u suggest will not do this. I need to access the substreams
> separately. That's why I did a groupBy (similar to SQL groupBy). And I
> could do this in the 1.0 version.
>
> Any workaround that u suggest ?
>
> Thanks.
>
> On Tue, Apr 26, 2016 at 9:18 PM, Roland Kuhn  wrote:
>
>> 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 :
>>
>> 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"  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 ..
 what am I doing wrong.

 Thanks.

 On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski <
 konrad@typesafe.com> 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 

Re: [akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Debasish Ghosh
Roland -

I need to merge into a fold sink w/ a Monoid. Consider the following
example ..

case class Transaction(id: String, accountNo: String, debitCredit:
TransactionType, amount: Amount, date: Date = today)

and I have the following list of Transactions ..

val txns =
Seq(
  Transaction("t-1", "a-1", Debit, 1000),
  Transaction("t-2", "a-2", Debit, 1000),
  Transaction("t-3", "a-3", Credit, 1000),
  Transaction("t-4", "a-1", Credit, 1000),
  Transaction("t-5", "a-1", Debit, 1000),
  Transaction("t-6", "a-2", Debit, 1000),
  Transaction("t-7", "a-3", Credit, 1000),
  Transaction("t-8", "a-3", Debit, 1000),
  Transaction("t-9", "a-2", Credit, 1000),
  Transaction("t-10", "a-2", Debit, 1000),
  Transaction("t-11", "a-1", Credit, 1000),
  Transaction("t-12", "a-3", Debit, 1000)
)

I do a group by accountNo, which gives me 3 substreams. Each substream
needs to go into a fold sink where I fold using a Monoid. The Monoid has
the logic of merging transactions belonging to the same accountNo. The
logic that u suggest will not do this. I need to access the substreams
separately. That's why I did a groupBy (similar to SQL groupBy). And I
could do this in the 1.0 version.

Any workaround that u suggest ?

Thanks.

On Tue, Apr 26, 2016 at 9:18 PM, Roland Kuhn  wrote:

> 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 :
>
> 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"  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 ..
>>> what am I doing wrong.
>>>
>>> Thanks.
>>>
>>> On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski <
>>> konrad@typesafe.com> 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/
 

Re: [akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Roland Kuhn
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 :
> 
> 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"  > 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 
>  .. what 
> am I doing wrong.
> 
> Thanks.
> 
> On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski  > 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/ 
> >> 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 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 
> .
> To unsubscribe from this group and all its topics, send an email to 
> akka-user+...@googlegroups.com .
> To post to this group, send email to akka...@googlegroups.com .
> Visit this group at https://groups.google.com/group/akka-user 
> .
> For more options, visit https://groups.google.com/d/optout 
> .
> 
> 
> 
> -- 
> Debasish Ghosh
> http://manning.com/ghosh2 
> http://manning.com/ghosh 
> 
> Twttr: @debasishg
> Blog: http://debasishg.blogspot.com 
> Code: http://github.com/debasishg 
> 
> -- 
> >> Read the docs: http://akka.io/docs/ 
> >> Check the FAQ: 
> >> http://doc.akka.io/docs/akka/current/additional/faq.html 
> >> 

Re: [akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread debasish
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"  > 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 .. 
>> what am I doing wrong.
>>
>> Thanks.
>>
>> On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski > > 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/
>>> >> 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 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.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> akka-user+...@googlegroups.com .
>>> To post to this group, send email to akka...@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Debasish Ghosh
>> http://manning.com/ghosh2
>> http://manning.com/ghosh
>>
>> Twttr: @debasishg
>> Blog: http://debasishg.blogspot.com
>> Code: http://github.com/debasishg
>>
>> -- 
>> >> 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 .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit 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

Re: [akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Viktor Klang
What are you expecting to be returned?

-- 
Cheers,
√
On Apr 26, 2016 3:49 PM, "Debasish Ghosh"  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 ..
> what am I doing wrong.
>
> Thanks.
>
> On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski <
> konrad.malaw...@typesafe.com> 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/
>> >> 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 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.
>> To unsubscribe from this group and all its topics, 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.
>>
>
>
>
> --
> Debasish Ghosh
> http://manning.com/ghosh2
> http://manning.com/ghosh
>
> Twttr: @debasishg
> Blog: http://debasishg.blogspot.com
> Code: http://github.com/debasishg
>
> --
> >> 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.
>

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


Re: [akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Debasish Ghosh
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 .. what
am I doing wrong.

Thanks.

On Tue, Apr 26, 2016 at 6:22 PM, Konrad Malawski <
konrad.malaw...@typesafe.com> 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/
> >> 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 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.
> To unsubscribe from this group and all its topics, 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.
>



-- 
Debasish Ghosh
http://manning.com/ghosh2
http://manning.com/ghosh

Twttr: @debasishg
Blog: http://debasishg.blogspot.com
Code: http://github.com/debasishg

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


[akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Konrad Malawski
(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/
>>  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.


[akka-user] Re: migrating from an earlier version of akka-streams ..

2016-04-26 Thread Konrad Malawski
Hi Debasish,
sorry for the delay, team meeting got us focused on planning things.

It seems that in your case you don't need anything very weird, have you 
seen `to`?

val txnSink: Sink[Transaction, Future[Transaction]] =
  Sink.fold[Transaction, Transaction](Transaction.zero)(_ + _)

val netTxn: RunnableGraph[NotUsed] =
  transactions.groupBy(maxSubstreams = 100, _.accountNo)
.to(txnSink)


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