public interface ScriptGraphStatement extends GraphStatement<ScriptGraphStatement>
These statements are generally used for DSE Graph set-up queries, such as creating or dropping
a graph, or defining a graph schema. For graph traversals, we recommend using FluentGraphStatement
instead. To do bulk data ingestion in graph, we recommend using BatchGraphStatement
instead.
Typical usage:
ScriptGraphStatement statement = ScriptGraphStatement.newInstance("schema.propertyKey('age').Int().create()");
GraphResultSet graphResultSet = dseSession.execute(statement);
ASYNC, SYNC
Modifier and Type | Method and Description |
---|---|
static ScriptGraphStatementBuilder |
builder(ScriptGraphStatement template)
Create a builder helper object to start creating a new instance with an existing statement as a
template.
|
static ScriptGraphStatementBuilder |
builder(String script)
Create a builder object to start creating a new instance from the given script.
|
Map<String,Object> |
getQueryParams()
The query parameters to send along the request.
|
String |
getScript()
The Gremlin-groovy script representing the graph query.
|
Boolean |
isSystemQuery()
Whether the statement is a system query, or
null if it defaults to the value defined in
the configuration. |
static ScriptGraphStatement |
newInstance(String script)
Create a new instance from the given script.
|
ScriptGraphStatement |
removeQueryParam(String name)
Removes a binding for the given name from this statement.
|
ScriptGraphStatement |
setQueryParam(String name,
Object value)
Set a value for a parameter defined in the Groovy script.
|
ScriptGraphStatement |
setSystemQuery(Boolean newValue)
Defines if this statement is a system query.
|
getConsistencyLevel, getGraphName, getKeyspace, getReadConsistencyLevel, getRoutingKey, getRoutingKeyspace, getRoutingToken, getSubProtocol, getTimeout, getTimestamp, getTraversalSource, getWriteConsistencyLevel, isTracing, setConsistencyLevel, setCustomPayload, setExecutionProfile, setExecutionProfileName, setGraphName, setIdempotent, setNode, setReadConsistencyLevel, setSubProtocol, setTimeout, setTimestamp, setTraversalSource, setWriteConsistencyLevel
getCustomPayload, getExecutionProfile, getExecutionProfileName, getNode, getPartitioner, isIdempotent
@NonNull static ScriptGraphStatement newInstance(@NonNull String script)
@NonNull static ScriptGraphStatementBuilder builder(@NonNull String script)
Note that this builder is mutable and not thread-safe.
@NonNull static ScriptGraphStatementBuilder builder(@NonNull ScriptGraphStatement template)
Note that this builder is mutable and not thread-safe.
@NonNull String getScript()
@Nullable Boolean isSystemQuery()
null
if it defaults to the value defined in
the configuration.setSystemQuery(Boolean)
@NonNull ScriptGraphStatement setSystemQuery(@Nullable Boolean newValue)
Script statements that access the system
variable must not specify a graph
name (otherwise system
is not available). However, if your application executes a lot
of non-system statements, it is convenient to configure the graph name in your configuration to
avoid repeating it every time. This method allows you to ignore that global graph name for a
specific statement.
This property is the programmatic equivalent of the configuration option basic.graph.is-system-query
, and takes precedence over it. That is, if this property is
non-null, then the configuration will be ignored.
The driver's built-in implementation is immutable, and returns a new instance from this method. However custom implementations may choose to be mutable and return the same instance.
newValue
- true
to mark this statement as a system query (the driver will ignore
any graph name set on the statement or the configuration); false
to mark it as a
non-system query; null
to default to the value defined in the configuration.isSystemQuery()
@NonNull Map<String,Object> getQueryParams()
setQueryParam(String, Object)
@NonNull ScriptGraphStatement setQueryParam(@NonNull String name, @Nullable Object value)
The script engine in the DSE Graph server allows to define parameters in a Groovy script and
set the values of these parameters as a binding. Defining parameters allows to re-use scripts
and only change their parameters values, which improves the performance of the script executed,
so defining parameters is encouraged; however, for optimal Graph traversal performance, we
recommend either using BatchGraphStatement
s for data ingestion, or FluentGraphStatement
for normal traversals.
Parameters in a Groovy script are always named; unlike CQL, they are not prefixed by a
column (:
).
The driver's built-in implementation is immutable, and returns a new instance from this
method. However custom implementations may choose to be mutable and return the same instance.
If many parameters are to be set in a query, it is recommended to create the statement with
builder(String)
instead.
name
- the name of the parameter defined in the script. If the statement already had a
binding for this name, it gets replaced.value
- the value that will be transmitted with the request.@NonNull ScriptGraphStatement removeQueryParam(@NonNull String name)
If the statement did not have such a binding, this method has no effect and returns the same statement instance. Otherwise, the driver's built-in implementation returns a new instance (however custom implementations may choose to be mutable and return the same instance).
setQueryParam(String, Object)
Copyright © 2017–2024. All rights reserved.