index

package
v0.0.0-...-d2c5623 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: GPL-3.0, GPL-3.0-or-later Imports: 9 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

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 B+ 树索引,封装了 主要封装了 https://github.com/etcd-io/bbolt

func NewBPlusTree

func NewBPlusTree(dirPath string, syncWrites bool) *BPlusTree

func (*BPlusTree) Close

func (b *BPlusTree) Close() error

func (*BPlusTree) Delete

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

func (*BPlusTree) Get

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

func (*BPlusTree) Iterator

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

func (*BPlusTree) Put

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

func (*BPlusTree) Size

func (b *BPlusTree) Size() int

type BTree

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

BTree 索引,封装了 google btree 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) (*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 IndexType = iota + 1

	ART // Adaptive Radix Tree 自适应基数树索引
	BPT // B+ 树索引
)

type Indexer

type Indexer interface {
	// Put 向索引中存储 key 对应的数据位置信息, 返回旧的数据位置信息
	Put(key []byte, pos *data.LogRecordPos) *data.LogRecordPos
	// Get 从索引中获取 key 对应的数据位置信息
	Get(key []byte) *data.LogRecordPos
	// Delete 从索引中删除 key 对应的数据位置信息, 返回旧的数据位置信息
	Delete(key []byte) (*data.LogRecordPos, bool)
	// Size 返回索引中元素的数量
	Size() int
	// Iterator 返回一个迭代器,用于遍历索引中的所有元素
	Iterator(reverse bool) Iterator
	// Close 关闭索引
	Close() error
}

Indexer 抽象索引接口

func NewIndexer

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

NewIndexer 根据类型初始化索引

type Item

type Item struct {
	Key []byte
	Pos *data.LogRecordPos
}

func (*Item) Less

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

type Iterator

type Iterator interface {
	Rewind()                   // 重置迭代器,使其指向索引中的第一个元素
	Seek(key []byte)           // 重置迭代器,使其指向索引中第一个大于(或小于) key 的元素
	Next()                     // 使迭代器指向索引中的下一个元素
	Valid() bool               // 判断迭代器是否有效
	Key() []byte               // 遍历位置的 key
	Value() *data.LogRecordPos // 遍历位置的 value
	Close()                    // 关闭迭代器
}

Iterator 通用的索引迭代器

Jump to

Keyboard shortcuts

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