Interface MemStore

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AbstractMemStore, CompactingMemStore, DefaultMemStore

@Private public interface MemStore extends Closeable
The MemStore holds in-memory modifications to the Store. Modifications are Cells.

The MemStore functions should not be called in parallel. Callers should hold write and read locks. This is done in HStore.

  • Method Details

    • snapshot

      Creates a snapshot of the current memstore. Snapshot must be cleared by call to clearSnapshot(long).
      Returns:
      MemStoreSnapshot
    • clearSnapshot

      Clears the current snapshot of the Memstore.
      Throws:
      UnexpectedStateException
      See Also:
    • getFlushableSize

      Flush will first clear out the data in snapshot if any (It will take a second flush invocation to clear the current Cell set). If snapshot is empty, current Cell set will be flushed.
      Returns:
      On flush, how much memory we will clear.
    • getSnapshotSize

      Return the size of the snapshot(s) if any
      Returns:
      size of the memstore snapshot
    • add

      void add(Cell cell, MemStoreSizing memstoreSizing)
      Write an update
      Parameters:
      memstoreSizing - The delta in memstore size will be passed back via this. This will include both data size and heap overhead delta.
    • add

      void add(Iterable<Cell> cells, MemStoreSizing memstoreSizing)
      Write the updates
      Parameters:
      memstoreSizing - The delta in memstore size will be passed back via this. This will include both data size and heap overhead delta.
    • timeOfOldestEdit

      Returns Oldest timestamp of all the Cells in the MemStore
    • upsert

      void upsert(Iterable<Cell> cells, long readpoint, MemStoreSizing memstoreSizing)
      Update or insert the specified cells.

      For each Cell, insert into MemStore. This will atomically upsert the value for that row/family/qualifier. If a Cell did already exist, it will then be removed.

      Currently the memstoreTS is kept at 0 so as each insert happens, it will be immediately visible. May want to change this so it is atomic across all KeyValues.

      This is called under row lock, so Get operations will still see updates atomically. Scans will only see each KeyValue update as atomic.

      Parameters:
      readpoint - readpoint below which we can safely remove duplicate Cells.
      memstoreSizing - The delta in memstore size will be passed back via this. This will include both data size and heap overhead delta.
    • getScanners

      Returns:
      scanner over the memstore. This might include scanner over the snapshot when one is present.
      Throws:
      IOException
    • size

      Returns:
      Total memory occupied by this MemStore. This won't include any size occupied by the snapshot. We assume the snapshot will get cleared soon. This is not thread safe and the memstore may be changed while computing its size. It is the responsibility of the caller to make sure this doesn't happen.
    • preFlushSeqIDEstimation

      This method is called before the flush is executed.
      Returns:
      an estimation (lower bound) of the unflushed sequence id in memstore after the flush is executed. if memstore will be cleared returns HConstants.NO_SEQNUM.
    • isSloppy

      boolean isSloppy()
    • startReplayingFromWAL

      default void startReplayingFromWAL()
      This message intends to inform the MemStore that next coming updates are going to be part of the replaying edits from WAL
    • stopReplayingFromWAL

      default void stopReplayingFromWAL()
      This message intends to inform the MemStore that the replaying edits from WAL are done
    • close

      void close()
      Close the memstore.

      Usually this should only be called when there is nothing in the memstore, unless we are going to abort ourselves.

      For normal cases, this method is only used to fix the reference counting, see HBASE-27941.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable