Skip to content

Scripting: Groundwork for caching script results#49895

Merged
stu-elastic merged 2 commits intoelastic:masterfrom
stu-elastic:feature/painless-caching-part-1
Dec 6, 2019
Merged

Scripting: Groundwork for caching script results#49895
stu-elastic merged 2 commits intoelastic:masterfrom
stu-elastic:feature/painless-caching-part-1

Conversation

@stu-elastic
Copy link
Copy Markdown
Contributor

In order to cache script results in the query shard cache, we need to
check if scripts are deterministic. This change adds a default method
to the script factories, isResultDeterministic() -> false which is
used by the QueryShardContext.

Script results were never cached and that does not change here. Future
changes will implement this method based on whether the results of the
scripts are deterministic or not and therefore cacheable.

Refs: #49466

In order to cache script results in the query shard cache, we need to
check if scripts are deterministic.  This change adds a default method
to the script factories, `isResultDeterministic() -> false` which is
used by the `QueryShardContext`.

Script results were never cached and that does not change here.  Future
changes will implement this method based on whether the results of the
scripts are deterministic or not and therefore cacheable.

Refs: elastic#49466
Copy link
Copy Markdown
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


package org.elasticsearch.script;

public interface ScriptFactory {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A short javadoc on the interface itself would be nice. Something about a base for utility methods about compiled scripts that is agnostic to the concrete script signatures?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, done.

package org.elasticsearch.script;

public interface ScriptFactory {
/** Is the result of this script deterministic? */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we do a little more exact javadoc, like:

Returns {@code true} if the result of the script will be deterministic, {@code false} otherwise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's so good I may use it.

@stu-elastic
Copy link
Copy Markdown
Contributor Author

@elasticmachine run elasticsearch-ci/1

@stu-elastic stu-elastic merged commit 356d1a2 into elastic:master Dec 6, 2019
stu-elastic added a commit to stu-elastic/elasticsearch that referenced this pull request Dec 6, 2019
In order to cache script results in the query shard cache, we need to
check if scripts are deterministic.  This change adds a default method
to the script factories, `isResultDeterministic() -> false` which is
used by the `QueryShardContext`.

Script results were never cached and that does not change here.  Future
changes will implement this method based on whether the results of the
scripts are deterministic or not and therefore cacheable.

Refs: elastic#49466
@stu-elastic stu-elastic added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v7.6.0 v8.0.0 labels Dec 6, 2019
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

stu-elastic added a commit that referenced this pull request Dec 6, 2019
In order to cache script results in the query shard cache, we need to
check if scripts are deterministic.  This change adds a default method
to the script factories, `isResultDeterministic() -> false` which is
used by the `QueryShardContext`.

Script results were never cached and that does not change here.  Future
changes will implement this method based on whether the results of the
scripts are deterministic or not and therefore cacheable.

Refs: #49466

**Backport**
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
In order to cache script results in the query shard cache, we need to
check if scripts are deterministic.  This change adds a default method
to the script factories, `isResultDeterministic() -> false` which is
used by the `QueryShardContext`.

Script results were never cached and that does not change here.  Future
changes will implement this method based on whether the results of the
scripts are deterministic or not and therefore cacheable.

Refs: elastic#49466
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 >enhancement v7.6.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants