< prev index next >

src/java.base/share/classes/java/util/stream/SliceOps.java

Print this page

        

*** 137,147 **** helper.wrapSpliterator(spliterator), skip, limit, size); } else { // @@@ OOMEs will occur for LongStream.range(0, Long.MAX_VALUE).filter(i -> true).limit(n) ! // regardless of the value of n // Need to adjust the target size of splitting for the // SliceTask from say (size / k) to say min(size / k, 1 << 14) // This will limit the size of the buffers created at the leaf nodes // cancellation will be more aggressive cancelling later tasks // if the target slice size has been reached from a given task, --- 137,147 ---- helper.wrapSpliterator(spliterator), skip, limit, size); } else { // @@@ OOMEs will occur for LongStream.range(0, Long.MAX_VALUE).filter(i -> true).limit(n) ! // when n * parallelismLevel is sufficiently large. // Need to adjust the target size of splitting for the // SliceTask from say (size / k) to say min(size / k, 1 << 14) // This will limit the size of the buffers created at the leaf nodes // cancellation will be more aggressive cancelling later tasks // if the target slice size has been reached from a given task,
*** 602,613 **** // There is no need to truncate since the op performs the // skipping and limiting of elements return nb.build(); } else { ! Node<P_OUT> node = helper.wrapAndCopyInto(helper.makeNodeBuilder(-1, generator), ! spliterator).build(); thisNodeSize = node.count(); completed = true; spliterator = null; return node; } --- 602,620 ---- // There is no need to truncate since the op performs the // skipping and limiting of elements return nb.build(); } else { ! final Node.Builder<P_OUT> nb = op.makeNodeBuilder(-1, generator); ! if(targetOffset == 0) { // limit only ! Sink<P_OUT> opSink = op.opWrapSink(helper.getStreamAndOpFlags(), nb); ! helper.copyIntoWithCancel(helper.wrapSink(opSink), spliterator); ! } ! else { ! helper.wrapAndCopyInto(nb, spliterator); ! } ! Node<P_OUT> node = nb.build(); thisNodeSize = node.count(); completed = true; spliterator = null; return node; }
< prev index next >