index

package
v0.0.0-...-de123dd Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package index contains data structures to help cope with caches, indices and key filters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	*lru.ARCCache
}

Cache implements a simple ARC cache.

func NewCache

func NewCache(size int) *Cache

NewCache initializes a new cache with the given size.

type Filter

type Filter struct {
	*bloom.BloomFilter
}

Filter implements a simple key filter based on a bloom filter.

func NewFilter

func NewFilter() *Filter

NewFilter initializes a new bloom filter.

type Index

type Index struct {
	*redblacktree.Tree
}

Index implements an in-memory key-offset map.

func NewIndex

func NewIndex() *Index

NewIndex constructs a new key-offset index.

func (*Index) Get

func (index *Index) Get(key []byte) (int64, bool)

Get returns the offset associated with the given key.

func (*Index) ReadFrom

func (index *Index) ReadFrom(file io.Reader) (int64, error)

ReadFrom deserializes the given binary stream and stores all read key-offset pairs in the index.

func (*Index) WriteTo

func (index *Index) WriteTo(file io.Writer) (int64, error)

WriteTo serializes the index and writes it to the given stream in a binary format.

type Memory

type Memory struct {
	*redblacktree.Tree
	// contains filtered or unexported fields
}

Memory is an in-memory key-valueset store.

func NewMemory

func NewMemory() *Memory

NewMemory initializes a new in-memory key-valueset store.

func (*Memory) Get

func (memory *Memory) Get(key []byte) [][]byte

Get returns the valueset for the given key.

func (*Memory) Iterator

func (memory *Memory) Iterator() MemoryIterator

Iterator returns an abstraction to iterate through all key-value pairs in the tree.

func (*Memory) Put

func (memory *Memory) Put(key []byte, value []byte)

Put stores the given key-value pair in the in-memory tree.

func (*Memory) SetIterator

func (memory *Memory) SetIterator() MemorySetIterator

SetIterator returns an abstraction to iterate through all key-valueset pairs in the tree.

type MemoryIterator

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

MemoryIterator implements an iterator for scanning through key-value pairs.

func (*MemoryIterator) Key

func (iterator *MemoryIterator) Key() []byte

Key returns the key of the current pair pointer.

func (*MemoryIterator) Next

func (iterator *MemoryIterator) Next() bool

Next fetches the next pair and returns true on success

func (*MemoryIterator) Value

func (iterator *MemoryIterator) Value() []byte

Value returns the value of the current pair pointer.

type MemorySetIterator

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

MemorySetIterator implements an iterator for scanning through key-valueset pairs.

func (*MemorySetIterator) Key

func (iterator *MemorySetIterator) Key() []byte

Key returns the pair's key.

func (*MemorySetIterator) Next

func (iterator *MemorySetIterator) Next() bool

Next fetches the next pair and returns true on success.

func (*MemorySetIterator) Values

func (iterator *MemorySetIterator) Values() [][]byte

Values returns the pair's valueset.

type RunIndex

type RunIndex struct {
	*redblacktree.Tree
}

func NewRunIndex

func NewRunIndex() *RunIndex

type ValueSet

type ValueSet struct {
	*treeset.Set
	// contains filtered or unexported fields
}

func NewValueSet

func NewValueSet() *ValueSet

func (*ValueSet) Add

func (set *ValueSet) Add(value []byte)

func (*ValueSet) Values

func (set *ValueSet) Values() [][]byte

Jump to

Keyboard shortcuts

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