forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize Painless doc structure (elastic#42303)
- Loading branch information
Showing
32 changed files
with
120 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include::painless-walkthrough.asciidoc[] | ||
|
||
include::painless-method-dispatch.asciidoc[] | ||
|
||
include::painless-debugging.asciidoc[] | ||
|
||
include::painless-execute-script.asciidoc[] |
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
docs/painless/painless-guide/painless-method-dispatch.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[[modules-scripting-painless-dispatch]] | ||
=== How painless dispatches functions | ||
|
||
Painless uses receiver, name, and https://en.wikipedia.org/wiki/Arity[arity] | ||
for method dispatch. For example, `s.foo(a, b)` is resolved by first getting | ||
the class of `s` and then looking up the method `foo` with two parameters. This | ||
is different from Groovy which uses the | ||
https://en.wikipedia.org/wiki/Multiple_dispatch[runtime types] of the | ||
parameters and Java which uses the compile time types of the parameters. | ||
|
||
The consequence of this that Painless doesn't support overloaded methods like | ||
Java, leading to some trouble when it whitelists classes from the Java | ||
standard library. For example, in Java and Groovy, `Matcher` has two methods: | ||
`group(int)` and `group(String)`. Painless can't whitelist both of these methods | ||
because they have the same name and the same number of parameters. So instead it | ||
has `group(int)` and `namedGroup(String)`. | ||
|
||
We have a few justifications for this different way of dispatching methods: | ||
|
||
1. It makes operating on `def` types simpler and, presumably, faster. Using | ||
receiver, name, and arity means that when Painless sees a call on a `def` object it | ||
can dispatch the appropriate method without having to do expensive comparisons | ||
of the types of the parameters. The same is true for invocations with `def` | ||
typed parameters. | ||
2. It keeps things consistent. It would be genuinely weird for Painless to | ||
behave like Groovy if any `def` typed parameters were involved and Java | ||
otherwise. It'd be slow for it to behave like Groovy all the time. | ||
3. It keeps Painless maintainable. Adding the Java or Groovy like method | ||
dispatch *feels* like it'd add a ton of complexity which'd make maintenance and | ||
other improvements much more difficult. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
include::painless-comments.asciidoc[] | ||
|
||
include::painless-keywords.asciidoc[] | ||
|
||
include::painless-literals.asciidoc[] | ||
|
||
include::painless-identifiers.asciidoc[] | ||
|
||
include::painless-variables.asciidoc[] | ||
|
||
include::painless-types.asciidoc[] | ||
|
||
include::painless-casting.asciidoc[] | ||
|
||
include::painless-operators.asciidoc[] | ||
|
||
include::painless-operators-general.asciidoc[] | ||
|
||
include::painless-operators-numeric.asciidoc[] | ||
|
||
include::painless-operators-boolean.asciidoc[] | ||
|
||
include::painless-operators-reference.asciidoc[] | ||
|
||
include::painless-operators-array.asciidoc[] | ||
|
||
include::painless-statements.asciidoc[] | ||
|
||
include::painless-scripts.asciidoc[] | ||
|
||
include::painless-functions.asciidoc[] | ||
|
||
include::painless-lambdas.asciidoc[] | ||
|
||
include::painless-regexes.asciidoc[] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
[[modules-scripting-painless]] | ||
=== Painless Scripting Language | ||
|
||
include::../../../painless/painless-description.asciidoc[] | ||
_Painless_ is a simple, secure scripting language designed specifically for use | ||
with Elasticsearch. It is the default scripting language for Elasticsearch and | ||
can safely be used for inline and stored scripts. To get started with | ||
Painless, see the {painless}/painless-guide.html[Painless Guide]. For a | ||
detailed description of the Painless syntax and language features, see the | ||
{painless}/painless-lang-spec.html[Painless Language Specification]. | ||
|
||
Ready to start scripting with Painless? See {painless}/painless-getting-started.html[Getting Started with Painless] in the guide to the | ||
[[painless-features]] | ||
You can use Painless anywhere scripts can be used in Elasticsearch. Painless | ||
provides: | ||
|
||
* Fast performance: Painless scripts https://benchmarks.elastic.co/index.html#search_qps_scripts[ | ||
run several times faster] than the alternatives. | ||
|
||
* Safety: Fine-grained whitelist with method call/field granularity. See the | ||
{painless}/painless-api-reference.html[Painless API Reference] for a | ||
complete list of available classes and methods. | ||
|
||
* Optional typing: Variables and parameters can use explicit types or the | ||
dynamic `def` type. | ||
|
||
* Syntax: Extends a subset of Java's syntax to provide additional scripting | ||
language features. | ||
|
||
* Optimizations: Designed specifically for Elasticsearch scripting. | ||
|
||
Ready to start scripting with Painless? See the | ||
{painless}/painless-guide.html[Painless Guide] for the | ||
{painless}/index.html[Painless Scripting Language]. |