forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripting: Converters can adapt return values
Add ability to explicitly coerce the return value from a script. Runtime fields want to avoid returning `Object` from the execute method in each context. Instead, they will return an array of primitive objects, such as `long[]`. However, it's convenient to allow a user to return a single primitive type rather than allocating a length-one array. To achieve this, an implementer can add explicit conversion functions to a context with signature: `public static <context-return-value> convertFrom<Suffix>(<any type>)` When a user returns a type other than the context return value, at compile-time, painless will insert a call to their `convertFrom` method. This commit is Phase 1 of this work. It handles explicit converters for all painless types EXCEPT def type. Refs: elastic#59647
- Loading branch information
1 parent
1c6ffb6
commit 03cf8a6
Showing
1 changed file
with
54 additions
and
4 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