index

package
v0.0.0-...-1c06873 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	Node
	// contains filtered or unexported fields
}

Element 跳表存储元素定义

func (*Element) Key

func (e *Element) Key() []byte

Key 跳表元素 key

func (*Element) Next

func (e *Element) Next() *Element

Next 跳表的第一层索引是原始数据,有序排序,可根据next方法获得一个串联所有数据的链表

func (*Element) SetValue

func (e *Element) SetValue(val interface{})

SetValue set the elem val

func (*Element) Value

func (e *Element) Value() interface{}

Value 跳表元素 value

type Indexer

type Indexer struct {
	Meta      *storage.Meta //元数据信息  metadata info
	FileId    uint32        //存储数据的文件id 	the file id of storing the data
	EntrySize uint32        //数据条目entry的大小 the size of entry
	Offset    int64         //entry数据的查询起始位置    entry data query start position
}

type Node

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

Node 跳表节点

type SkipList

type SkipList struct {
	Node

	Len int
	// contains filtered or unexported fields
}

SkipList 跳表定义

func NewSkipList

func NewSkipList() *SkipList

NewSkipList 初始化一个空跳表

func (*SkipList) Exist

func (t *SkipList) Exist(key []byte) bool

Exist judge if the key exists

func (*SkipList) FindPrefix

func (t *SkipList) FindPrefix(prefix []byte) *Element

FindPrefix 找到第一个和前缀匹配的Element

func (*SkipList) Foreach

func (t *SkipList) Foreach(fun handleEle)

Foreach 遍历跳表中的每一个元素

func (*SkipList) Front

func (t *SkipList) Front() *Element

Front get the head element

e := list.Front()
for p := e; p!= nil; p = p.next() {
	-----
}

func (*SkipList) Get

func (t *SkipList) Get(key []byte) *Element

Get 根据key查找对应的 Element 元素 未找到返回nil

func (*SkipList) Put

func (t *SkipList) Put(key []byte, value interface{}) *Element

Put store a element to skiplist, if the key already exists, update the value 因此此链表暂时不支持相同的key

func (*SkipList) Remove

func (t *SkipList) Remove(key []byte) *Element

Remove 根据key 删除跳表中对应的元素,返回删除后元素的指针

Jump to

Keyboard shortcuts

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