index

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOpenBPTreeFailed   = errors.New("OpenBPTreeFailedError : failed to open bptree")
	ErrCreateBucketFailed = errors.New("CreateBucketFailedError : failed to create bucket in bptree")
	ErrPutValueFailed     = errors.New("PutValueFailedError : failed to put value in bptree")
	ErrGetValueFailed     = errors.New("GetValueFailedError : failed to get value in bptree")
	ErrDeleteValueFailed  = errors.New("DeleteValueFailedError : failed to delete value in bptree")
	ErrGetIndexSizeFailed = errors.New("GetIndexSizeFailedError : failed to get index size in bptree")
	ErrBeginTxFailed      = errors.New("BeginTxFailedError : failed to begin tx in bptree")
	ErrRollbackTxFailed   = errors.New("RollbackTxFailedError : failed to rollback tx in bptree")
)

Functions

func Compare added in v1.0.8

func Compare(a, b []byte) int

Types

type ARTreeIterator

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

ART Index iterator

func NewARTreeIterator

func NewARTreeIterator(tree art.Tree, reverse bool) *ARTreeIterator

func (*ARTreeIterator) Close

func (artree *ARTreeIterator) Close()

func (*ARTreeIterator) Key

func (artree *ARTreeIterator) Key() []byte

func (*ARTreeIterator) Next

func (artree *ARTreeIterator) Next()

func (*ARTreeIterator) Rewind

func (artree *ARTreeIterator) Rewind()

func (*ARTreeIterator) Seek

func (artree *ARTreeIterator) Seek(key []byte)

func (*ARTreeIterator) Valid

func (artree *ARTreeIterator) Valid() bool

func (*ARTreeIterator) Value

func (artree *ARTreeIterator) Value() *data.LogRecordPst

type AdaptiveRadixTree

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

Adaptive Radix Tree Index The following link is the ART library written by go. If you need to know more about it, please go to the corresponding warehouse. https://github.com/plar/go-adaptive-radix-tree

func NewART

func NewART() *AdaptiveRadixTree

NewART Initializes the adaptive radix tree index

func (*AdaptiveRadixTree) Delete

func (artree *AdaptiveRadixTree) Delete(key []byte) bool

func (*AdaptiveRadixTree) Get

func (artree *AdaptiveRadixTree) Get(key []byte) *data.LogRecordPst

func (*AdaptiveRadixTree) Iterator

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

func (*AdaptiveRadixTree) Put

func (artree *AdaptiveRadixTree) Put(key []byte, pst *data.LogRecordPst) bool

func (*AdaptiveRadixTree) Size

func (artree *AdaptiveRadixTree) Size() int

type BPlusTree

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

BPlusTree B+ Tree Index go.etcd.io/bbolt This is the library that encapsulates b+ tree Again, if you need to look at the source code for b+ trees, The following link is a good place to start https://github.com/etcd-io/bbolt

func NewBPlusTree

func NewBPlusTree(dirPath string) *BPlusTree

NewBPlusTree Initializes the B+ tree index

func (*BPlusTree) Delete

func (bptree *BPlusTree) Delete(key []byte) bool

Delete Deletes the key-value pair corresponding to the key from the B+ tree index The argument to the Delete method is required to be a byte array The argument is the key, and the return value is a bool value If the key does not exist, false is returned

func (*BPlusTree) Get

func (bptree *BPlusTree) Get(key []byte) *data.LogRecordPst

Get Gets the value corresponding to the key from the B+ tree index The argument to the Get method is required to be a byte array The argument is the key, and the return value is the value corresponding to the key If the key does not exist, nil is returned

func (*BPlusTree) Iterator

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

Iterator Gets the iterator of the B+ tree index The argument to the Iterator method is required to be a bool value The argument is the traversal direction of the iterator, and the return value is an iterator If the argument is true, the iterator is traversed in reverse order, otherwise it is traversed in order

func (*BPlusTree) Put

func (bptree *BPlusTree) Put(key []byte, pst *data.LogRecordPst) bool

Put Inserts a key-value pair into the B+ tree index The two arguments to the Put method The first argument is the key, and the second argument is the value The key is the primary key of the data, and the value is the offset of the data in the data file

func (*BPlusTree) Size

func (bptree *BPlusTree) Size() int

Size Gets the number of key-value pairs in the B+ tree index The return value is an int value If the index is empty, 0 is returned

type BTree

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

func NewBTree

func NewBTree() *BTree

NewBTree initializes a new BTree.

func (*BTree) Delete

func (bt *BTree) Delete(key []byte) bool

func (*BTree) Get

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

func (*BTree) Iterator

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

func (*BTree) Put

func (bt *BTree) Put(key []byte, pst *data.LogRecordPst) bool

func (*BTree) Size

func (bt *BTree) Size() int

type BtreeIterator

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

BTreeIterator represents an iterator for BTree index.

func NewBTreeIterator

func NewBTreeIterator(tree *btree.BTree, reverse bool) *BtreeIterator

func (*BtreeIterator) Close

func (bi *BtreeIterator) Close()

func (*BtreeIterator) Key

func (bi *BtreeIterator) Key() []byte

func (*BtreeIterator) Next

func (bi *BtreeIterator) Next()

func (*BtreeIterator) Rewind

func (bi *BtreeIterator) Rewind()

func (*BtreeIterator) Seek

func (bi *BtreeIterator) Seek(key []byte)

func (*BtreeIterator) Valid

func (bi *BtreeIterator) Valid() bool

func (*BtreeIterator) Value

func (bi *BtreeIterator) Value() *data.LogRecordPst

type IndexType

type IndexType = int8
const (
	// Btree Index
	Btree IndexType = iota + 1

	// ART Index
	ART

	// SkipList Index
	SkipListIndex
)

type Indexer

type Indexer interface {
	// Put stores the position information of the key in the index.
	Put(key []byte, pst *data.LogRecordPst) bool

	// Get retrieves the position information of the key from the index.
	Get(key []byte) *data.LogRecordPst

	// Delete deletes the position information of the key from the index.
	Delete(key []byte) bool

	// Size returns the number of entries in the index.
	Size() int

	// Iterator returns an iterator for the index.
	Iterator(reverse bool) Iterator
}

Indexer index interface abstraction layer. If you want to access other data structures, you can directly implement this interface

func NewIndexer

func NewIndexer(typeIndex IndexType, dirPath string) Indexer

type Item

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

func (*Item) Less

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

type Iterator

type Iterator interface {
	// Rewind resets the iterator to the beginning, i.e., the first entry.
	Rewind()

	// Seek seeks to a target key that is >= or <= the given key, depending on the implementation.
	Seek(key []byte)

	// Next moves to the next key.
	Next()

	// Valid returns whether the iterator is still valid, i.e., if all keys have been traversed.
	Valid() bool

	// Key returns the key at the current iterator position.
	Key() []byte

	// Value returns the value (position information) at the current iterator position.
	Value() *data.LogRecordPst

	// Close closes the iterator and releases any resources.
	Close()
}

Iterator is a generic index iterator.

type SkipList added in v1.0.8

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

SkipList Memory Index based on https://github.com/chen3feng/stl4go

func NewSkipList added in v1.0.8

func NewSkipList() *SkipList

NewSkipList Initialize the SkipList index

func (*SkipList) Delete added in v1.0.8

func (sl *SkipList) Delete(key []byte) bool

Delete Deletes the key-value pair corresponding to the key from the SkipList index

func (*SkipList) Get added in v1.0.8

func (sl *SkipList) Get(key []byte) *data.LogRecordPst

Get Gets the value corresponding to the key from the SkipList index

func (*SkipList) Iterator added in v1.0.8

func (sl *SkipList) Iterator(reverse bool) Iterator

Iterator Gets the iterator of the SkipList index If the reverse is true, the iterator is traversed in reverse order, otherwise it is traversed in order

func (*SkipList) Put added in v1.0.8

func (sl *SkipList) Put(key []byte, pst *data.LogRecordPst) bool

Put Inserts a key-value pair into the SkipList index

func (*SkipList) Size added in v1.0.8

func (sl *SkipList) Size() int

Size Gets the number of key-value pairs in the SkipList index

type SkipListIterator added in v1.0.8

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

func NewSkipListIterator added in v1.0.8

func NewSkipListIterator(sl *SkipList, reverse bool) *SkipListIterator

NewSkipListIterator Initializes the SkipList index iterator

func (*SkipListIterator) Close added in v1.0.8

func (sl *SkipListIterator) Close()

Close Closes the iterator

func (*SkipListIterator) Key added in v1.0.8

func (sl *SkipListIterator) Key() []byte

Key Gets the key at the current iterator position

func (*SkipListIterator) Next added in v1.0.8

func (sl *SkipListIterator) Next()

Next Positions the iterator to the next key If the iterator is positioned at the last key, the iterator is positioned to the start of the iterator

func (*SkipListIterator) Rewind added in v1.0.8

func (sl *SkipListIterator) Rewind()

Rewind Resets the iterator to the beginning

func (*SkipListIterator) Seek added in v1.0.8

func (sl *SkipListIterator) Seek(key []byte)

Seek Positions the iterator to the first key that is greater or equal to the specified key

func (*SkipListIterator) Valid added in v1.0.8

func (sl *SkipListIterator) Valid() bool

Valid Determines whether the iterator is positioned at a valid key

func (*SkipListIterator) Value added in v1.0.8

func (sl *SkipListIterator) Value() *data.LogRecordPst

Value Gets the value at the current iterator position

Jump to

Keyboard shortcuts

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