Stream#diff is not Lazy

已查看 28 次
跳至第一个未读帖子

Eastsun

未读,
2013年1月19日 07:41:132013/1/19
收件人 scala-i...@googlegroups.com
The method diff in Stream should be reimplemented to make it lazy.

Welcome to Scala version 2.11.0-20130116-203322-1dc6a99edc (OpenJDK 64-Bit Server VM, Java 1.7.0_09).
Type in expressions to have them evaluated.
Type :help for more information.

scala> val ints = Stream.from(1)
ints: scala.collection.immutable.Stream[Int] = Stream(1, ?)

scala> ints.diff(1 to 10)
java.lang.OutOfMemoryError: GC overhead limit exceeded
    at scala.collection.mutable.ListBuffer.$plus$eq(ListBuffer.scala:168)
    at scala.collection.mutable.ListBuffer.$plus$eq(ListBuffer.scala:43)
    at scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:58)
    at scala.collection.generic.Growable$$anonfun$$plus$plus$eq$1.apply(Growable.scala:58)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
    at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:58)
    at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:181)
    at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:43)
    at scala.collection.TraversableLike$class.to(TraversableLike.scala:632)
    at scala.collection.AbstractTraversable.to(Traversable.scala:103)
    at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:241)
    at scala.collection.AbstractTraversable.toList(Traversable.scala:103)
    at scala.collection.immutable.List$.apply(List.scala:397)
    at scala.collection.mutable.LazyBuilder.$plus$eq(LazyBuilder.scala:23)
    at scala.collection.mutable.LazyBuilder.$plus$eq(LazyBuilder.scala:20)
    at scala.collection.SeqLike$$anonfun$diff$1.apply(SeqLike.scala:443)
    at scala.collection.immutable.Stream.foreach(Stream.scala:552)
    at scala.collection.SeqLike$class.diff(SeqLike.scala:442)
    at scala.collection.AbstractSeq.diff(Seq.scala:40)
    at .<init>(<console>:9)
    at .<clinit>(<console>)
    at .<init>(<console>:7)
    at .<clinit>(<console>)
    at $print(<console>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:689)
    at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:895)
    at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:543)

Jason Zaugg

未读,
2013年1月19日 07:43:282013/1/19
收件人 scala-i...@googlegroups.com
On Sat, Jan 19, 2013 at 1:41 PM, Eastsun <flus...@gmail.com> wrote:
The method diff in Stream should be reimplemented to make it lazy.

It's best to raise a ticket directly in JIRA for bugs.

-jason 
回复全部
回复作者
转发
0 个新帖子