SSTableWriter (apache-cassandra API)
Date: 2018-02-14

org.apache.cassandra.io.sstable.format

## Class SSTableWriter

- java.lang.Object
- - org.apache.cassandra.io.sstable.SSTable
  - - org.apache.cassandra.io.sstable.format.SSTableWriter

- All Implemented Interfaces:
    java.lang.AutoCloseable, Transactional
  Direct Known Subclasses:
    BigTableWriter

      public abstract class SSTableWriter
      extends SSTable
      implements Transactional

  This is the API all table writers must implement. TableWriter.create() is the primary way to create a writer for a particular format. The format information is part of the Descriptor.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SSTableWriter.Factory`
    `protected class` | `SSTableWriter.TransactionalProxy`

    - ### Nested classes/interfaces inherited from interface org.apache.cassandra.utils.concurrent.Transactional

      `Transactional.AbstractTransactional`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SerializationHeader` | `header`
    `protected long` | `keyCount`
    `protected long` | `maxDataAge`
    `protected MetadataCollector` | `metadataCollector`
    `protected java.util.Collection<SSTableFlushObserver>` | `observers`
    `protected long` | `repairedAt`
    `protected RowIndexEntry.IndexSerializer` | `rowIndexEntrySerializer`
    `protected SSTableWriter.TransactionalProxy` | `txnProxy`

    - ### Fields inherited from class org.apache.cassandra.io.sstable.SSTable

      `components, compression, descriptor, first, last, metadata, optimizationStrategy, TOMBSTONE_HISTOGRAM_BIN_SIZE, TOMBSTONE_HISTOGRAM_SPOOL_SIZE, TOMBSTONE_HISTOGRAM_TTL_ROUND_SECONDS`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SSTableWriter(Descriptor descriptor, long keyCount, long repairedAt, CFMetaData metadata, MetadataCollector metadataCollector, SerializationHeader header, java.util.Collection<SSTableFlushObserver> observers)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `abort()`
    `java.lang.Throwable` | `abort(java.lang.Throwable accumulate)`
    `abstract RowIndexEntry` | `append(UnfilteredRowIterator iterator)` Appends partition data to this writer.
    `void` | `close()`
    `java.lang.Throwable` | `commit(java.lang.Throwable accumulate)`
    `static SSTableWriter` | `create(CFMetaData metadata, Descriptor descriptor, long keyCount, long repairedAt, int sstableLevel, SerializationHeader header, java.util.Collection<Index> indexes, LifecycleTransaction txn)`
    `static SSTableWriter` | `create(Descriptor descriptor, java.lang.Long keyCount, java.lang.Long repairedAt, CFMetaData metadata, MetadataCollector metadataCollector, SerializationHeader header, java.util.Collection<Index> indexes, LifecycleTransaction txn)`
    `static SSTableWriter` | `create(Descriptor descriptor, long keyCount, long repairedAt, int sstableLevel, SerializationHeader header, java.util.Collection<Index> indexes, LifecycleTransaction txn)`
    `static SSTableWriter` | `create(java.lang.String filename, long keyCount, long repairedAt, int sstableLevel, SerializationHeader header, java.util.Collection<Index> indexes, LifecycleTransaction txn)`
    `static SSTableWriter` | `create(java.lang.String filename, long keyCount, long repairedAt, SerializationHeader header, java.util.Collection<Index> indexes, LifecycleTransaction txn)`
    `protected java.util.Map<MetadataType,MetadataComponent>` | `finalizeMetadata()`
    `SSTableReader` | `finish(boolean openResult)`
    `SSTableReader` | `finish(long repairedAt, long maxDataAge, boolean openResult)`
    `SSTableReader` | `finished()` Open the resultant SSTableReader once it has been fully written, and all related state is ready to be finalised including other sstables being written involved in the same operation
    `long` | `getEstimatedOnDiskBytesWritten()`
    `abstract long` | `getFilePointer()`
    `abstract long` | `getOnDiskFilePointer()`
    `abstract void` | `mark()`
    `abstract SSTableReader` | `openEarly()` Open the resultant SSTableReader before it has been fully written
    `abstract SSTableReader` | `openFinalEarly()` Open the resultant SSTableReader once it has been fully written, but before the _set_ of tables that are being written together as one atomic operation are all ready
    `void` | `prepareToCommit()`
    `static void` | `rename(Descriptor tmpdesc, Descriptor newdesc, java.util.Set<Component> components)`
    `abstract void` | `resetAndTruncate()`
    `SSTableWriter` | `setMaxDataAge(long maxDataAge)`
    `SSTableWriter` | `setOpenResult(boolean openResult)`
    `SSTableWriter` | `setRepairedAt(long repairedAt)`
    `protected StatsMetadata` | `statsMetadata()`
    `protected abstract SSTableWriter.TransactionalProxy` | `txnProxy()`

    - ### Methods inherited from class org.apache.cassandra.io.sstable.SSTable

      `addComponents, appendTOC, bytesOnDisk, componentsFor, decorateKey, delete, discoverComponentsFor, estimateRowsFromIndex, getAllFilePaths, getColumnFamilyName, getFilename, getIndexFilename, getKeyspaceName, getMinimalKey, getPartitioner, readTOC, toString, tryComponentFromFilename`

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

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

- - ### Field Detail

    - #### repairedAt

          protected long repairedAt

    - #### maxDataAge

          protected long maxDataAge

    - #### keyCount

          protected final long keyCount

    - #### metadataCollector

          protected final MetadataCollector metadataCollector

    - #### rowIndexEntrySerializer

          protected final RowIndexEntry.IndexSerializer rowIndexEntrySerializer

    - #### header

          protected final SerializationHeader header

    - #### txnProxy

          protected final SSTableWriter.TransactionalProxy txnProxy

    - #### observers

          protected final java.util.Collection<SSTableFlushObserver> observers

  - ### Constructor Detail

    - #### SSTableWriter

          protected SSTableWriter(Descriptor descriptor,
                                  long keyCount,
                                  long repairedAt,
                                  CFMetaData metadata,
                                  MetadataCollector metadataCollector,
                                  SerializationHeader header,
                                  java.util.Collection<SSTableFlushObserver> observers)

  - ### Method Detail

    - #### txnProxy

          protected abstract SSTableWriter.TransactionalProxy txnProxy()

    - #### create

          public static SSTableWriter create(Descriptor descriptor,
                                             java.lang.Long keyCount,
                                             java.lang.Long repairedAt,
                                             CFMetaData metadata,
                                             MetadataCollector metadataCollector,
                                             SerializationHeader header,
                                             java.util.Collection<Index> indexes,
                                             LifecycleTransaction txn)

    - #### create

          public static SSTableWriter create(Descriptor descriptor,
                                             long keyCount,
                                             long repairedAt,
                                             int sstableLevel,
                                             SerializationHeader header,
                                             java.util.Collection<Index> indexes,
                                             LifecycleTransaction txn)

    - #### create

          public static SSTableWriter create(CFMetaData metadata,
                                             Descriptor descriptor,
                                             long keyCount,
                                             long repairedAt,
                                             int sstableLevel,
                                             SerializationHeader header,
                                             java.util.Collection<Index> indexes,
                                             LifecycleTransaction txn)

    - #### create

          public static SSTableWriter create(java.lang.String filename,
                                             long keyCount,
                                             long repairedAt,
                                             int sstableLevel,
                                             SerializationHeader header,
                                             java.util.Collection<Index> indexes,
                                             LifecycleTransaction txn)

    - #### create

          public static SSTableWriter create(java.lang.String filename,
                                             long keyCount,
                                             long repairedAt,
                                             SerializationHeader header,
                                             java.util.Collection<Index> indexes,
                                             LifecycleTransaction txn)

    - #### mark

          public abstract void mark()

    - #### append

          public abstract RowIndexEntry append(UnfilteredRowIterator iterator)

      Appends partition data to this writer.
      Parameters:
        `iterator` - the partition to write
      Returns:
        the created index entry if something was written, that is if `iterator` wasn't empty, `null` otherwise.
      Throws:
        `FSWriteError` - if a write to the dataFile fails

    - #### getFilePointer

          public abstract long getFilePointer()

    - #### getOnDiskFilePointer

          public abstract long getOnDiskFilePointer()

    - #### getEstimatedOnDiskBytesWritten

          public long getEstimatedOnDiskBytesWritten()

    - #### resetAndTruncate

          public abstract void resetAndTruncate()

    - #### setRepairedAt

          public SSTableWriter setRepairedAt(long repairedAt)

    - #### setMaxDataAge

          public SSTableWriter setMaxDataAge(long maxDataAge)

    - #### setOpenResult

          public SSTableWriter setOpenResult(boolean openResult)

    - #### openEarly

          public abstract SSTableReader openEarly()

      Open the resultant SSTableReader before it has been fully written

    - #### openFinalEarly

          public abstract SSTableReader openFinalEarly()

      Open the resultant SSTableReader once it has been fully written, but before the _set_ of tables that are being written together as one atomic operation are all ready

    - #### finish

          public SSTableReader finish(long repairedAt,
                                      long maxDataAge,
                                      boolean openResult)

    - #### finish

          public SSTableReader finish(boolean openResult)

    - #### finished

          public SSTableReader finished()

      Open the resultant SSTableReader once it has been fully written, and all related state is ready to be finalised including other sstables being written involved in the same operation

    - #### prepareToCommit

          public final void prepareToCommit()

      Specified by:
        `prepareToCommit` in interface `Transactional`

    - #### commit

          public final java.lang.Throwable commit(java.lang.Throwable accumulate)

      Specified by:
        `commit` in interface `Transactional`

    - #### abort

          public final java.lang.Throwable abort(java.lang.Throwable accumulate)

      Specified by:
        `abort` in interface `Transactional`

    - #### close

          public final void close()

      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `Transactional`

    - #### abort

          public final void abort()

    - #### finalizeMetadata

          protected java.util.Map<MetadataType,MetadataComponent> finalizeMetadata()

    - #### statsMetadata

          protected StatsMetadata statsMetadata()

    - #### rename

          public static void rename(Descriptor tmpdesc,
                                    Descriptor newdesc,
                                    java.util.Set<Component> components)

Copyright © 2018 The Apache Software Foundation