skl

package
v1.7.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const MaxNodeSize = int(unsafe.Sizeof(node{}))

MaxNodeSize is the memory footprint of a node of maximum height.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arena

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

Arena should be lock-free.

type Iterator

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

Iterator is an iterator over skiplist object. For new objects, you just need to initialize Iterator.list.

func (*Iterator) Close

func (s *Iterator) Close() error

Close frees the resources held by the iterator

func (*Iterator) Key

func (s *Iterator) Key() []byte

Key returns the key at the current position.

func (*Iterator) Next

func (s *Iterator) Next()

Next advances to the next position.

func (*Iterator) Prev

func (s *Iterator) Prev()

Prev advances to the previous position.

func (*Iterator) Seek

func (s *Iterator) Seek(target []byte)

Seek advances to the first entry with a key >= target.

func (*Iterator) SeekForPrev

func (s *Iterator) SeekForPrev(target []byte)

SeekForPrev finds an entry with key <= target.

func (*Iterator) SeekToFirst

func (s *Iterator) SeekToFirst()

SeekToFirst seeks position at the first entry in list. Final state of iterator is Valid() iff list is not empty.

func (*Iterator) SeekToLast

func (s *Iterator) SeekToLast()

SeekToLast seeks position at the last entry in list. Final state of iterator is Valid() iff list is not empty.

func (*Iterator) Valid

func (s *Iterator) Valid() bool

Valid returns true iff the iterator is positioned at a valid node.

func (*Iterator) Value

func (s *Iterator) Value() y.ValueStruct

Value returns value.

type Skiplist

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

Skiplist maps keys to values (in memory)

func NewSkiplist

func NewSkiplist(arenaSize int64) *Skiplist

NewSkiplist makes a new empty skiplist, with a given arena size

func (*Skiplist) DecrRef

func (s *Skiplist) DecrRef()

DecrRef decrements the refcount, deallocating the Skiplist when done using it

func (*Skiplist) Empty

func (s *Skiplist) Empty() bool

Empty returns if the Skiplist is empty.

func (*Skiplist) Get

func (s *Skiplist) Get(key []byte) y.ValueStruct

Get gets the value associated with the key. It returns a valid value if it finds equal or earlier version of the same key.

func (*Skiplist) IncrRef

func (s *Skiplist) IncrRef()

IncrRef increases the refcount

func (*Skiplist) MemSize

func (s *Skiplist) MemSize() int64

MemSize returns the size of the Skiplist in terms of how much memory is used within its internal arena.

func (*Skiplist) NewIterator

func (s *Skiplist) NewIterator() *Iterator

NewIterator returns a skiplist iterator. You have to Close() the iterator.

func (*Skiplist) NewUniIterator

func (s *Skiplist) NewUniIterator(reversed bool) *UniIterator

NewUniIterator returns a UniIterator.

func (*Skiplist) Put

func (s *Skiplist) Put(key []byte, v y.ValueStruct)

Put inserts the key-value pair.

type UniIterator

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

UniIterator is a unidirectional memtable iterator. It is a thin wrapper around Iterator. We like to keep Iterator as before, because it is more powerful and we might support bidirectional iterators in the future.

func (*UniIterator) Close

func (s *UniIterator) Close() error

Close implements y.Interface (and frees up the iter's resources)

func (*UniIterator) Key

func (s *UniIterator) Key() []byte

Key implements y.Interface

func (*UniIterator) Next

func (s *UniIterator) Next()

Next implements y.Interface

func (*UniIterator) Rewind

func (s *UniIterator) Rewind()

Rewind implements y.Interface

func (*UniIterator) Seek

func (s *UniIterator) Seek(key []byte)

Seek implements y.Interface

func (*UniIterator) Valid

func (s *UniIterator) Valid() bool

Valid implements y.Interface

func (*UniIterator) Value

func (s *UniIterator) Value() y.ValueStruct

Value implements y.Interface

Jump to

Keyboard shortcuts

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