lushuifeng 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_r225762550
##########
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:
Is It better by NOT declaring the setter function, these fields can be
accessed by reflection directly, so the number of constants in constant pool
can be reduced
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services