vvysotskyi commented on a change in pull request #1481: DRILL-6763: Codegen optimization of SQL functions with constant values URL: https://github.com/apache/drill/pull/1481#discussion_r225494095
########## File path: exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java ########## @@ -531,11 +541,42 @@ public JVar declareClassField(String prefix, JType t) { public JVar declareClassField(String prefix, JType t, JExpression init) { if (innerClassGenerator != null && hasMaxIndexValue()) { - return innerClassGenerator.clazz.field(JMod.NONE, t, prefix + index++, init); + return innerClassGenerator.declareClassField(prefix, t, init); } return clazz.field(JMod.NONE, t, prefix + index++, init); } + /** + * declare a setter method for the argument {@code var}. + * argument {@code function} holds the constant value which + * returns a value holder must be invoked when the class instance created. + * the setter method of innerClassField will be invoked if innerClassGenerator exists. + * + * @param var the class member variable + * @param function the function holds the constant value + * @return the depth of nested class, setter method + */ + public Pair<Integer, JMethod> declareSetterMethod(JVar var, Function<DrillBuf, ? extends ValueHolder> function) { + JMethod setter = clazz.method(JMod.PUBLIC, void.class, "set" + StringUtils.capitalize(var.name())); Review comment: Please move the initialization to the else block below and put code which uses this var after the `if...else` block. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services