Interface Memtable.Factory

  • All Known Implementing Classes:
    SkipListMemtableFactory
    Enclosing interface:
    Memtable

    public static interface Memtable.Factory
    Factory interface for constructing memtables, and querying write durability features. The factory is chosen using the MemtableParams class (passed as argument to CREATE TABLE ... WITH memtable = '<configuration_name>' where the configuration definition is a map given under memtable_configurations in cassandra.yaml). To make that possible, implementations must provide either a static FACTORY field (if they accept no further option) or a static factory(Map<String, String>) method. In the latter case, the method should avoid creating multiple instances of the factory for the same parameters, or factories should at least implement hashCode and equals.
    • Method Detail

      • create

        Memtable create​(java.util.concurrent.atomic.AtomicReference<CommitLogPosition> commitLogLowerBound,
                        TableMetadataRef metadaRef,
                        Memtable.Owner owner)
        Create a memtable.
        Parameters:
        commitLogLowerBound - A commit log lower bound for the new memtable. This will be equal to the previous memtable's upper bound and defines the span of positions that any flushed sstable will cover.
        metadaRef - Pointer to the up-to-date table metadata.
        owner - Owning objects that will receive flush requests triggered by the memtable (e.g. on expiration).
      • writesShouldSkipCommitLog

        default boolean writesShouldSkipCommitLog()
        If the memtable can achieve write durability directly (i.e. using some feature other than the commitlog, e.g. persistent memory), it can return true here, in which case the commit log will not store mutations in this table. Note that doing so will prevent point-in-time restores and changed data capture, thus a durable memtable must allow the option of turning commit log writing on even if it does not need it.
      • writesAreDurable

        default boolean writesAreDurable()
        This should be true if the memtable can achieve write durability for crash recovery directly (i.e. using some feature other than the commitlog, e.g. persistent memory). Setting this flag to true means that the commitlog should not replay mutations for this table on restart, and that it should not try to preserve segments that contain relevant data. Unless writesShouldSkipCommitLog() is also true, writes will be recorded in the commit log as they may be needed for changed data capture or point-in-time restore.
      • streamToMemtable

        default boolean streamToMemtable()
        Normally we can receive streamed sstables directly, skipping the memtable stage (zero-copy-streaming). When the memtable is the primary data store (e.g. persistent memtables), it will usually prefer to receive the data instead. If this returns true, all streamed sstables's content will be read and replayed as mutations, disabling zero-copy streaming.
      • streamFromMemtable

        default boolean streamFromMemtable()
        When we need to stream data, we usually flush and stream the resulting sstables. This will not work correctly if the memtable does not want to flush for streaming (e.g. persistent memtables acting as primary data store), because data (not just recent) will be missing from the streamed view. Such memtables must present their data separately for streaming. In other words if the memtable returns false on shouldSwitch(STREAMING/REPAIR), its factory must return true here. If this flag returns true, streaming will write the relevant content that resides in the memtable to temporary sstables, stream these sstables and then delete them.
      • createMemtableMetrics

        default TableMetrics.ReleasableMetric createMemtableMetrics​(TableMetadataRef metadataRef)
        Override this method to include implementation-specific memtable metrics in the table metrics. Memtable metrics lifecycle matches table lifecycle. It is the table that owns the metrics and decides when to release them.