@Immutable public class DefaultScriptGraphStatement extends GraphStatementBase<ScriptGraphStatement> implements ScriptGraphStatement
ASYNC, SYNC
Constructor and Description |
---|
DefaultScriptGraphStatement(String script,
Map<String,Object> queryParams,
Boolean isSystemQuery,
Boolean isIdempotent,
Duration timeout,
com.datastax.oss.driver.api.core.metadata.Node node,
long timestamp,
com.datastax.oss.driver.api.core.config.DriverExecutionProfile executionProfile,
String executionProfileName,
Map<String,ByteBuffer> customPayload,
String graphName,
String traversalSource,
String subProtocol,
com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel,
com.datastax.oss.driver.api.core.ConsistencyLevel readConsistencyLevel,
com.datastax.oss.driver.api.core.ConsistencyLevel writeConsistencyLevel) |
Modifier and Type | Method and Description |
---|---|
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. |
protected ScriptGraphStatement |
newInstance(Boolean isIdempotent,
Duration timeout,
com.datastax.oss.driver.api.core.metadata.Node node,
long timestamp,
com.datastax.oss.driver.api.core.config.DriverExecutionProfile executionProfile,
String executionProfileName,
Map<String,ByteBuffer> customPayload,
String graphName,
String traversalSource,
String subProtocol,
com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel,
com.datastax.oss.driver.api.core.ConsistencyLevel readConsistencyLevel,
com.datastax.oss.driver.api.core.ConsistencyLevel writeConsistencyLevel) |
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, getCustomPayload, getExecutionProfile, getExecutionProfileName, getGraphName, getNode, getReadConsistencyLevel, getSubProtocol, getTimeout, getTimestamp, getTraversalSource, getWriteConsistencyLevel, isIdempotent, setConsistencyLevel, setCustomPayload, setExecutionProfile, setExecutionProfileName, setGraphName, setIdempotent, setNode, setReadConsistencyLevel, setSubProtocol, setTimeout, setTimestamp, setTraversalSource, setWriteConsistencyLevel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, builder, newInstance
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
public DefaultScriptGraphStatement(String script, Map<String,Object> queryParams, Boolean isSystemQuery, Boolean isIdempotent, Duration timeout, com.datastax.oss.driver.api.core.metadata.Node node, long timestamp, com.datastax.oss.driver.api.core.config.DriverExecutionProfile executionProfile, String executionProfileName, Map<String,ByteBuffer> customPayload, String graphName, String traversalSource, String subProtocol, com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel, com.datastax.oss.driver.api.core.ConsistencyLevel readConsistencyLevel, com.datastax.oss.driver.api.core.ConsistencyLevel writeConsistencyLevel)
@NonNull public String getScript()
ScriptGraphStatement
getScript
in interface ScriptGraphStatement
@NonNull public ScriptGraphStatement setSystemQuery(@Nullable Boolean newValue)
ScriptGraphStatement
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.
setSystemQuery
in interface ScriptGraphStatement
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.ScriptGraphStatement.isSystemQuery()
@Nullable public Boolean isSystemQuery()
ScriptGraphStatement
null
if it defaults to the value defined in
the configuration.isSystemQuery
in interface ScriptGraphStatement
ScriptGraphStatement.setSystemQuery(Boolean)
@NonNull public Map<String,Object> getQueryParams()
ScriptGraphStatement
getQueryParams
in interface ScriptGraphStatement
ScriptGraphStatement.setQueryParam(String, Object)
@NonNull public ScriptGraphStatement setQueryParam(@NonNull String name, @Nullable Object value)
ScriptGraphStatement
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
ScriptGraphStatement.builder(String)
instead.
setQueryParam
in interface ScriptGraphStatement
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 public ScriptGraphStatement removeQueryParam(@NonNull String name)
ScriptGraphStatement
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).
removeQueryParam
in interface ScriptGraphStatement
ScriptGraphStatement.setQueryParam(String, Object)
protected ScriptGraphStatement newInstance(Boolean isIdempotent, Duration timeout, com.datastax.oss.driver.api.core.metadata.Node node, long timestamp, com.datastax.oss.driver.api.core.config.DriverExecutionProfile executionProfile, String executionProfileName, Map<String,ByteBuffer> customPayload, String graphName, String traversalSource, String subProtocol, com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel, com.datastax.oss.driver.api.core.ConsistencyLevel readConsistencyLevel, com.datastax.oss.driver.api.core.ConsistencyLevel writeConsistencyLevel)
newInstance
in class GraphStatementBase<ScriptGraphStatement>
Copyright © 2017–2019. All rights reserved.