sstable

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

func NewSSTable(root string) (*SSTable, error)

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

func (s *SSTable) Get(key string) ([]byte, error)

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

func (s *SSTable) Write(scanner common.Scanner) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL