On 11/12/2015 06:57 PM, Endre Varga wrote:
Hi Simon,

This documentation section explains this in more detail: http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M1/scala/stream-rate.html
Ok, I didn't come to that point of the documentation so far. I'm going to have a look, thanks!

Btw, Sink.head actually does not request more than one, however this is not transitive and cannot be. Grouped cannot possibly know how many elements a downstream ever needs, so it tries to prefetch and exploit concurrency.
Why not? Doesn't it have to wait for a demand as all other components have to do too? I mean Sink.head has a demand of 1, shouldn't grouped get this demand and then forward a demand of 1*N, where N is the argument to grouped?

-Endre

On Thu, Nov 12, 2015 at 6:39 PM, Simon Schäfer <[email protected] <mailto:[email protected]>> wrote:

    I just tried the following (on 2.0-M1):

    scala> Source(1 to 100).map{i ⇒ println(i);
    i}.grouped(10).runWith(Sink.head)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    res10:
    scala.concurrent.Future[scala.collection.immutable.Seq[Int]] =
    scala.concurrent.impl.Promise$DefaultPromise@2df79942
    12
    13
    14
    15
    16

    scala> 17
    18
    19
    20
    21
    22
    23
    24
    res10.onComplete(println)
    Success(Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))

    A similar behavior can be seen for the take function:

    scala> Source(1 to 100).map{i ⇒ println(i);
    i}.take(10).runWith(Sink.fold(Vector[Int]())(_ :+ _))
    ...


    As one can see, the stream processes more elements than it has to.
    It is not a problem for me, but I would like to know if this
    behavior is spec'ed anywhere? Shouldn't the stream be able to say,
    just by looking at the arguments for grouped, take and the sink,
    how many elements should be produced?
-- >>>>>>>>>> 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 [email protected]
    <mailto:[email protected]>.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    Visit this group at http://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 a topic in the Google Groups "Akka User List" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/m4V-AsScuak/unsubscribe. To unsubscribe from this group and all its topics, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to