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_r225775240
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java
##########
@@ -1074,7 +1078,12 @@ private void addBatchHolder(int part, int
batchRowCount) {
// These methods are overridden in the generated class when created as plain
Java code.
protected BatchHolder newBatchHolder(int batchRowCount) {
- return new BatchHolder(batchRowCount);
+ return this.injectMembers(new BatchHolder(batchRowCount));
+ }
+
+ protected BatchHolder injectMembers(BatchHolder batchHolder) {
+ CodeGenMemberInjector.injectMembers(cg, batchHolder, context);
Review comment:
The ClassGenerator and FragmentContext is needed in this method for general
cases, but not for test classes, see example in `ExampleTemplateWithInner.java`
newBatchHolder is override by generated code can be implemented as follows
to remove above method
`protected BatchHolder newBatchHolder(int batchRowCount) { return
CodeGenMemberInjector.injectMembers(cg, new BatchHolder(batchRowCount),
context); }`
but the `cg` and `context` params are hard coded, not flexable. I think it
is better to make a function call to hide the implementation which may differ
in each template.
----------------------------------------------------------------
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