index

package
v0.0.0-...-09ba173 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdaptiveRadixTree

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

AdaptiveRadixTree defines an ART index

refer to [https://github.com/plar/go-adaptive-radix-tree]

func NewART

func NewART() *AdaptiveRadixTree

func (*AdaptiveRadixTree) Close

func (art *AdaptiveRadixTree) Close() error

func (*AdaptiveRadixTree) Delete

func (art *AdaptiveRadixTree) Delete(key []byte) (*data.LogRecordPos, bool)

func (*AdaptiveRadixTree) Get

func (art *AdaptiveRadixTree) Get(key []byte) *data.LogRecordPos

func (*AdaptiveRadixTree) Iterator

func (art *AdaptiveRadixTree) Iterator(reverse bool) Iterator

func (*AdaptiveRadixTree) Put

func (art *AdaptiveRadixTree) Put(key []byte, pos *data.LogRecordPos) *data.LogRecordPos

func (*AdaptiveRadixTree) Size

func (art *AdaptiveRadixTree) Size() int

type BPlusTree

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

BPlusTree defines a B+ tree index

refer to [https://github.com/etcd-io/bbolt]

func NewBPlusTree

func NewBPlusTree(directoryPath string, syncWrites bool) *BPlusTree

NewBPlusTree initialize a new BPlusTree index

func (*BPlusTree) Close

func (bpt *BPlusTree) Close() error

func (*BPlusTree) Delete

func (bpt *BPlusTree) Delete(key []byte) (*data.LogRecordPos, bool)

func (*BPlusTree) Get

func (bpt *BPlusTree) Get(key []byte) *data.LogRecordPos

func (*BPlusTree) Iterator

func (bpt *BPlusTree) Iterator(reverse bool) Iterator

func (*BPlusTree) Put

func (bpt *BPlusTree) Put(key []byte, pos *data.LogRecordPos) *data.LogRecordPos

func (*BPlusTree) Size

func (bpt *BPlusTree) Size() int

type BTree

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

BTree defines the BTree index

it mainly encapsulates Google's btree library: [https://github.com/google/btree]

func NewBTree

func NewBTree() *BTree

NewBTree constructor creates a new BTree index structure

func (*BTree) Close

func (bt *BTree) Close() error

func (*BTree) Delete

func (bt *BTree) Delete(key []byte) (*data.LogRecordPos, bool)

func (*BTree) Get

func (bt *BTree) Get(key []byte) *data.LogRecordPos

func (*BTree) Iterator

func (bt *BTree) Iterator(reverse bool) Iterator

func (*BTree) Put

func (bt *BTree) Put(key []byte, pos *data.LogRecordPos) *data.LogRecordPos

func (*BTree) Size

func (bt *BTree) Size() int

type IndexType

type IndexType = int8
const (
	// Btree indicates btree index
	Btree IndexType = iota + 1

	// ART indicates Adaptive Radix Tree index
	ART

	// BPTree indicates b+tree index
	BPTree
)

type Indexer

type Indexer interface {
	// Put stores information about the location of the data corresponding to the key in the index
	Put(key []byte, pos *data.LogRecordPos) *data.LogRecordPos

	// Get Fetches the index position information according to the key
	Get(key []byte) *data.LogRecordPos

	// Delete deletes the index position information according to the key
	Delete(key []byte) (*data.LogRecordPos, bool)

	// Size defines the size of index
	Size() int

	// Iterator defines an iterator to iterator over the index
	Iterator(reverse bool) Iterator

	// Close closes the index
	Close() error
}

Indexer is the abstract index interface If there are other data structures that require integration, implement this interface directly

func NewIndexer

func NewIndexer(tp IndexType, directoryPath string, sync bool) Indexer

NewIndexer initializes the index according to the data structure type

type Item

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

Item defines each item to be inserted into the BTree structure

func (*Item) Less

func (i *Item) Less(rhs btree.Item) bool

Less compares the current item with the right-hand side item it can be used to determine the order of the item in the BTree

type Iterator

type Iterator interface {
	// Rewind returns to the start (first item) of the iterator
	Rewind()

	// Seek finds the first target key that is greater than (or less than) or equal to the key passed in
	// and starts traversing from this key
	Seek(key []byte)

	// Next jumps to the next key
	Next()

	// Valid checks the validity
	// by checking whether all keys have been traversed, which can be used to exit traversal
	Valid() bool

	// Key returns the current iterating Key data
	Key() []byte

	// Value returns the current iterating Value data
	Value() *data.LogRecordPos

	// Close closes the iterator, freeing the resources
	Close()
}

Iterator defines a generic index iterator

Jump to

Keyboard shortcuts

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