Giovanni, hi!
With some piece of stubbornness :) I (guess) have found a way with
Source.last():
def sinkFoldM[U, T](zero: U)(f: (U, T) ⇒ Future[U]): Sink[T, Future[U]] =
Sink.fromGraph {
val last = Sink.last[U]
GraphDSL.create(last) { implicit b => last =>
import
On Wednesday, March 9, 2016 at 1:20:37 PM UTC+3, Giovanni Alberto
Caporaletti wrote:
>
> It would fail with an empty stream. You can use lastOption but you would
> need to map over the materialized value thus needing an execution context
> outside the stream context.
>
Oh.. Yes! Thanks for
It would fail with an empty stream. You can use lastOption but you would
need to map over the materialized value thus needing an execution context
outside the stream context.
cheers
G
On Wednesday, 9 March 2016 01:19:01 UTC+1, Andrew Gaydenko wrote:
>
> Giovanni, I mean your last suggestion
Giovanni, I mean your last suggestion with custom stage.
--
>> 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
---
Giovanni, hi!
What do you think about replacing
val sink = Sink.fold(zero)(Keep.right[U, U])
with
val sink = Sink.last[U]
?
--
>> Read the docs: http://akka.io/docs/
>> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
I'll volunteer to review :)
On Tue, Mar 8, 2016 at 12:26 PM, Konrad Malawski
wrote:
> Here's the ticket, you'd like to contribute these operations (it's pretty
> easy to contribute, one can look at mapAsync and see how it differs from
> map):
>
I'd like to repeat that a scanAsync and a foldAsync would be very welcome
additions :)
On Tue, Mar 8, 2016 at 12:01 AM, Andrew Gaydenko
wrote:
> Giovanni, hi!
>
> Thanks! - have played with this test. In fact, I started tests with
> -Xmx=128M, and range up to 20M. The
Giovanni, hi!
Thanks! - have played with this test. In fact, I started tests with
-Xmx=128M, and range up to 20M. The first two variants resulted in OOME, as
Roland predicted, and the last one with own Graph resulted in the rather
quick answer with small RAM footprint during execution (~100MB
def foldM[U, T](zero: U)(f: (U, T) ⇒ Future[U]): Sink[T, Future[U]] = {
Sink.fold[Future[U], T](Future.successful(zero)) { (fu, t) =>
println(s"inside fold $t")
fu.flatMap { x =>
println(s"inside flatMap $x")
f(x, t)
}
}.mapMaterializedValue(_ flatMap identity)
}
val
On Sunday, March 6, 2016 at 2:28:22 AM UTC+3, Giovanni Alberto Caporaletti
wrote:
>
> Hi Roland,
> you're right, my solution was a bit naive. I came up with this, I'm pretty
> sure it can be done in a better way, looking forward to seeing your
> solution :)
>
Giovanni, thanks for this graph -
Hi Roland,
you're right, my solution was a bit naive. I came up with this, I'm pretty
sure it can be done in a better way, looking forward to seeing your
solution :)
def foldM[U, T](zero: U)(f: (U, T) ⇒ Future[U]): Sink[T, Future[U]] =
Sink.fromGraph {
val sink =
On Saturday, March 5, 2016 at 11:52:06 PM UTC+3, rkuhn wrote:
>
> Unfortunately these solutions create unbounded amounts of futures without
> back pressure, so I'd recommend against this approach. But it is late and
> I'm on the phone so cannot suggest a proper solution.
>
Roland, hi!
Thanks
Unfortunately these solutions create unbounded amounts of futures without back
pressure, so I'd recommend against this approach. But it is late and I'm on the
phone so cannot suggest a proper solution.
Regards,
Roland
Sent from my iPhone
> On 05 Mar 2016, at 17:41, Giovanni Alberto
Giovanni, hi!
I used a way similar to the the first suggestion, but wasn't sure it is
elegant way to wrap zero into Future on rewriting folding function.
So, I'll experiment with both ways when some benchmarks be ready. And I
need some time to dig in the second suggestion :)
Thanks!!
On
how about this:
def foldM[U, T](zero: U)(f: (U, T) ⇒ Future[U]): Sink[T, Future[U]] = {
Sink
.fold[Future[U], T](Future.successful(zero))((fu, t) => fu.flatMap(f(_, t)))
.mapMaterializedValue(_ flatMap identity)
}
or this:
def foldM[U, T](zero: U)(f: (U, T) ⇒ Future[U]): Sink[T,
15 matches
Mail list logo