dssysolyatin commented on code in PR #2977:
URL: https://github.com/apache/calcite/pull/2977#discussion_r1033016387
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableWindow.java:
##########
@@ -693,7 +696,7 @@ private static Pair<Expression, Expression>
getPartitionIterator(
}
Expression multiMap_ =
builder.append(
- "multiMap", Expressions.new_(SortedMultiMap.class));
+ "multiMap", Expressions.new_(SortedMultiMap.class), false);
Review Comment:
multiMap works OK at the moment even with optimize = true. But it is very
unsafe. I will try to explain why. The different between multiMap and tempList
cases are following.
Code for tempList case looks like:
```
final java.util.List tempList = (java.util.List)
org.apache.calcite.linq4j.Linq4j.asEnumerable(new Integer[] {1,2})
.into(new
java.util.ArrayList()); <-- this expression will be reused.
tempList.clear()
<----> Second EnumerableWindow will use the same tempList and will not fill
tempList again
```
Code for multiMap looks like:
```
final org.apache.calcite.runtime.SortedMultiMap multiMap = new
org.apache.calcite.runtime.SortedMultiMap(); <--this expression will be reused
org.apache.calcite.linq4j.Linq4j.asEnumerable(new Integer[]
{1,2}).foreach(<code for multiMap filling>)
multiMap.clear()
<----> Second EnumerableWindow will refill
```
Code works OK for multiMap only because the creation and filling of the
multiMap are in different expressions. But it is very unsafe. If for some
reason creating and filling multiMap are in the same expression code will also
stop working.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]