You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2023/12/05 01:52:42 UTC
(pinot) branch master updated: fix by repalcing HashSet with TreeSet (#12047)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 96c2f3dd9d fix by repalcing HashSet with TreeSet (#12047)
96c2f3dd9d is described below
commit 96c2f3dd9dbfc1c7b7d8daa0ad7c2a9c66ce6cc0
Author: Yuxuan Guo <gu...@gmail.com>
AuthorDate: Mon Dec 4 19:52:36 2023 -0600
fix by repalcing HashSet with TreeSet (#12047)
---
.../pinot/sql/parsers/rewriter/ExprMinMaxRewriter.java | 16 ++++------------
.../sql/parsers/rewriter/ExprMinMaxRewriterTest.java | 2 +-
2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriter.java b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriter.java
index 2e08118a43..2363ae5c42 100644
--- a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriter.java
+++ b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriter.java
@@ -20,12 +20,11 @@ package org.apache.pinot.sql.parsers.rewriter;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.TreeSet;
import org.apache.pinot.common.request.Expression;
import org.apache.pinot.common.request.Function;
import org.apache.pinot.common.request.PinotQuery;
@@ -162,15 +161,8 @@ public class ExprMinMaxRewriter implements QueryRewriter {
int size = exprMinMaxFunctionIDMap.size();
int id = exprMinMaxFunctionIDMap.computeIfAbsent(exprMinMaxMeasuringExpressions, (k) -> size);
- AtomicBoolean added = new AtomicBoolean(true);
-
- exprMinMaxFunctionMap.compute(exprMinMaxMeasuringExpressions, (k, v) -> {
- if (v == null) {
- v = new HashSet<>();
- }
- added.set(v.add(exprMinMaxProjectionExpression));
- return v;
- });
+ boolean added = exprMinMaxFunctionMap.computeIfAbsent(exprMinMaxMeasuringExpressions, k -> new TreeSet<>())
+ .add(exprMinMaxProjectionExpression);
String operator = function.getOperator();
function.setOperator(CommonConstants.RewriterConstants.CHILD_AGGREGATION_NAME_PREFIX + operator);
@@ -179,6 +171,6 @@ public class ExprMinMaxRewriter implements QueryRewriter {
operands.add(0, exprMinMaxProjectionExpression);
operands.add(0, RequestUtils.getLiteralExpression(id));
- return added.get();
+ return added;
}
}
diff --git a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriterTest.java b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriterTest.java
index adae1cf5ab..d44b9d7abf 100644
--- a/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriterTest.java
+++ b/pinot-common/src/test/java/org/apache/pinot/sql/parsers/rewriter/ExprMinMaxRewriterTest.java
@@ -43,7 +43,7 @@ public class ExprMinMaxRewriterTest {
"SELECT CHILD_EXPR_MIN(0,col5,col5,col1,col2), "
+ "CHILD_EXPR_MIN(0,col6,col6,col1,col2), "
+ "CHILD_EXPR_MAX(0,col6,col6,col1,col2),"
- + "PARENT_EXPR_MIN(0,2,col1,col2,col6,col5),"
+ + "PARENT_EXPR_MIN(0,2,col1,col2,col5,col6),"
+ "PARENT_EXPR_MAX(0,2,col1,col2,col6) FROM myTable");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org