Class SSTableWriter

    • Method Detail

      • handleConstructionFailure

        protected void handleConstructionFailure​(java.lang.Throwable ex)
        Constructors of subclasses, if they open any resources, should wrap that in a try-catch block and call this method in the 'catch' section after closing any resources opened in the constructor. This method would remove the sstable from the transaction and delete the orphaned components, if any were created during the construction. The caught exception should be then rethrown so the SSTableWriter.Builder can handle it and close any resources opened implicitly by the builder.

        See SortedTableWriter(SortedTableWriter.Builder, LifecycleNewTracker, Owner) as of CASSANDRA-18737.

        Parameters:
        ex - the exception thrown during the construction
      • mark

        public abstract void mark()
      • append

        public abstract AbstractRowIndexEntry 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 writing to the dataFile fails
      • getFilePointer

        public abstract long getFilePointer()
        Returns a position in the uncompressed data - for uncompressed files it is the same as getOnDiskFilePointer() but for compressed files it returns a position in the data rather than a position in the file on disk.
      • getOnDiskFilePointer

        public abstract long getOnDiskFilePointer()
        Returns a position in the (compressed) data file on disk. See getFilePointer()
      • getEstimatedOnDiskBytesWritten

        public long getEstimatedOnDiskBytesWritten()
        Returns the amount of data already written to disk that may not be accurate (for example, the position after the recently flushed chunk).
      • resetAndTruncate

        public abstract void resetAndTruncate()
        Reset the data file to the marked position (see mark()) and truncate the rest of the file.
      • setRepairedAt

        public void setRepairedAt​(long repairedAt)
      • setMaxDataAge

        public void setMaxDataAge​(long maxDataAge)
      • setTokenSpaceCoverage

        public SSTableWriter setTokenSpaceCoverage​(double rangeSpanned)
      • setOpenResult

        public void setOpenResult​(boolean openResult)
      • openEarly

        public abstract void openEarly​(java.util.function.Consumer<SSTableReader> doWhenReady)
        Open the resultant SSTableReader before it has been fully written.

        The passed consumer will be called when the necessary data has been flushed to disk/cache. This may never happen (e.g. if the table was finished before the flushes materialized, or if this call returns false e.g. if a table was already prepared but hasn't reached readiness yet).

        Uses callback instead of future because preparation and callback happen on the same thread.

      • 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
      • 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
      • 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()
      • releaseMetadataOverhead

        public void releaseMetadataOverhead()