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
`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
`protected long` `keyCount`
`protected long` `maxDataAge`
`protected MetadataCollector` `metadataCollector`
`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, partitioner, TOMBSTONE_HISTOGRAM_BIN_SIZE`

### Constructor Summary

Constructors
`protected` `SSTableWriter(Descriptor descriptor, long keyCount, long repairedAt, CFMetaData metadata, IPartitioner partitioner, MetadataCollector metadataCollector)`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`void` `abort()`
`java.lang.Throwable` `abort(java.lang.Throwable accumulate)`
`abstract RowIndexEntry` `append(AbstractCompactedRow row)`
`abstract void` `append(DecoratedKey decoratedKey, ColumnFamily cf)`
`abstract long` `appendFromStream(DecoratedKey key, CFMetaData metadata, java.io.DataInput in, Version version)`
`void` `close()`
`java.lang.Throwable` `commit(java.lang.Throwable accumulate)`
`static SSTableWriter` `create(CFMetaData metadata, Descriptor descriptor, long keyCount, long repairedAt, int sstableLevel, IPartitioner partitioner)`
`static SSTableWriter` `create(Descriptor descriptor, long keyCount, long repairedAt)`
`static SSTableWriter` `create(Descriptor descriptor, java.lang.Long keyCount, java.lang.Long repairedAt, CFMetaData metadata, IPartitioner partitioner, MetadataCollector metadataCollector)`
`static SSTableWriter` `create(Descriptor descriptor, long keyCount, long repairedAt, int sstableLevel)`
`static SSTableWriter` `create(java.lang.String filename, long keyCount, long repairedAt)`
`static SSTableWriter` `create(java.lang.String filename, long keyCount, long repairedAt, int sstableLevel)`
`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
`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)`
`static Descriptor` `rename(Descriptor tmpdesc, 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, delete, discoverComponentsFor, estimateRowsFromIndex, getColumnFamilyName, getFilename, getIndexFilename, getKeyspaceName, getMinimalKey, 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

#### txnProxy

    protected final SSTableWriter.TransactionalProxy txnProxy

### Constructor Detail

#### SSTableWriter

    protected SSTableWriter(Descriptor descriptor,
                            long keyCount,
                            long repairedAt,
                            CFMetaData metadata,
                            IPartitioner partitioner,
                            MetadataCollector metadataCollector)

### 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,
                                       IPartitioner partitioner,
                                       MetadataCollector metadataCollector)

#### create

    public static SSTableWriter create(Descriptor descriptor,
                                       long keyCount,
                                       long repairedAt)

#### create

    public static SSTableWriter create(Descriptor descriptor,
                                       long keyCount,
                                       long repairedAt,
                                       int sstableLevel)

#### create

    public static SSTableWriter create(CFMetaData metadata,
                                       Descriptor descriptor,
                                       long keyCount,
                                       long repairedAt,
                                       int sstableLevel,
                                       IPartitioner partitioner)

#### create

    public static SSTableWriter create(java.lang.String filename,
                                       long keyCount,
                                       long repairedAt,
                                       int sstableLevel)

#### create

    public static SSTableWriter create(java.lang.String filename,
                                       long keyCount,
                                       long repairedAt)

#### mark

    public abstract void mark()

#### append

    public abstract RowIndexEntry append(AbstractCompactedRow row)

Parameters:
  `row` -
Returns:
  null if the row was compacted away entirely; otherwise, the PK index entry for this row

#### append

    public abstract void append(DecoratedKey decoratedKey,
                                ColumnFamily cf)

#### appendFromStream

    public abstract long appendFromStream(DecoratedKey key,
                                          CFMetaData metadata,
                                          java.io.DataInput in,
                                          Version version)
                                   throws java.io.IOException

Throws:
  `java.io.IOException`

#### getFilePointer

    public abstract long getFilePointer()

#### getOnDiskFilePointer

    public abstract long getOnDiskFilePointer()

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

#### abort

    public final void abort()

#### finalizeMetadata

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

#### statsMetadata

    protected StatsMetadata statsMetadata()

#### rename

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

#### rename

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