lsm

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound will be returned when the key could not be located
	ErrNotFound = errors.New("not found")

	ErrInternal = fmt.Errorf("%w: internal error", ErrNotFound)
)

Functions

This section is empty.

Types

type GoStore

type GoStore struct {
	// contains filtered or unexported fields
}

func (*GoStore) Close

func (store *GoStore) Close() error

Close closes all associated resources

func (*GoStore) Delete

func (store *GoStore) Delete(key []byte) error

Delete a key from the DB

func (*GoStore) Read

func (store *GoStore) Read(key []byte) ([]byte, error)

Read the value from the given key. Will return error if value is not found.

func (*GoStore) Write

func (store *GoStore) Write(key []byte, val []byte) error

Write the Key-Value pair to the memtable

type LSM

type LSM interface {
	io.Closer
	Write([]byte, []byte) error  // Write the Key-Value pair to the memtable
	Read([]byte) ([]byte, error) // Read the value from the given key.
	Delete([]byte) error         // Delete the key from the DB
}

func New

func New(opts *LSMOpts) (LSM, error)

Creates a new LSMTree. Creates application directory if it does not exist.

***Will exit with non-zero status if error is returned during any of the initialization steps.

type LSMOpts

type LSMOpts struct {
	MemTableOpts     *memtable.Opts
	ManifestOpts     *manifest.Opts
	GoStorePath      string
	SSTable_max_size int
}

func NewDefaultLSMOpts

func NewDefaultLSMOpts(gostorepath string) *LSMOpts
return &LSMOpts{
	MemTableOpts: &memtable.Opts{
		WalPath:          filepath.Join(gostorepath, "WAL.log"),
		Batch_write_size: 10,
		Max_size:         20000,
		Bloom_size:       10000,
		BloomPath:        filepath.Join(gostorepath, "filters"),
	},
	ManifestOpts: &manifest.Opts{
		Path:            filepath.Join(gostorepath, "manifest.log"),
		Num_levels:      4,
		Level0_max_size: 300000000,
		LevelPaths: []string{
			filepath.Join(gostorepath, "l0"), filepath.Join(gostorepath, "l1"),
			filepath.Join(gostorepath, "l2"), filepath.Join(gostorepath, "l3"),
		},
		SSTable_max_size: 400000,
		BloomPath:        filepath.Join(gostorepath, "filters"),
	},
	GoStorePath: gostorepath,
}

func NewTestLSMOpts

func NewTestLSMOpts(gostorepath string) *LSMOpts
return &LSMOpts{
	MemTableOpts: &memtable.Opts{
		WalPath:          filepath.Join(gostorepath, "WAL.log"),
		Batch_write_size: 100,
		Max_size:         1000,
		Bloom_size:       10000,
		BloomPath:        filepath.Join(gostorepath, "filters"),
	},
	ManifestOpts: &manifest.Opts{
		LevelPaths: []string{
			filepath.Join(gostorepath, "l0"), filepath.Join(gostorepath, "l1"),
			filepath.Join(gostorepath, "l2"), filepath.Join(gostorepath, "l3"),
		},
		Path:             filepath.Join(gostorepath, "manifest.log"),
		Num_levels:       4,
		Level0_max_size:  539375,
		SSTable_max_size: 1000,
		BloomPath:        filepath.Join(gostorepath, "filters"),
	},
	GoStorePath: gostorepath,
}

Jump to

Keyboard shortcuts

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