## org.apache.cassandra.io.sstable
Class SSTableSimpleUnsortedWriter

    java.lang.Object
      org.apache.cassandra.io.sstable.AbstractSSTableSimpleWriter
          org.apache.cassandra.io.sstable.SSTableSimpleUnsortedWriter

    public class SSTableSimpleUnsortedWriter

extends AbstractSSTableSimpleWriter

A SSTable writer that doesn't assume rows are in sorted order. This writer buffers rows in memory and then write them all in sorted order. To avoid loading the entire data set in memory, the amount of rows buffered is configurable. Each time the threshold is met, one SSTable will be created (and the buffer be reseted).

See Also:
  `AbstractSSTableSimpleWriter`

Field Summary

Fields inherited from class org.apache.cassandra.io.sstable.AbstractSSTableSimpleWriter
`columnFamily, currentKey, currentSuperColumn, directory, metadata, nodeid`

Constructor Summary
`SSTableSimpleUnsortedWriter(java.io.File directory, java.lang.String keyspace, java.lang.String columnFamily, AbstractType comparator, AbstractType subComparator, int bufferSizeInMB)` Create a new buffering writer.

Method Summary
`void` `close()` Close this writer.
`protected ColumnFamily` `getColumnFamily()`
`protected void` `writeRow(DecoratedKey key, ColumnFamily columnFamily)`

Methods inherited from class org.apache.cassandra.io.sstable.AbstractSSTableSimpleWriter
`addColumn, addCounterColumn, addExpiringColumn, getWriter, newRow, newSuperColumn`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SSTableSimpleUnsortedWriter

    public SSTableSimpleUnsortedWriter(java.io.File directory,
                                       java.lang.String keyspace,
                                       java.lang.String columnFamily,
                                       AbstractType comparator,
                                       AbstractType subComparator,
                                       int bufferSizeInMB)
                                throws java.io.IOException

  Create a new buffering writer.

  Parameters:
    `directory` - the directory where to write the sstables
    `keyspace` - the keyspace name
    `columnFamily` - the column family name
    `comparator` - the column family comparator
    `subComparator` - the column family subComparator or null if not a Super column family.
    `bufferSizeInMB` - the data size in MB before which a sstable is written and the buffer reseted. This correspond roughly to the written data size (i.e. the size of the create sstable). The actual size used in memory will be higher (by how much depends on the size of the columns you add). For 1GB of heap, a 128 bufferSizeInMB is probably a reasonable choice. If you experience OOM, this value should be lowered.
  Throws:
    `java.io.IOException`

Method Detail

### writeRow

    protected void writeRow(DecoratedKey key,
                            ColumnFamily columnFamily)
                     throws java.io.IOException

  Specified by:
    `writeRow` in class `AbstractSSTableSimpleWriter`
  Throws:
    `java.io.IOException`

### getColumnFamily

    protected ColumnFamily getColumnFamily()

  Specified by:
    `getColumnFamily` in class `AbstractSSTableSimpleWriter`

### close

    public void close()
               throws java.io.IOException

  Description copied from class: `AbstractSSTableSimpleWriter`
  Close this writer. This method should be called, otherwise the produced sstables are not guaranteed to be complete (and won't be in practice).

  Specified by:
    `close` in class `AbstractSSTableSimpleWriter`
  Throws:
    `java.io.IOException`

Copyright © 2012 The Apache Software Foundation