index

package
v0.0.0-...-50ac2b6 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 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 自适应基数树索引 主要封装了 https://github.com/plar/go-adaptive-radix-tree 库

func NewART

func NewART() *AdaptiveRadixTree

NewART 初始化自适应基数树索引

func (*AdaptiveRadixTree) Close

func (art *AdaptiveRadixTree) Close() error

func (*AdaptiveRadixTree) Delete

func (art *AdaptiveRadixTree) Delete(key []byte) 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) bool

func (*AdaptiveRadixTree) Size

func (art *AdaptiveRadixTree) Size() int

type BPlusTree

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

BPlusTree B+ 树索引 主要封装了 go.etcd.io/bbolt 库

func NewBPlusTree

func NewBPlusTree(dirPath string, syncWrites bool) *BPlusTree

NewBPlusTree 初始化 B+ 树索引

func (*BPlusTree) Close

func (bpt *BPlusTree) Close() error

func (*BPlusTree) Delete

func (bpt *BPlusTree) Delete(key []byte) 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) bool

func (*BPlusTree) Size

func (bpt *BPlusTree) Size() int

type BTree

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

BTree 索引,主要封装了 google 的 btree ku https://github.com/google/btree

func NewBTree

func NewBTree() *BTree

func (*BTree) Close

func (bt *BTree) Close() error

func (*BTree) Delete

func (bt *BTree) Delete(key []byte) 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) bool

func (*BTree) Size

func (bt *BTree) Size() int

type IndexType

type IndexType = int8
const (
	Btree IndexType = iota + 1 // Btree索引

	ART // Adaptive Radix Tree索引

	// BPTree B+ 树索引
	BPTree
)

type Indexer

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

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

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

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

	// Iterator 迭代器
	Iterator(reverse bool) Iterator

	// Close 关闭索引
	Close() error
}

抽象索引接口,目前接入google的btree,后续如果要更换其他数据结构,则可以直接实现这个接口

func NewIndexer

func NewIndexer(typ IndexType, dirPath string, sync bool) Indexer

type Item

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

func (*Item) Less

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

放入btree的item必须要实现这个Less方法,因为btree需要对item进行排序

type Iterator

type Iterator interface {
	// Rewind 重新回到迭代器的起点,即第一个数据
	Rewind()

	// Seek 根据传入的 key 查找到第一个大于(或小于)等于的目标 key,根据从这个 key 开始遍历
	Seek(key []byte)

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

	// Valid 是否有效,即是否已经遍历完了所有的 key,用于退出遍历
	Valid() bool

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

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

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

Iterator 通用索引迭代器

Jump to

Keyboard shortcuts

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