index

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 9 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

This section is empty.

Types

type ARTreeIterator

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

ART Index iterator

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 初始化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
}

BTree 索引迭代器

func NewARTreeIterator

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

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 索引
	Btree IndexType = iota + 1

	// ART 自适应基数数索引
	ART
)

type Indexer

type Indexer interface {
	// Put 向索引中存储 key 对应的数据位置信息
	Put(key []byte, pst *data.LogRecordPst) bool

	// Get 根据 key 取出对应的索引位置信息
	Get(key []byte) *data.LogRecordPst

	// Delete 根据 key 删除对应的索引位置信息
	Delete(key []byte) bool

	// Size 索引中的数据量
	Size() int

	// Iterator 索引迭代器
	Iterator(reverse bool) Iterator
}

Indexer 索引接口抽象层,后续如果想要接入其他的数据结构,则直接实现这个接口

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 重新回到迭代器的起点,即第一个数据
	Rewind()

	// Seek 根据传入的 key 查找到一个 >= 或 <= 的目标 key,从这个目标 key 开始遍历
	Seek(key []byte)

	// Next 跳转到下一个 key
	Next()

	// Valid 是否有效,即是否已经遍历完了所有 key,用于退出遍历 ==> true->是  false-->否
	Valid() bool

	// Key 当前遍历位置的 key 数据
	Key() []byte

	// Value 当前遍历位置的 value 数据
	Value() *data.LogRecordPst

	// Close 关闭迭代器,释放相应资源
	Close()
}

Iterator 通用索引迭代器

Jump to

Keyboard shortcuts

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