index

package
v2.3.9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Indexer

type Indexer interface {
	// Put key and position into the index.
	Put(key []byte, position *wal.ChunkPosition) *wal.ChunkPosition

	// Get the position of the key in the index.
	Get(key []byte) *wal.ChunkPosition

	// Delete the index of the key.
	Delete(key []byte) (*wal.ChunkPosition, bool)

	// Size represents the number of keys in the index.
	Size() int

	// Ascend iterates over items in ascending order and invokes the handler function for each item.
	// If the handler function returns false, iteration stops.
	Ascend(handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

	// AscendRange iterates in ascending order within [startKey, endKey], invoking handleFn.
	// Stops if handleFn returns false.
	AscendRange(startKey, endKey []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

	// AscendGreaterOrEqual iterates in ascending order, starting from key >= given key,
	// invoking handleFn. Stops if handleFn returns false.
	AscendGreaterOrEqual(key []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

	// Descend iterates over items in descending order and invokes the handler function for each item.
	// If the handler function returns false, iteration stops.
	Descend(handleFn func(key []byte, pos *wal.ChunkPosition) (bool, error))

	// DescendRange iterates in descending order within [startKey, endKey], invoking handleFn.
	// Stops if handleFn returns false.
	DescendRange(startKey, endKey []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

	// DescendLessOrEqual iterates in descending order, starting from key <= given key,
	// invoking handleFn. Stops if handleFn returns false.
	DescendLessOrEqual(key []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))
}

Indexer is an interface for indexing key and position. It is used to store the key and the position of the data in the WAL. The index will be rebuilt when the database is opened. You can implement your own indexer by implementing this interface.

func NewIndexer

func NewIndexer() Indexer

type IndexerType

type IndexerType = byte
const (
	BTree IndexerType = iota
)

type MemoryBTree added in v2.3.0

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

MemoryBTree is a memory based btree implementation of the Index interface It is a wrapper around the google/btree package: github.com/google/btree

func (*MemoryBTree) Ascend added in v2.3.0

func (mt *MemoryBTree) Ascend(handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

func (*MemoryBTree) AscendGreaterOrEqual added in v2.3.1

func (mt *MemoryBTree) AscendGreaterOrEqual(key []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

func (*MemoryBTree) AscendRange added in v2.3.1

func (mt *MemoryBTree) AscendRange(startKey, endKey []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

func (*MemoryBTree) Delete added in v2.3.0

func (mt *MemoryBTree) Delete(key []byte) (*wal.ChunkPosition, bool)

func (*MemoryBTree) Descend added in v2.3.0

func (mt *MemoryBTree) Descend(handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

func (*MemoryBTree) DescendLessOrEqual added in v2.3.1

func (mt *MemoryBTree) DescendLessOrEqual(key []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

func (*MemoryBTree) DescendRange added in v2.3.1

func (mt *MemoryBTree) DescendRange(startKey, endKey []byte, handleFn func(key []byte, position *wal.ChunkPosition) (bool, error))

func (*MemoryBTree) Get added in v2.3.0

func (mt *MemoryBTree) Get(key []byte) *wal.ChunkPosition

func (*MemoryBTree) Put added in v2.3.0

func (mt *MemoryBTree) Put(key []byte, position *wal.ChunkPosition) *wal.ChunkPosition

func (*MemoryBTree) Size added in v2.3.0

func (mt *MemoryBTree) Size() int

Jump to

Keyboard shortcuts

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