Documentation ¶
Index ¶
Constants ¶
const ( BlockSize = 64 * common.KB FileModePerm = 0644 SegSuffix = ".seg" SpSuffix = ".sp" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SSTable ¶
type SSTable struct { Segments []*segment Root string }
func NewSSTable ¶
NewSSTable initializes a new SSTable instance with the given root directory. It loads existing segments from the root directory and appends them to the SSTable. Returns a pointer to the SSTable and an error if any occurs during initialization or loading.
func (*SSTable) Close ¶
func (s *SSTable) Close()
Close shuts down all the segments in the SSTable by calling the close method on each one.
func (*SSTable) Get ¶
Get retrieves the value associated with the given key from the SSTable. It iterates through the segments in reverse order to find the latest value for the key. If the key is found and not marked as deleted, it returns the corresponding value; otherwise, it returns nil. If an error occurs during the retrieval process, it is returned along with the nil value.
func (*SSTable) Write ¶
Write reads data from the provided Scanner and writes it into a new segment within the SSTable. It creates a new segment, iterates over the Scanner, writes each chunk, generates a snapshot for the segment, appends the segment to the SSTable's segments, and syncs the segment to disk. Returns an error if any occurs during segment creation, writing, or syncing.