xdata

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BPTreePageType      = 1 // 叶子页
	BPTreePageTypeIndex = 2 // 索引页
)

Variables

View Source
var (
	NotFoundError = errors.New("NotFound")
)

Functions

func NewConsistent

func NewConsistent(replicas int, salt string, hf HashFunc) *consistentHash

NewConsistent 创建一致性hash算法结构体,设置默认节点数量

Types

type BPTree

type BPTree struct {
	Order    int
	RootPage *BPTreePage
	LeafPage *BPTreePage
}

func NewBPTree

func NewBPTree(order int) BPTree

NewBPTree @Description: B+树实现,B+树的索引节点在下层节点中,每一个索引节点对应下层的一个子分页,这与B树不同,B树是左右子分页的结构 @param order int @return BPTree

func (*BPTree) Delete

func (bp *BPTree) Delete(index int) (data interface{}, err error)

func (*BPTree) Insert

func (bp *BPTree) Insert(index int, data interface{})

func (*BPTree) Search

func (bp *BPTree) Search(index int) (data interface{}, err error)

type BPTreeNode

type BPTreeNode struct {
	Index     int
	Data      interface{}
	Next      *BPTreeNode
	Page      *BPTreePage
	ChildPage *BPTreePage
}

type BPTreePage

type BPTreePage struct {
	Type       int
	Pre, Next  *BPTreePage
	ParentNode *BPTreeNode
	HeadNode   *BPTreeNode
	Len        int
	Cap        int
}

func (*BPTreePage) DeleteByIndex

func (page *BPTreePage) DeleteByIndex(index int) *BPTreeNode

func (*BPTreePage) Insert

func (page *BPTreePage) Insert(node *BPTreeNode)

func (*BPTreePage) Split

func (page *BPTreePage) Split() (*BPTreePage, *BPTreePage)

func (*BPTreePage) Up

func (page *BPTreePage) Up()

type HashFunc

type HashFunc func(data []byte) uint32

type Response

type Response struct {
	Code int
	Data interface{}
}

Jump to

Keyboard shortcuts

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