public class QueryOptions extends Object
Modifier and Type | Field and Description |
---|---|
static ConsistencyLevel |
DEFAULT_CONSISTENCY_LEVEL
The default consistency level for queries:
ConsistencyLevel.ONE . |
static int |
DEFAULT_FETCH_SIZE
The default fetch size for SELECT queries: 5000.
|
static boolean |
DEFAULT_IDEMPOTENCE
The default value for
getDefaultIdempotence() : false . |
static ConsistencyLevel |
DEFAULT_SERIAL_CONSISTENCY_LEVEL
The default serial consistency level for conditional updates:
ConsistencyLevel.SERIAL . |
Constructor and Description |
---|
QueryOptions()
Creates a new
QueryOptions instance using the DEFAULT_CONSISTENCY_LEVEL ,
DEFAULT_SERIAL_CONSISTENCY_LEVEL and DEFAULT_FETCH_SIZE . |
Modifier and Type | Method and Description |
---|---|
ConsistencyLevel |
getConsistencyLevel()
The default consistency level used by queries.
|
boolean |
getDefaultIdempotence()
The default idempotence for queries.
|
int |
getFetchSize()
The default fetch size used by queries.
|
ConsistencyLevel |
getSerialConsistencyLevel()
The default serial consistency level used by queries.
|
QueryOptions |
setConsistencyLevel(ConsistencyLevel consistencyLevel)
Sets the default consistency level to use for queries.
|
QueryOptions |
setDefaultIdempotence(boolean defaultIdempotence)
Sets the default idempotence for queries.
|
QueryOptions |
setFetchSize(int fetchSize)
Sets the default fetch size to use for SELECT queries.
|
QueryOptions |
setSerialConsistencyLevel(ConsistencyLevel serialConsistencyLevel)
Sets the default serial consistency level to use for queries.
|
public static final ConsistencyLevel DEFAULT_CONSISTENCY_LEVEL
ConsistencyLevel.ONE
.public static final ConsistencyLevel DEFAULT_SERIAL_CONSISTENCY_LEVEL
ConsistencyLevel.SERIAL
.public static final int DEFAULT_FETCH_SIZE
public static final boolean DEFAULT_IDEMPOTENCE
getDefaultIdempotence()
: false
.public QueryOptions()
QueryOptions
instance using the DEFAULT_CONSISTENCY_LEVEL
,
DEFAULT_SERIAL_CONSISTENCY_LEVEL
and DEFAULT_FETCH_SIZE
.public QueryOptions setConsistencyLevel(ConsistencyLevel consistencyLevel)
The consistency level set through this method will be use for queries
that don't explicitly have a consistency level, i.e. when Statement.getConsistencyLevel()
returns null
.
consistencyLevel
- the new consistency level to set as default.QueryOptions
instance.public ConsistencyLevel getConsistencyLevel()
public QueryOptions setSerialConsistencyLevel(ConsistencyLevel serialConsistencyLevel)
The serial consistency level set through this method will be use for queries
that don't explicitly have a serial consistency level, i.e. when Statement.getSerialConsistencyLevel()
returns null
.
serialConsistencyLevel
- the new serial consistency level to set as default.QueryOptions
instance.public ConsistencyLevel getSerialConsistencyLevel()
public QueryOptions setFetchSize(int fetchSize)
The fetch size set through this method will be use for queries
that don't explicitly have a fetch size, i.e. when Statement.getFetchSize()
is less or equal to 0.
fetchSize
- the new fetch size to set as default. It must be
strictly positive but you can use Integer.MAX_VALUE
to disable
paging.QueryOptions
instance.IllegalArgumentException
- if fetchSize <e; 0
.UnsupportedFeatureException
- if version 1 of the native protocol is in
use and fetchSize != Integer.MAX_VALUE
as paging is not supported by
version 1 of the protocol. See Cluster.Builder.withProtocolVersion(com.datastax.driver.core.ProtocolVersion)
for more details on protocol versions.public int getFetchSize()
public QueryOptions setDefaultIdempotence(boolean defaultIdempotence)
This will be used for statements for which Statement.isIdempotent()
returns null
.
defaultIdempotence
- the new value to set as default idempotence.QueryOptions
instance.public boolean getDefaultIdempotence()
It defaults to DEFAULT_IDEMPOTENCE
.
Copyright © 2012–2015. All rights reserved.