public class Batch extends BuiltStatement
Modifier and Type | Class and Description |
---|---|
static class |
Batch.Options
The options of a BATCH statement.
|
idempotent, NULL_PAYLOAD_VALUE
Modifier and Type | Method and Description |
---|---|
Batch |
add(RegularStatement statement)
Adds a new statement to this batch.
|
String |
getKeyspace()
Returns the keyspace of the first statement in this batch.
|
ByteBuffer |
getRoutingKey(ProtocolVersion protocolVersion,
CodecRegistry codecRegistry)
Returns the first non-null routing key of the statements in this batch or null otherwise.
|
ByteBuffer[] |
getValues(ProtocolVersion protocolVersion,
CodecRegistry codecRegistry)
The positional values to use for this statement.
|
Boolean |
isIdempotent()
Whether this statement is idempotent, i.e.
|
Batch.Options |
using(Using using)
Adds a new options for this BATCH statement.
|
escapeId, getNamedValues, getObject, getObject, getQueryString, hasValues, setForceNoValues, toString, usesNamedValues
getQueryString, hasValues, requestSizeInBytes
disableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getHost, getLastHost, getNowInSeconds, getOutgoingPayload, getPartitioner, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, isBatchIdempotent, isLWT, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setHost, setIdempotent, setLastHost, setNowInSeconds, setOutgoingPayload, setPagingState, setPagingState, setPagingStateUnsafe, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel
public Batch add(RegularStatement statement)
statement
- the new statement to add.IllegalArgumentException
- if counter and non-counter operations are mixed.public ByteBuffer[] getValues(ProtocolVersion protocolVersion, CodecRegistry codecRegistry)
RegularStatement
A statement can use either positional or named values, but not both. So if this method
returns a non-null result, RegularStatement.getNamedValues(ProtocolVersion, CodecRegistry)
will return
null
.
Values for a RegularStatement (i.e. if either method does not return null
) are not
supported with the native protocol version 1: you will get an UnsupportedProtocolVersionException
when submitting one if version 1 of the protocol is in use
(i.e. if you've forced version 1 through Cluster.Builder.withProtocolVersion(com.datastax.driver.core.ProtocolVersion)
or you use
Cassandra 1.2).
getValues
in class BuiltStatement
protocolVersion
- the protocol version that will be used to serialize the values.codecRegistry
- the codec registry that will be used to serialize the values.SimpleStatement(String, Object...)
public Batch.Options using(Using using)
using
- the option to add.public ByteBuffer getRoutingKey(ProtocolVersion protocolVersion, CodecRegistry codecRegistry)
getRoutingKey
in class BuiltStatement
protocolVersion
- the protocol version that will be used if the actual implementation
needs to serialize something to compute the key.codecRegistry
- the codec registry that will be used if the actual implementation needs to
serialize something to compute this key.public String getKeyspace()
getKeyspace
in class BuiltStatement
public Boolean isIdempotent()
Statement
If a statement is not idempotent, the driver will ensure that it never gets executed more than once, which means:
retries
on write timeouts or request errors;
speculative executions
.
Note that this method can return null
, in which case the driver will default to
QueryOptions.getDefaultIdempotence()
.
By default, this method returns null
for all statements, except for
BuiltStatement
- value will be inferred from the query: if it updates counters,
prepends/appends to a list, or uses a function call or QueryBuilder.raw(String)
anywhere in an inserted
value, the result will be false
; otherwise it will be true
.
Batch
and BatchStatement
:
Statement.setIdempotent(boolean)
forces a value that overrides calculated
value.
Note that when a statement is prepared (Session.prepare(String)
), its idempotence
flag will be propagated to all PreparedStatement
s created from it.
isIdempotent
in class BuiltStatement
null
to use QueryOptions.getDefaultIdempotence()
.Copyright © 2012–2024. All rights reserved.