trie

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IterFn

type IterFn func(key []byte, uid uint64) error

type Trie

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

Trie is an implementation of Ternary Search Tries to store XID to UID map. It uses Arena to allocate nodes in the trie. It is not thread-safe.

func NewTrie

func NewTrie(_ string) *Trie

NewTrie would return back a Trie backed by the provided Arena. Trie would assume ownership of the Arena. Release must be called at the end to release Arena's resources.

func NewTrieFromBuffer added in v1.8.0

func NewTrieFromBuffer(buf *buffer.Buffer) *Trie

func (*Trie) Bytes added in v1.8.0

func (t *Trie) Bytes() []byte

func (*Trie) Get

func (t *Trie) Get(key []byte) uint64

Get would return the UID for the key. If the key is not found, it would return 0.

func (*Trie) Iterate

func (t *Trie) Iterate(fn IterFn) error

func (*Trie) IterateWIthPrefix

func (t *Trie) IterateWIthPrefix(prefix []byte, fn IterFn) error

func (*Trie) Put

func (t *Trie) Put(key []byte, uid uint64)

Put would store the UID for the key.

func (*Trie) Release

func (t *Trie) Release() error

Release would release the resources used by the Arena.

func (*Trie) Size

func (t *Trie) Size() uint32

Size returns the size of Arena used by this Trie so far.

Jump to

Keyboard shortcuts

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