[
https://issues.apache.org/jira/browse/TINKERPOP-2959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901073#comment-17901073
]
ASF GitHub Bot commented on TINKERPOP-2959:
-------------------------------------------
Cole-Greer opened a new pull request, #2919:
URL: https://github.com/apache/tinkerpop/pull/2919
https://issues.apache.org/jira/browse/TINKERPOP-2959
The parameterization which was added to gremlin-lang in 3.7 has a key
limitation as a result of all variables directly resolving to literals as the
script is parsed. As such, the existing parameterization does not allow for any
optimizations from caching recurring query plans, as may be seen with
gremlin-groovy. The primary benefits of the existing parameterization is to
offer users additional flexibility and to increase similarity between
gremlin-lang and gremlin-groovy.
This work extends parameterization beyond gremlin-lang to enable
optimizations in cases of users executing repetitive query patterns. To
accomplish this, a new class `GValue` is introduced which wraps a parameter
name and value. Steps which will benefit from parameterization have been given
overloads to accept `GValue`'s. Users can pass GValue's into their traversals
to inject parameters. When using the new `DefaultVariableResolver`, the grammar
will now resolve variables into GValue which are passed to the constructed
traversal, instead of directly resolving them to literals. The old variable
resolution behavior can still be obtained via the `DirectVariableResolver`.
As GValue has only been explicitly added in places where parameterization is
expected to be useful, a corresponding change has been made to the grammar only
allow variables in places which will take a GValue.
> Allow the grammar to support parameters
> ---------------------------------------
>
> Key: TINKERPOP-2959
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2959
> Project: TinkerPop
> Issue Type: Improvement
> Components: language
> Affects Versions: 3.6.4
> Reporter: Stephen Mallette
> Assignee: Stephen Mallette
> Priority: Major
> Fix For: 3.7.0
>
>
> Allow the grammar to support parameters similar to how the groovy engine does
> like, {{g.inject(x,y,z)}}. Doing this will make it easier for a transition
> away from the groovy engine as a lot of Gremlin in the world today uses
> parameters. The grammar may have to come with some limitations though as
> groovy is wide open in terms of what can be treated as a variable. Probably
> going to keep parameters tied to primitives, collections and tokens/enums
> like {{Order}} and {{Scope}}. Collections themselves will not contain
> parameters and things like a {{Traversal}} or {{P}} cannot be treated as one.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)