-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Painless: Clean up FunctionRef #32644
Conversation
Pinging @elastic/es-core-infra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original name FunctionRef actually fit better into existing names within the codebase, eg we have BytesRef. The rename is also very difficult to review, as it is unclear what little changes there are within the file since it looks all new. Can you change the name back, and if the rename is that important, do it in a followup PR by itself?
Class<?> interfaceType = painlessLookup.canonicalTypeNameToType(interfaceClass); | ||
PainlessMethod interfaceMethod = painlessLookup.lookupPainlessClass(interfaceType).functionalMethod; | ||
if (interfaceMethod == null) { | ||
Class<?> interfaceType = painlessLookup.canonicalTypeNameToType(interfaceClass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems like this is indented too much now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. For some reason the formatting in this file has a lot of issues.
import static org.objectweb.asm.Opcodes.H_INVOKEVIRTUAL; | ||
import static org.objectweb.asm.Opcodes.H_NEWINVOKESPECIAL; | ||
|
||
public class FunctionReference { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the top level javadoc was lost in the rename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new one. The old one wasn't descriptive.
@rjernst Thanks for the review! Ready for the next round. Renamed this back to FunctionRef; however, while we do have classes like BytesRef outside of Painless, we've been heading toward longer more descriptive file names in Painless, and I would like to change this back in a different PR. The file names in Painless are all over the place right now and I would like a stronger consistency moving forward as things are worked on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
@rjernst Thanks again for the review! Will commit as soon as CI passes. |
This change consolidates all the logic for generating a FunctionReference (renamed from FunctionRef) from several arbitrary constructors to a single static function that is used at both compile-time and run-time. This increases long-term maintainability as it is much easier to follow when and how a function reference is being generated. It moves most of the duplicated logic out of the ECapturingFuncRef, EFuncRef and ELambda nodes and Def as well.
This change consolidates all the logic for generating a FunctionReference (renamed from FunctionRef) from several arbitrary constructors to a single static function that is used at both compile-time and run-time. This increases long-term maintainability as it is much easier to follow when and how a function reference is being generated. It moves most of the duplicated logic out of the ECapturingFuncRef, EFuncRef and ELambda nodes and Def as well.