changeset 6652:5262dcc62fd0

Intermediate node for parallel evaluation or spliterator should only inject SIZED.
author psandoz
date Fri, 30 Nov 2012 18:30:31 +0100
parents 55ce0f66ce3b
children 1e85112dff65
files src/share/classes/java/util/stream/AbstractPipeline.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FlagOpTest.java
diffstat 2 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/AbstractPipeline.java	Fri Nov 30 12:14:41 2012 -0500
+++ b/src/share/classes/java/util/stream/AbstractPipeline.java	Fri Nov 30 18:30:31 2012 +0100
@@ -192,7 +192,7 @@
 
                 // Get the source flags for the intermediate stream
                 iSourceFlags = StreamOpFlag.toStreamFlags(StreamOpFlag.combineOpFlags(statefulOp.getOpFlags(), opsFlags[upToOp]))
-                               | StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED;
+                               | StreamOpFlag.IS_SIZED;
                 iSource = new StreamSource.ForSpliterator<>(iNode.spliterator());
 
                 fromOp = ++upToOp;
@@ -620,7 +620,7 @@
                         for (int i = 0; i < subDepth; i++) {
                             flags = StreamOpFlag.combineOpFlags(ops[i].getOpFlags(), flags);
                         }
-                        flags = StreamOpFlag.toStreamFlags(flags) | StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED;
+                        flags = StreamOpFlag.toStreamFlags(flags) | StreamOpFlag.IS_SIZED;
 
                         // Wrap the spliterator in a wrapping spliterator
                         s = wrappingSpliterator(new StreamSource.ForSpliterator<>(s), flags, subDepth, depth);
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/FlagOpTest.java	Fri Nov 30 12:14:41 2012 -0500
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FlagOpTest.java	Fri Nov 30 18:30:31 2012 +0100
@@ -219,24 +219,26 @@
     }
 
     protected void testFlagsClearSequence(Supplier<StatefulOp<Integer, Integer>> cf) {
+        EnumSet<StreamOpFlag> known = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
         EnumSet<StreamOpFlag> preserve = EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED);
         EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
 
         List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
-        for (StreamOpFlag f : EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
+        for (StreamOpFlag f : EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
             ops.add(cf.get());
             ops.add(new TestFlagExpectedOp<>(f.clear(),
-                                             EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED),
+                                             known.clone(),
                                              preserve.clone(),
-                                             notKnown));
+                                             notKnown.clone()));
+            known.remove(f);
+            preserve.remove(f);
             notKnown.add(f);
-            preserve.remove(f);
         }
         ops.add(cf.get());
         ops.add(new TestFlagExpectedOp<>(0,
-                                         EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED),
+                                         known.clone(),
                                          preserve.clone(),
-                                         EnumSet.noneOf(StreamOpFlag.class)));
+                                         notKnown.clone()));
 
         StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
         @SuppressWarnings("rawtypes")
@@ -249,7 +251,7 @@
     }
 
     public void testFlagsSizedOrderedParallelCollect() {
-        EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
+        EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
         EnumSet<StreamOpFlag> serKnown = parKnown.clone();
 
         List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();