Skip to content

Commit

Permalink
fix by repalcing HashSet with TreeSet (apache#12047)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemesis123925 authored Dec 5, 2023
1 parent 9d779b4 commit 96c2f3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

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;
Expand Down Expand Up @@ -162,15 +161,8 @@ private boolean updateExprMinMaxFunctionMap(List<Expression> exprMinMaxMeasuring
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);
Expand All @@ -179,6 +171,6 @@ private boolean updateExprMinMaxFunctionMap(List<Expression> exprMinMaxMeasuring
operands.add(0, exprMinMaxProjectionExpression);
operands.add(0, RequestUtils.getLiteralExpression(id));

return added.get();
return added;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testQueryRewrite() {
"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");
}

Expand Down

0 comments on commit 96c2f3d

Please sign in to comment.