Class CQLSSTableWriter.Builder
- Enclosing class:
- CQLSSTableWriter
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()The schema (CREATE TABLE statement) for the table for which sstable are to be created.inDirectory(String directory) The directory where to write the sstables.inDirectory(File directory) The directory where to write the sstables (mandatory option).Whether the produced sstable should be open or not.sorted()Creates a CQLSSTableWriter that expects sorted inputs.The INSERT, UPDATE, or DELETE statement defining the order of the values to add for a given CQL row.withBufferSizeInMB(int size) Deprecated.This method is deprecated in favor of the new withBufferSizeInMiB(int size).withBufferSizeInMiB(int size) Deprecated.This method is deprecated in favor of the new withMaxSSTableSizeInMiB(int size)withBuildIndexes(boolean buildIndexes) Whether indexes should be built and serialized to disk along data.withFormat(SSTableFormat<?, ?> format) Specifies the SSTable format this CQLSSTableWriter instance should use for writing.withIndexes(String... indexes) The schema (CREATE INDEX statement) for index to be created for the table.withMaxSSTableSizeInMiB(int size) Defines the maximum SSTable size in mebibytes when using the sorted writer.withPartitioner(IPartitioner partitioner) The partitioner to use.withSSTableProducedListener(Consumer<Collection<SSTableReader>> sstableProducedListener) Set the listener to receive notifications on sstable produced
-
Field Details
-
format
-
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
inDirectory
The directory where to write the sstables.This is a mandatory option.
- Parameters:
directory- the directory to use, which should exists and be writable.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifdirectorydoesn't exist or is not writable.
-
inDirectory
The directory where to write the sstables (mandatory option).This is a mandatory option.
- Parameters:
directory- the directory to use, which should exists and be writable.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifdirectorydoesn't exist or is not writable.
-
withType
- Throws:
SyntaxException
-
forTable
The schema (CREATE TABLE statement) for the table for which sstable are to be created.Please note that the provided CREATE TABLE statement must use a fully-qualified table name, one that include the keyspace name.
This is a mandatory option.
- Parameters:
schema- the schema of the table for which sstables are to be created.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifschemais not a valid CREATE TABLE statement or does not have a fully-qualified table name.
-
withIndexes
The schema (CREATE INDEX statement) for index to be created for the table. Only SAI indexes are supported.- Parameters:
indexes- CQL statements representing SAI indexes to be created.- Returns:
- this builder
-
withPartitioner
The partitioner to use.By default,
Murmur3Partitionerwill be used. If this is not the partitioner used by the cluster for which the SSTables are created, you need to use this method to provide the correct partitioner.- Parameters:
partitioner- the partitioner to use.- Returns:
- this builder.
-
using
The INSERT, UPDATE, or DELETE statement defining the order of the values to add for a given CQL row.Please note that the provided statement must use a fully-qualified table name, one that include the keyspace name. Moreover, said statement must use bind variables since these variables will be bound to values by the resulting writer.
This is a mandatory option.
- Parameters:
modificationStatement- an insert, update, or delete statement that defines the order of column values to use.- Returns:
- this builder.
- Throws:
IllegalArgumentException- ifmodificationStatementis not a valid insert, update, or delete statement, does not have a fully-qualified table name or have no bind variables.
-
withMaxSSTableSizeInMiB
Defines the maximum SSTable size in mebibytes when using the sorted writer. By default, i.e. not specified, there is no maximum size limit for the produced SSTable- Parameters:
size- the maximum sizein mebibytes of each individual SSTable allowed- Returns:
- this builder
-
withBufferSizeInMiB
Deprecated.This method is deprecated in favor of the new withMaxSSTableSizeInMiB(int size)The size of the buffer to use.This defines how much data will be buffered before being written as a new SSTable. This corresponds roughly to the data size that will have the created sstable.
The default is 128MiB, which should be reasonable for a 1GiB heap. If you experience OOM while using the writer, you should lower this value.
- Parameters:
size- the size to use in MiB.- Returns:
- this builder.
-
withBufferSizeInMB
Deprecated.This method is deprecated in favor of the new withBufferSizeInMiB(int size). See CASSANDRA-17675The size of the buffer to use.This defines how much data will be buffered before being written as a new SSTable. This corresponds roughly to the data size that will have the created sstable.
The default is 128MiB, which should be reasonable for a 1GiB heap. If you experience OOM while using the writer, you should lower this value.
- Parameters:
size- the size to use in MiB.- Returns:
- this builder.
-
sorted
Creates a CQLSSTableWriter that expects sorted inputs.If this option is used, the resulting writer will expect rows to be added in SSTable sorted order (and an exception will be thrown if that is not the case during modification). The SSTable sorted order means that rows are added such that their partition key respect the partitioner order.
You should thus only use this option is you know that you can provide the rows in order, which is rarely the case. If you can provide the rows in order however, using this sorted might be more efficient.
Note that if used, some option like withBufferSizeInMiB will be ignored.
- Returns:
- this builder.
-
withBuildIndexes
Whether indexes should be built and serialized to disk along data. Defaults to true.- Parameters:
buildIndexes- true if indexes should be built, false otherwise- Returns:
- this builder
-
withSSTableProducedListener
public CQLSSTableWriter.Builder withSSTableProducedListener(Consumer<Collection<SSTableReader>> sstableProducedListener) Set the listener to receive notifications on sstable producedNote that if listener is registered, the sstables are opened into
SSTableReader. The consumer is responsible for releasing theSSTableReader- Parameters:
sstableProducedListener- receives the produced sstables- Returns:
- this builder
-
withFormat
Specifies the SSTable format this CQLSSTableWriter instance should use for writing.- Parameters:
format- The format to use- Returns:
- this builder
-
openSSTableOnProduced
Whether the produced sstable should be open or not. By default, the writer does not open the produced sstables- Returns:
- this builder
-
build
-