org.apache.cassandra.io.sstable

## Class CQLSSTableWriter.Builder

- java.lang.Object
- - org.apache.cassandra.io.sstable.CQLSSTableWriter.Builder

- Enclosing class:
    CQLSSTableWriter

      public static class CQLSSTableWriter.Builder
      extends java.lang.Object

  A Builder for a CQLSSTableWriter object.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SSTableFormat.Type` | `formatType`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Builder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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` | `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)` The size of the buffer to use.
    `CQLSSTableWriter.Builder` | `withPartitioner(IPartitioner partitioner)` The partitioner to use.
    `CQLSSTableWriter.Builder` | `withType(java.lang.String typeDefinition)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### formatType

          protected SSTableFormat.Type formatType

  - ### 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(java.io.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.

    - #### withType

          public CQLSSTableWriter.Builder withType(java.lang.String typeDefinition)
                                            throws SyntaxException

      Throws:
        `SyntaxException`

    - #### 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.

    - #### 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 insert)

      The INSERT or UPDATE statement defining the order of the values to add for a given CQL row.

      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.

      Parameters:
        `insert` - an insertion statement that defines the order of column values to use.
      Returns:
        this builder.
      Throws:
        `java.lang.IllegalArgumentException` - if `insertStatement` is not a valid insertion statement, does not have a fully-qualified table name or have no bind variables.

    - #### withBufferSizeInMB

          public CQLSSTableWriter.Builder withBufferSizeInMB(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 correspond 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.

      Parameters:
        `size` - the size to use in MB.
      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 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.

      Returns:
        this builder.

    - #### build

          public CQLSSTableWriter build()

Copyright © 2018 The Apache Software Foundation