Class CQLSSTableWriter.Builder

  • Enclosing class:
    CQLSSTableWriter

    public static class CQLSSTableWriter.Builder
    extends java.lang.Object
    A Builder for a CQLSSTableWriter object.
    • Constructor Detail

      • Builder

        protected Builder()
    • Method Detail

      • inDirectory

        public CQLSSTableWriter.Builder inDirectory​(java.lang.String directory)
        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:
        java.lang.IllegalArgumentException - if directory doesn't exist or is not writable.
      • inDirectory

        public CQLSSTableWriter.Builder inDirectory​(File directory)
        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:
        java.lang.IllegalArgumentException - if directory doesn't exist or is not writable.
      • forTable

        public CQLSSTableWriter.Builder forTable​(java.lang.String schema)
        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:
        java.lang.IllegalArgumentException - if schema is not a valid CREATE TABLE statement or does not have a fully-qualified table name.
      • withIndexes

        public CQLSSTableWriter.Builder withIndexes​(java.lang.String... indexes)
        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

        public CQLSSTableWriter.Builder withPartitioner​(IPartitioner partitioner)
        The partitioner to use.

        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.

        Parameters:
        partitioner - the partitioner to use.
        Returns:
        this builder.
      • using

        public CQLSSTableWriter.Builder using​(java.lang.String modificationStatement)
        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:
        java.lang.IllegalArgumentException - if modificationStatement is not a valid insert, update, or delete statement, does not have a fully-qualified table name or have no bind variables.
      • withMaxSSTableSizeInMiB

        public CQLSSTableWriter.Builder withMaxSSTableSizeInMiB​(int size)
        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(since="5.0")
        public CQLSSTableWriter.Builder withBufferSizeInMiB​(int size)
        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(since="4.1")
        public CQLSSTableWriter.Builder withBufferSizeInMB​(int size)
        Deprecated.
        This method is deprecated in favor of the new withBufferSizeInMiB(int size). See CASSANDRA-17675
        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.
      • sorted

        public CQLSSTableWriter.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

        public CQLSSTableWriter.Builder withBuildIndexes​(boolean buildIndexes)
        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