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
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. -Endre On Thu, Nov 12, 2015 at 6:39 PM, Simon Schäfer <m...@antoras.de> 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 akka-user+unsubscr...@googlegroups.com. > To post to this group, send email to akka-user@googlegroups.com. > 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 akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.