Class CompactionAwareWriter

    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
      • nonExpiredSSTables

        protected final java.util.Set<SSTableReader> nonExpiredSSTables
      • estimatedTotalKeys

        protected final long estimatedTotalKeys
      • maxAge

        protected final long maxAge
      • minRepairedAt

        protected final long minRepairedAt
      • pendingRepair

        protected final TimeUUID pendingRepair
      • isTransient

        protected final boolean isTransient
    • Method Detail

      • estimatedKeys

        public long estimatedKeys()
        estimated number of keys we should write
      • append

        public final boolean append​(UnfilteredRowIterator partition)
        Writes a partition in an implementation specific way
        Parameters:
        partition - the partition to append
        Returns:
        true if the partition was written, false otherwise
      • getSStableDirectory

        public final File getSStableDirectory()
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • maybeSwitchWriter

        protected void maybeSwitchWriter​(DecoratedKey key)
        Switches the writer if necessary, i.e. if the new key should be placed in a different data directory, or if the specific strategy has decided a new sstable is needed. Guaranteed to be called before the first call to realAppend.
      • maybeSwitchLocation

        protected boolean maybeSwitchLocation​(DecoratedKey key)
        Switches the file location and writer and returns true if the new key should be placed in a different data directory.
      • shouldSwitchWriterInCurrentLocation

        protected abstract boolean shouldSwitchWriterInCurrentLocation​(DecoratedKey key)
        Returns true if the writer should be switched for reasons other than switching to a new data directory (e.g. because an sstable size limit has been reached).
      • switchCompactionWriter

        protected void switchCompactionWriter​(Directories.DataDirectory directory,
                                              DecoratedKey nextKey)
        Implementations of this method should finish the current sstable writer and start writing to this directory.

        Called once before starting to append and then whenever we see a need to start writing to another directory.

        Parameters:
        directory -
        nextKey -
      • sstableLevel

        protected int sstableLevel()
        Returns the level that should be used when creating sstables.
      • sstableKeyCount

        protected abstract long sstableKeyCount()
        Returns the key count with which created sstables should be set up.
      • getDirectories

        public Directories getDirectories()
        The directories we can write to
      • getWriteDirectory

        public Directories.DataDirectory getWriteDirectory​(java.lang.Iterable<SSTableReader> sstables,
                                                           long estimatedWriteSize)
        Return a directory where we can expect expectedWriteSize to fit.
        Parameters:
        sstables - the sstables to compact
      • getExpectedWriteSize

        protected long getExpectedWriteSize()