Class TableOptions<T extends TableOptions>
- java.lang.Object
-
- com.datastax.driver.core.Statement
-
- com.datastax.driver.core.RegularStatement
-
- com.datastax.driver.core.schemabuilder.SchemaStatement
-
- com.datastax.driver.core.schemabuilder.TableOptions<T>
-
- Type Parameters:
T- the concrete sub-class ofTableOptions
- Direct Known Subclasses:
Alter.Options,Create.Options
public abstract class TableOptions<T extends TableOptions> extends SchemaStatement
The table options used in a CREATE TABLE or ALTER TABLE statement.Implementation notes: this class is abstract and not meant to use directly. The type parameter
Tallows usage of covariant return type and makes the builder pattern work for different sub-classes.- See Also:
- details on table options
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTableOptions.AdditionalWritePolicyValueAdditional Write Policy.static classTableOptions.CachingRowsPerPartitionDefine the number of rows to be cached per partition when row caching is enabled (this feature is only applicable to Cassandra 2.1.x).static classTableOptions.CompactionOptions<T extends TableOptions.CompactionOptions>Compaction options for a CREATE or ALTER TABLE statement.static classTableOptions.CompressionOptionsThe compression options for a CREATE or ALTER TABLE statement.static classTableOptions.ReadRepairValueRead Repair modes.static classTableOptions.SpeculativeRetryValueThe speculative retry options.
-
Field Summary
-
Fields inherited from class com.datastax.driver.core.Statement
idempotent, NULL_PAYLOAD_VALUE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TadditionalWritePolicy(TableOptions.AdditionalWritePolicyValue additionalWritePolicy)Define the additional_write_policy for this table.protected abstract voidaddSpecificOptions(List<String> options)TbloomFilterFPChance(Double fpChance)Define the desired false-positive probability for SSTable Bloom filters.StringbuildInternal()Tcaching(SchemaBuilder.Caching caching)Define the caching type for Cassandra 2.0.x.Tcaching(SchemaBuilder.KeyCaching keys, TableOptions.CachingRowsPerPartition rowsPerPartition)Define the caching options for Cassandra 2.1.x.Tcdc(Boolean cdc)Define whether or not change data capture is enabled on this table.Tcomment(String comment)Define a human readable comment describing the table.TcompactionOptions(TableOptions.CompactionOptions compactionOptions)Define the compaction options.TcompressionOptions(TableOptions.CompressionOptions compressionOptions)Define the compression options.TdcLocalReadRepairChance(Double dcLocalReadRepairChance)Define the probability of read repairs being invoked over all replicas in the current data center.TdefaultTimeToLive(Integer defaultTimeToLive)Define the default expiration time in seconds for a table.TfreeformOption(String key, Object value)Define a free-form option as a key/value pair.TgcGraceSeconds(Integer gcGraceSeconds)Define the time to wait before garbage collecting tombstones (deletion markers).TindexInterval(Integer indexInterval)Define the index interval for Cassandra 2.0.TmaxIndexInterval(Integer maxIndexInterval)Define the maximum index interval for Cassandra 2.1.TmaxReadsPerSecond(int maxReadsPerSecond)Sets rate limit for read operations in table option "per_partition_rate_limit".TmaxWritesPerSecond(int maxWritesPerSecond)Sets rate limit for write operations in table option "per_partition_rate_limit".TmemtableFlushPeriodInMillis(Integer memtableFlushPeriodInMillis)Define the memtable flush period.TminIndexInterval(Integer minIndexInterval)Define the minimum index interval for Cassandra 2.1.TpopulateIOCacheOnFlush(Boolean populateIOOnCacheFlush)Define whether to populate IO cache on flush of sstables.TreadRepair(TableOptions.ReadRepairValue readRepair)Define the read_repair mode for this table.TreadRepairChance(Double readRepairChance)Define the probability with which read repairs should be invoked on non-quorum reads.TreplicateOnWrite(Boolean replicateOnWrite)Define whether to replicate data on write (Cassandra 2.0.x only).TspeculativeRetry(TableOptions.SpeculativeRetryValue speculativeRetry)To override normal read timeout when read_repair_chance is not 1.0, sending another request to read, choose one of these values and use the property to create or alter the table: ALWAYS: Retry reads of all replicas.-
Methods inherited from class com.datastax.driver.core.schemabuilder.SchemaStatement
getKeyspace, getNamedValues, getQueryString, getRoutingKey, getValues, hasValues, usesNamedValues
-
Methods inherited from class com.datastax.driver.core.RegularStatement
getQueryString, hasValues, requestSizeInBytes, toString
-
Methods inherited from class com.datastax.driver.core.Statement
disableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getHost, getLastHost, getNowInSeconds, getOutgoingPayload, getPartitioner, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, isBatchIdempotent, isIdempotent, isLWT, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setHost, setIdempotent, setLastHost, setNowInSeconds, setOutgoingPayload, setPagingState, setPagingState, setPagingStateUnsafe, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel
-
-
-
-
Method Detail
-
caching
public T caching(SchemaBuilder.Caching caching)
Define the caching type for Cassandra 2.0.x.If no call is made to this method, the default value set by Cassandra is
SchemaBuilder.Caching.KEYS_ONLY.- Parameters:
caching- the caching type (all enum values are allowed).- Returns:
- this
TableOptionsobject.
-
caching
public T caching(SchemaBuilder.KeyCaching keys, TableOptions.CachingRowsPerPartition rowsPerPartition)
Define the caching options for Cassandra 2.1.x.If no call is made to this method, the default values set by Cassandra are keys =
SchemaBuilder.Caching.ALLand rows_per_partition =SchemaBuilder.noRows().- Parameters:
keys- the key cache type.rowsPerPartition- defines the number of rows to be cached per partition when Row Caching is enabled. To create instances, useSchemaBuilder.noRows(),SchemaBuilder.allRows()orSchemaBuilder.rows(int).- Returns:
- this
TableOptionsobject.
-
bloomFilterFPChance
public T bloomFilterFPChance(Double fpChance)
Define the desired false-positive probability for SSTable Bloom filters.If no call is made to this method, the default value set by Cassandra is:
- 0.01 for the size-tiered compaction strategy;
- 0.1 for the leveled compaction strategy.
- Parameters:
fpChance- the false positive change. This value should be between 0 and 1.0.- Returns:
- this
TableOptionsobject.
-
comment
public T comment(String comment)
Define a human readable comment describing the table.- Parameters:
comment- the comment.- Returns:
- this
TableOptionsobject.
-
compressionOptions
public T compressionOptions(TableOptions.CompressionOptions compressionOptions)
Define the compression options.If no call is made to this method, the default value set by Cassandra is
SchemaBuilder.lz4().- Parameters:
compressionOptions- the compression options. To create instances, useSchemaBuilder.noCompression(),SchemaBuilder.lz4(),SchemaBuilder.snappy()orSchemaBuilder.deflate().- Returns:
- this
TableOptionsobject.
-
compactionOptions
public T compactionOptions(TableOptions.CompactionOptions compactionOptions)
Define the compaction options.If no call is made to this method, the default value set by Cassandra is
SchemaBuilder.sizedTieredStategy().- Parameters:
compactionOptions- the compaction options. To create instances, useSchemaBuilder.sizedTieredStategy(),SchemaBuilder.leveledStrategy()orSchemaBuilder.dateTieredStrategy()- Returns:
- this
TableOptionsobject.
-
dcLocalReadRepairChance
public T dcLocalReadRepairChance(Double dcLocalReadRepairChance)
Define the probability of read repairs being invoked over all replicas in the current data center.If no call is made to this method, the default value set by Cassandra is 0.0.
- Parameters:
dcLocalReadRepairChance- the probability.- Returns:
- this
TableOptionsobject.
-
defaultTimeToLive
public T defaultTimeToLive(Integer defaultTimeToLive)
Define the default expiration time in seconds for a table.Used in MapReduce/Hive scenarios when you have no control of TTL.
If no call is made to this method, the default value set by Cassandra is 0.
- Parameters:
defaultTimeToLive- the default time to live in seconds for a table.- Returns:
- this
TableOptionsobject.
-
gcGraceSeconds
public T gcGraceSeconds(Integer gcGraceSeconds)
Define the time to wait before garbage collecting tombstones (deletion markers).The default value allows a great deal of time for consistency to be achieved prior to deletion. In many deployments this interval can be reduced, and in a single-node cluster it can be safely set to zero.
If no call is made to this method, the default value set by Cassandra is 864000 secs (10 days).
- Parameters:
gcGraceSeconds- the grace period.- Returns:
- this
TableOptionsobject.
-
indexInterval
public T indexInterval(Integer indexInterval)
Define the index interval for Cassandra 2.0.To control the sampling of entries from the primary row index, configure sample frequency of the partition summary by changing the index interval. After changing the index interval, SSTables are written to disk with new information. The interval corresponds to the number of index entries that are skipped between taking each sample. By default, Cassandra samples one row key out of every 128. The larger the interval, the smaller and less effective the sampling. The larger the sampling, the more effective the index, but with increased memory usage. In Cassandra 2.0.x, generally, the best trade off between memory usage and performance is a value between 128 and 512 in combination with a large table key cache. However, if you have small rows (many to an OS page), you may want to increase the sample size, which often lowers memory usage without an impact on performance. For large rows, decreasing the sample size may improve read performance.
If no call is made to this method, the default value set by Cassandra is 128.
- Parameters:
indexInterval- the index interval.- Returns:
- this
TableOptionsobject.
-
minIndexInterval
public T minIndexInterval(Integer minIndexInterval)
Define the minimum index interval for Cassandra 2.1.If no call is made to this method, the default value set by Cassandra is 128.
- Parameters:
minIndexInterval- the minimum index interval.- Returns:
- this
TableOptionsobject. - See Also:
indexInterval(Integer)
-
maxIndexInterval
public T maxIndexInterval(Integer maxIndexInterval)
Define the maximum index interval for Cassandra 2.1.If no call is made to this method, the default value set by Cassandra is 2048.
- Parameters:
maxIndexInterval- the maximum index interval.- Returns:
- this
TableOptionsobject. - See Also:
indexInterval(Integer)
-
memtableFlushPeriodInMillis
public T memtableFlushPeriodInMillis(Integer memtableFlushPeriodInMillis)
Define the memtable flush period.If set, this forces flushing of the memtable after the specified time elapses.
If no call is made to this method, the default value set by Cassandra is 0.
- Parameters:
memtableFlushPeriodInMillis- the memtable flush period in milliseconds.- Returns:
- this
TableOptionsobject.
-
populateIOCacheOnFlush
public T populateIOCacheOnFlush(Boolean populateIOOnCacheFlush)
Define whether to populate IO cache on flush of sstables.If set, Cassandra adds newly flushed or compacted sstables to the operating system page cache, potentially evicting other cached data to make room. Enable when all data in the table is expected to fit in memory.
If no call is made to this method, the default value set by Cassandra is
false.- Parameters:
populateIOOnCacheFlush- whether to populate IO cache on flush of sstables.- Returns:
- this
TableOptionsobject. - See Also:
- the global option compaction_preheat_key_cache
-
readRepairChance
public T readRepairChance(Double readRepairChance)
Define the probability with which read repairs should be invoked on non-quorum reads. The value must be between 0 and 1.If no call is made to this method, the default value set by Cassandra is 0.1.
- Parameters:
readRepairChance- the read repair chance.- Returns:
- this
TableOptionsobject.
-
replicateOnWrite
public T replicateOnWrite(Boolean replicateOnWrite)
Define whether to replicate data on write (Cassandra 2.0.x only).When set to
true, replicates writes to all affected replicas regardless of the consistency level specified by the client for a write request. For counter tables, this should always be set totrue.If no call is made to this method, the default value set by Cassandra is
true.- Parameters:
replicateOnWrite- whether to replicate data on write.- Returns:
- this
TableOptionsobject.
-
maxReadsPerSecond
public T maxReadsPerSecond(int maxReadsPerSecond)
Sets rate limit for read operations in table option "per_partition_rate_limit". NOTE: Due to ScyllaDB’s distributed nature, tracking per-partition request rates is not perfect and the actual rate of accepted requests may be higher up to a factor of keyspace’s RF. This feature should not be used to enforce precise limits but rather serve as an overload protection feature.- Parameters:
maxReadsPerSecond- rate limit for read operations- Returns:
- this
TableOptionsobject.
-
maxWritesPerSecond
public T maxWritesPerSecond(int maxWritesPerSecond)
Sets rate limit for write operations in table option "per_partition_rate_limit". NOTE: Due to ScyllaDB’s distributed nature, tracking per-partition request rates is not perfect and the actual rate of accepted requests may be higher up to a factor of keyspace’s RF. This feature should not be used to enforce precise limits but rather serve as an overload protection feature.- Parameters:
maxWritesPerSecond- rate limit for write operations- Returns:
- this
TableOptionsobject.
-
speculativeRetry
public T speculativeRetry(TableOptions.SpeculativeRetryValue speculativeRetry)
To override normal read timeout when read_repair_chance is not 1.0, sending another request to read, choose one of these values and use the property to create or alter the table:- ALWAYS: Retry reads of all replicas.
- Xpercentile: Retry reads based on the effect on throughput and latency.
- Yms: Retry reads after specified milliseconds.
- NONE: Do not retry reads.
Using the speculative retry property, you can configure rapid read protection in Cassandra 2.0.2 and later. Use this property to retry a request after some milliseconds have passed or after a percentile of the typical read latency has been reached, which is tracked per table.
If no call is made to this method, the default value set by Cassandra is {code 99percentile}.
- Parameters:
speculativeRetry- the speculative retry. To create instances, useSchemaBuilder.noSpeculativeRetry(),SchemaBuilder.always(),SchemaBuilder.percentile(int)orSchemaBuilder.millisecs(int).- Returns:
- this
TableOptionsobject.
-
cdc
public T cdc(Boolean cdc)
Define whether or not change data capture is enabled on this table.Note that using this option with a version of Apache Cassandra less than 3.8 will raise a syntax error.
If no call is made to this method, the default value set by Cassandra is
false.- Parameters:
cdc- Whether or not change data capture should be enabled for this table.- Returns:
- this
TableOptionsobject.
-
freeformOption
public T freeformOption(String key, Object value)
Define a free-form option as a key/value pair.This method is provided as a fallback if the SchemaBuilder is used with a more recent version of Cassandra that has new, unsupported options.
- Parameters:
key- the name of the option.value- the value of the option. If it's aString, it will be included in single quotes, otherwise the result of invoking itstoStringmethod will be used unquoted.- Returns:
- this
TableOptionsobject.
-
readRepair
public T readRepair(TableOptions.ReadRepairValue readRepair)
Define the read_repair mode for this table. Possible values are:- BLOCKING
- NONE
This option is for Cassandra 4.0+. The default value is
BLOCKING, which means that when a read repair is started, a read will block on writes sent to other replicas until the CL is reached by the writes. This provides monotonic quorum reads, but not partition level write atomicity.If
NONEis specified, the coordinator will reconcile any differences between replicas, but will not attempt to repair them. This provides partition level write atomicity, but not monotonic quorum reads.- Parameters:
readRepair- the read repair mode.- Returns:
- this
TableOptionsobject.
-
additionalWritePolicy
public T additionalWritePolicy(TableOptions.AdditionalWritePolicyValue additionalWritePolicy)
Define the additional_write_policy for this table. This specifies the threshold at which a cheap quorum write will be upgraded to include transient replicas.This option is for Cassandra 4.0+. The default value is "99p".
- Parameters:
additionalWritePolicy- the additional write policy threshold.- Returns:
- this
TableOptionsobject.
-
buildInternal
public final String buildInternal()
-
-