Skip to content
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

Merged
merged 64 commits into from
Aug 7, 2018
Merged

Painless: Clean up FunctionRef #32644

merged 64 commits into from
Aug 7, 2018

Conversation

jdconrad
Copy link
Contributor

@jdconrad jdconrad commented Aug 6, 2018

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.

@jdconrad jdconrad added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v7.0.0 >refactoring v6.5.0 labels Aug 6, 2018
@jdconrad jdconrad requested a review from rjernst August 6, 2018 16:14
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jdconrad jdconrad mentioned this pull request Aug 6, 2018
23 tasks
Copy link
Member

@rjernst rjernst left a 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);
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

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?

Copy link
Contributor Author

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.

@jdconrad
Copy link
Contributor Author

jdconrad commented Aug 7, 2018

@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.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@jdconrad
Copy link
Contributor Author

jdconrad commented Aug 7, 2018

@rjernst Thanks again for the review! Will commit as soon as CI passes.

@jdconrad jdconrad merged commit 0b7fb4e into elastic:master Aug 7, 2018
jdconrad added a commit that referenced this pull request Aug 7, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring v6.5.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants