CompactionAwareWriter (apache-cassandra API)
Date: 2018-02-12

org.apache.cassandra.db.compaction.writers

## Class CompactionAwareWriter

- java.lang.Object
- - org.apache.cassandra.utils.concurrent.Transactional.AbstractTransactional
  - - org.apache.cassandra.db.compaction.writers.CompactionAwareWriter

- All Implemented Interfaces:
    java.lang.AutoCloseable, Transactional
  Direct Known Subclasses:
    DefaultCompactionWriter, MajorLeveledCompactionWriter, MaxSSTableSizeWriter, SplittingSizeTieredCompactionWriter

      public abstract class CompactionAwareWriter
      extends Transactional.AbstractTransactional
      implements Transactional

  Class that abstracts away the actual writing of files to make it possible to use CompactionTask for more use cases.

- - ### Nested Class Summary

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

      `Transactional.AbstractTransactional.State`

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

      `Transactional.AbstractTransactional`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ColumnFamilyStore` | `cfs`
    `protected long` | `estimatedTotalKeys`
    `protected long` | `maxAge`
    `protected long` | `minRepairedAt`
    `protected java.util.Set<SSTableReader>` | `nonExpiredSSTables`
    `protected SSTableRewriter` | `sstableWriter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompactionAwareWriter(ColumnFamilyStore cfs, LifecycleTransaction txn, java.util.Set<SSTableReader> nonExpiredSSTables, boolean offline)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract boolean` | `append(AbstractCompactedRow row)` Writes a row in an implementation specific way
    `protected java.lang.Throwable` | `doAbort(java.lang.Throwable accumulate)`
    `protected java.lang.Throwable` | `doCommit(java.lang.Throwable accumulate)`
    `protected void` | `doPrepare()` Do any preparatory work prior to commit.
    `long` | `estimatedKeys()` estimated number of keys we should write
    `java.util.List<SSTableReader>` | `finish()` we are done, return the finished sstables so that the caller can mark the old ones as compacted
    `Directories` | `getDirectories()` The directories we can write to
    `Directories.DataDirectory` | `getWriteDirectory(long expectedWriteSize)` Return a directory where we can expect expectedWriteSize to fit.

    - ### Methods inherited from class org.apache.cassandra.utils.concurrent.Transactional.AbstractTransactional

      `abort, abort, close, commit, commit, doPostCleanup, doPreCleanup, permitRedundantTransitions, prepareToCommit, state`

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

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

    - ### Methods inherited from interface org.apache.cassandra.utils.concurrent.Transactional

      `abort, commit, prepareToCommit`

    - ### Methods inherited from interface java.lang.AutoCloseable

      `close`

- - ### Field Detail

    - #### cfs

          protected final ColumnFamilyStore cfs

    - #### nonExpiredSSTables

          protected final java.util.Set<SSTableReader> nonExpiredSSTables

    - #### estimatedTotalKeys

          protected final long estimatedTotalKeys

    - #### maxAge

          protected final long maxAge

    - #### minRepairedAt

          protected final long minRepairedAt

    - #### sstableWriter

          protected final SSTableRewriter sstableWriter

  - ### Constructor Detail

    - #### CompactionAwareWriter

          public CompactionAwareWriter(ColumnFamilyStore cfs,
                                       LifecycleTransaction txn,
                                       java.util.Set<SSTableReader> nonExpiredSSTables,
                                       boolean offline)

  - ### Method Detail

    - #### append

          public abstract boolean append(AbstractCompactedRow row)

      Writes a row in an implementation specific way
      Parameters:
        `row` - the row to append
      Returns:
        true if the row was written, false otherwise

    - #### doAbort

          protected java.lang.Throwable doAbort(java.lang.Throwable accumulate)

      Specified by:
        `doAbort` in class `Transactional.AbstractTransactional`

    - #### doCommit

          protected java.lang.Throwable doCommit(java.lang.Throwable accumulate)

      Specified by:
        `doCommit` in class `Transactional.AbstractTransactional`

    - #### doPrepare

          protected void doPrepare()

      Description copied from class: `Transactional.AbstractTransactional`
      Do any preparatory work prior to commit. This method should throw any exceptions that can be encountered during the finalization of the behaviour.
      Specified by:
        `doPrepare` in class `Transactional.AbstractTransactional`

    - #### finish

          public java.util.List<SSTableReader> finish()

      we are done, return the finished sstables so that the caller can mark the old ones as compacted
      Overrides:
        `finish` in class `Transactional.AbstractTransactional`
      Returns:
        all the written sstables sstables

    - #### estimatedKeys

          public long estimatedKeys()

      estimated number of keys we should write

    - #### getDirectories

          public Directories getDirectories()

      The directories we can write to

    - #### getWriteDirectory

          public Directories.DataDirectory getWriteDirectory(long expectedWriteSize)

      Return a directory where we can expect expectedWriteSize to fit.

Copyright © 2018 The Apache Software Foundation