public static class CQLSSTableWriter.Builder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected SSTableFormat.Type |
formatType |
Modifier | Constructor and Description |
---|---|
protected |
Builder() |
Modifier and Type | Method and Description |
---|---|
CQLSSTableWriter |
build() |
CQLSSTableWriter.Builder |
forTable(java.lang.String schema)
The schema (CREATE TABLE statement) for the table for which sstable are to be created.
|
CQLSSTableWriter.Builder |
inDirectory(java.io.File directory)
The directory where to write the sstables (mandatory option).
|
CQLSSTableWriter.Builder |
inDirectory(java.lang.String directory)
The directory where to write the sstables.
|
CQLSSTableWriter.Builder |
openSSTableOnProduced()
Whether the produced sstable should be open or not.
|
CQLSSTableWriter.Builder |
sorted()
Creates a CQLSSTableWriter that expects sorted inputs.
|
CQLSSTableWriter.Builder |
using(java.lang.String insert)
The INSERT or UPDATE statement defining the order of the values to add for a given CQL row.
|
CQLSSTableWriter.Builder |
withBufferSizeInMB(int size)
Deprecated.
This method is deprecated in favor of the new withMaxSSTableSizeInMiB(int size)
|
CQLSSTableWriter.Builder |
withMaxSSTableSizeInMiB(int size)
Defines the maximum SSTable size in mebibytes when using the sorted writer.
|
CQLSSTableWriter.Builder |
withPartitioner(IPartitioner partitioner)
The partitioner to use.
|
CQLSSTableWriter.Builder |
withSSTableProducedListener(java.util.function.Consumer<java.util.Collection<SSTableReader>> sstableProducedListener)
Set the listener to receive notifications on sstable produced
|
CQLSSTableWriter.Builder |
withType(java.lang.String typeDefinition) |
protected SSTableFormat.Type formatType
public CQLSSTableWriter.Builder inDirectory(java.lang.String directory)
This is a mandatory option.
directory
- the directory to use, which should exists and be writable.java.lang.IllegalArgumentException
- if directory
doesn't exist or is not writable.public CQLSSTableWriter.Builder inDirectory(java.io.File directory)
This is a mandatory option.
directory
- the directory to use, which should exists and be writable.java.lang.IllegalArgumentException
- if directory
doesn't exist or is not writable.public CQLSSTableWriter.Builder withType(java.lang.String typeDefinition) throws SyntaxException
SyntaxException
public CQLSSTableWriter.Builder forTable(java.lang.String schema)
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.
schema
- the schema of the table for which sstables are to be created.java.lang.IllegalArgumentException
- if schema
is not a valid CREATE TABLE statement
or does not have a fully-qualified table name.public CQLSSTableWriter.Builder withPartitioner(IPartitioner partitioner)
By default, Murmur3Partitioner
will 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.
partitioner
- the partitioner to use.public CQLSSTableWriter.Builder using(java.lang.String insert)
Please note that the provided INSERT 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.
insert
- an insertion statement that defines the order
of column values to use.java.lang.IllegalArgumentException
- if insertStatement
is not a valid insertion
statement, does not have a fully-qualified table name or have no bind variables.public CQLSSTableWriter.Builder withMaxSSTableSizeInMiB(int size)
size
- the maximum sizein mebibytes of each individual SSTable allowed@Deprecated public CQLSSTableWriter.Builder withBufferSizeInMB(int size)
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 128MB, which should be reasonable for a 1GB heap. If you experience OOM while using the writer, you should lower this value.
size
- the size to use in MB.public CQLSSTableWriter.Builder sorted()
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 insertion). 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 withBufferSizeInMB will be ignored.
public CQLSSTableWriter.Builder withSSTableProducedListener(java.util.function.Consumer<java.util.Collection<SSTableReader>> sstableProducedListener)
Note that if listener is registered, the sstables are opened into SSTableReader
.
The consumer is responsible for releasing the SSTableReader
sstableProducedListener
- receives the produced sstablespublic CQLSSTableWriter.Builder openSSTableOnProduced()
public CQLSSTableWriter build()
Copyright © 2009- The Apache Software Foundation