sstable

package
v0.0.0-...-81f4bad Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateUniqueSegmentName

func GenerateUniqueSegmentName(time time.Time) string

Generate a unique SSTable filename in the format TIMESTAMP_UNIQUESTRING.segment

func Merge

func Merge(tables ...*SSTable) <-chan *pb.SSTable_Entry

Return sorted output stream of SSTable_Entry from an arbitrary number of tables

func Split

func Split(in <-chan *pb.SSTable_Entry, maxSize int, tableOpts *Opts) <-chan *SSTable

Form SSTables of maxSize from input stream

Types

type Opts

type Opts struct {
	BloomOpts *filter.Opts
	DestDir   string
	Entries   []*pb.SSTable_Entry
}

type SSTable

type SSTable struct {
	Entries []*pb.SSTable_Entry // A list of entries sorted by key
	Filter  *filter.BloomFilter // Check if key could be in table

	Size      int64     // Size of file in bytes
	Name      string    // full filename
	First     []byte    // First key in range
	Last      []byte    // Last key in range
	CreatedOn time.Time // Timestamp
	// contains filtered or unexported fields
}

SSTable represents a Sorted String Table. Entries are sorted by key.

func FromProto

func FromProto(p *pb.SSTable) (*SSTable, error)

func New

func New(opts *Opts) *SSTable

func Oldest

func Oldest(tables []*SSTable) *SSTable

Find and return the oldest table

func Overlapping

func Overlapping(upper_table *SSTable, lower_level []*SSTable) []*SSTable

Return tables from lower_level that overlap upper_table

func (*SSTable) Close

func (table *SSTable) Close() error

Clears entries, unlocks table, and closes file

Should only be called after prior call to Open()

func (*SSTable) LoadFilter

func (table *SSTable) LoadFilter() error

func (*SSTable) Open

func (table *SSTable) Open() error

Read entries into memory & locks table

*** You must call Close() after opening table

func (*SSTable) Overlaps

func (table *SSTable) Overlaps(anotherTable *SSTable) bool

Test if table key range overlaps the key range of another

func (*SSTable) SaveFilter

func (table *SSTable) SaveFilter() error

func (*SSTable) Search

func (table *SSTable) Search(key []byte) ([]byte, bool)

Search searches for a key in the SSTable.

Panics if attempt to search empty entries array

func (*SSTable) Sync

func (table *SSTable) Sync() (int64, error)

Sync flushes all in-memory entries to stable storage

func (*SSTable) ToProto

func (table *SSTable) ToProto() (*pb.SSTable, error)

func (*SSTable) WriteTo

func (table *SSTable) WriteTo(writer io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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