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.

Reply via email to