This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new eda90f6 Tweak parallel support in GINQ
eda90f6 is described below
commit eda90f6168151033737ceb18c34ae32c86c66bf2
Author: Daniel Sun <[email protected]>
AuthorDate: Thu Dec 31 10:42:44 2020 +0800
Tweak parallel support in GINQ
---
.../ginq/provider/collection/runtime/QueryableCollection.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git
a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
index db2b5a5..60803cf 100644
---
a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
+++
b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableCollection.java
@@ -487,7 +487,7 @@ class QueryableCollection<T> implements Queryable<T>,
Serializable {
sourceStream = toStream(sourceIterable); // we have to create
new stream every time because Java stream can not be reused
}
- if (!sourceStream.isParallel() &&
TRUE_STR.equals(QueryableHelper.getVar(PARALLEL))) {
+ if (!sourceStream.isParallel() && isParallel()) {
sourceStream = sourceStream.parallel();
}
@@ -523,7 +523,11 @@ class QueryableCollection<T> implements Queryable<T>,
Serializable {
}
private static <T> Stream<T> toStream(Iterable<T> sourceIterable) {
- return StreamSupport.stream(sourceIterable.spliterator(), false);
+ return StreamSupport.stream(sourceIterable.spliterator(),
isParallel());
+ }
+
+ private static boolean isParallel() {
+ return TRUE_STR.equals(QueryableHelper.getVar(PARALLEL));
}
private boolean isReusable() {