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

ESQL: Add DriverContext to the construction of Evaluators #99518

Merged
merged 8 commits into from
Sep 13, 2023

Conversation

ChrisHegarty
Copy link
Contributor

This commit adds DriverContext to the construction of Evaluators.

DriverContext is enriched to carry bigArrays, and will eventually carry a BlockFactory - it's the context for code requiring to create instances of blocks and big arrays.

relates #99173

@ChrisHegarty ChrisHegarty added >refactoring Team:QL (Deprecated) Meta label for query languages team :Analytics/ES|QL AKA ESQL labels Sep 13, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@ChrisHegarty ChrisHegarty changed the title Add DriverContext to evaluators ESQL: Add DriverContext to the construction of Evaluators Sep 13, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

@ChrisHegarty
Copy link
Contributor Author

ChrisHegarty commented Sep 13, 2023

An explicit ExpressionEvaluatorFactory type is added, which replaces the previous Supplier<EvalOperator.ExpressionEvaluator>, following similar style in the operators package. The creator function (supplier/factory) now requires a single arg, a DriverContext. A more generic Function<Driver,ExpressionEvaluator> could have been used (rather than a new type), but it would clutter the use-site quite a bit.

Evaluator implementations also now take an additional DriverContext param. Allowing both the expression evaluator and evaluator implementations to eventually access driver-specific bigArrays and (eventually) block factory implementations.

@ChrisHegarty
Copy link
Contributor Author

I believe that all feedback has been addressed.

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I left some small things but they can come later.

// For testing
public DriverContext() {
this(BigArrays.NON_RECYCLING_INSTANCE);
}
Copy link
Member

Choose a reason for hiding this comment

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

I know it's a pain, but I'd prefer not to have this in our production code. It'd be super ok on some test class, but it's too tempting.

@@ -33,11 +35,30 @@
*/
public class DriverContext {

/** A default driver context. The returned bigArrays is non recycling. */
public static DriverContext DEFAULT = new DriverContext(BigArrays.NON_RECYCLING_INSTANCE);
Copy link
Member

Choose a reason for hiding this comment

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

It's not really a "default" - it's more of a "don't use this in production" kind of thing.

Copy link
Member

Choose a reason for hiding this comment

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

Or, like, I guess a "temporary" kind of thing.

}

@Override
public String describe() {
return "EvalOperator[evaluator=" + evaluator.get() + "]";
return "EvalOperator[evaluator=" + evaluator.get(DriverContext.DEFAULT) + "]";
Copy link
Member

Choose a reason for hiding this comment

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

If we're generating factory could we generate the toString in it so we don't have to pass the driver context? I just want to make sure we don't accidentally do stuff with the context.

@ChrisHegarty
Copy link
Contributor Author

@nik9000 If it's ok, I'll merge this PR as-is, to avoid any conflicts as it touches many places. I'll follow up with the outstanding comments immediately.

@ChrisHegarty ChrisHegarty merged commit baf11a9 into elastic:main Sep 13, 2023
@nik9000
Copy link
Member

nik9000 commented Sep 13, 2023

@nik9000 If it's ok, I'll merge this PR as-is, to avoid any conflicts as it touches many places. I'll follow up with the outstanding comments immediately.

no rush. It's not going to hurt anything.

piergm pushed a commit to piergm/elasticsearch that referenced this pull request Sep 14, 2023
)

This commit adds DriverContext to the construction of Evaluators.

DriverContext is enriched to carry bigArrays, and will eventually carry a BlockFactory - it's the context for code requiring to create instances of blocks and big arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >refactoring Team:QL (Deprecated) Meta label for query languages team v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants