index

package
v0.0.0-...-63846e3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 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
}

func NewART

func NewART() *AdaptiveRadixTree

NewART 新建 ART 索引

func (*AdaptiveRadixTree) Close

func (art *AdaptiveRadixTree) Close() error

func (*AdaptiveRadixTree) Delete

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

func (*AdaptiveRadixTree) Get

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

func (*AdaptiveRadixTree) Iterator

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

Iterator 索引迭代器

func (*AdaptiveRadixTree) Put

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

func (*AdaptiveRadixTree) Size

func (art *AdaptiveRadixTree) Size() int

type BPlusTree

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

BPlusTree B+树索引,将索引存储到磁盘上

func NewBPlusTree

func NewBPlusTree(dirPath string, sync bool) *BPlusTree

func (*BPlusTree) Close

func (bpt *BPlusTree) Close() error

func (*BPlusTree) Delete

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

func (*BPlusTree) Get

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

func (*BPlusTree) Iterator

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

func (*BPlusTree) Put

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

func (*BPlusTree) Size

func (bpt *BPlusTree) Size() int

type BTree

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

func NewBTree

func NewBTree() *BTree

NewBTree new BTree structure

func (*BTree) Close

func (bt *BTree) Close() error

func (*BTree) Delete

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

Delete 返回的是旧的value, 如果不存在则返回nil, true

func (*BTree) Get

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

func (*BTree) Iterator

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

func (*BTree) Put

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

func (*BTree) Size

func (bt *BTree) Size() int

type IndexType

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

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

	// BPTree B+树索引
	BPTree
)

type Indexer

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

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

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

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

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

	Close() error
}

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 (i *Item) Less(bi btree.Item) bool

Less 因为在BTree里数据排列都是有序的,所以这里的less方法是比较key的大小的规则

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.Position

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

Iterator 通用索引迭代器

Jump to

Keyboard shortcuts

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