suneet-s commented on a change in pull request #10370:
URL: https://github.com/apache/druid/pull/10370#discussion_r486052004
##########
File path: core/src/main/java/org/apache/druid/math/expr/ApplyFunction.java
##########
@@ -848,4 +882,32 @@ public CartesianFoldLambdaBinding accumulateWithIndex(int
index, Object acc)
return this;
}
}
+
+ class LambdaInputBindingTypes implements Expr.InputBindingTypes
+ {
+ private final Object2IntMap<String> lambdaIdentifiers;
+ private final Expr.InputBindingTypes inputTypes;
+ private final List<Expr> args;
+
+ public LambdaInputBindingTypes(Expr.InputBindingTypes inputTypes,
LambdaExpr expr, List<Expr> args)
+ {
+ this.inputTypes = inputTypes;
+ this.args = args;
+ List<String> identifiers = expr.getIdentifiers();
+ this.lambdaIdentifiers = new Object2IntOpenHashMap<>(args.size());
+ for (int i = 0; i < args.size(); i++) {
+ lambdaIdentifiers.put(identifiers.get(i), i);
+ }
+ }
+
+ @Nullable
+ @Override
+ public ExprType getType(String name)
+ {
+ if (lambdaIdentifiers.containsKey(name)) {
+ return
ExprType.elementType(args.get(lambdaIdentifiers.getInt(name)).getOutputType(inputTypes));
Review comment:
nit: Willl getType be called in a loop anywhere? It might be better to
use `getOrDefault(..)` instead to avoid 2 hashcode computations here (for
`containsKey` and `getInt`)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]