indexing

package
v0.0.0-...-f7bad0d Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUndefinedLookup = fmt.Errorf("undefined lookup")

ErrUndefinedLookup is an error for situations in which the indexer has no optimized lookup for the given arguments.

Functions

func LookupPartitions

func LookupPartitions(
	store *refstore.Store,
	parts badgerutils.Iterator[Partition],
	opts badger.IteratorOptions,
) badgerutils.Iterator[[]byte]

LookupPartitions returns an iterator that iterates over the keys in the given partition iterator.

func PopulateRoaring32

func PopulateRoaring32(bm *roaring.Bitmap, iter badgerutils.Iterator[[]byte]) error

PopulateRoaring32 populates a roaring bitmap with 32-bit integers from an iterator of byte slices.

func PopulateRoaring64

func PopulateRoaring64(bm *roaring64.Bitmap, iter badgerutils.Iterator[[]byte]) error

PopulateRoaring64 populates a roaring bitmap with 64-bit integers from an iterator of byte slices.

Types

type Extension

type Extension[T any] struct {
	// contains filtered or unexported fields
}

Extension is an extension for extensible stores that indexes the data with a given indexer.

func NewExtension

func NewExtension[T any](indexer Indexer[T]) *Extension[T]

NewExtension creates a new Extension.

func (*Extension[T]) Drop

func (e *Extension[T]) Drop() error

Drop implements the extensible.Extension interface.

func (*Extension[T]) Init

func (e *Extension[T]) Init(
	store badgerutils.BadgerStore,
	iter badgerutils.Iterator[*T],
) error

Init implements the extensible.Extension interface.

func (*Extension[T]) Lookup

func (e *Extension[T]) Lookup(opts badger.IteratorOptions, args ...any) (badgerutils.Iterator[[]byte], error)

Lookup queries the index with the given arguments and returns an iterator of keys.

func (*Extension[T]) OnDelete

func (e *Extension[T]) OnDelete(key []byte, value *T) error

OnDelete implements the extensible.Extension interface.

func (*Extension[T]) OnSet

func (e *Extension[T]) OnSet(key []byte, old, new *T, opts ...any) error

OnSet implements the extensible.Extension interface.

type Indexer

type Indexer[T any] interface {
	Index(v *T, set bool) ([]badgerutils.RawKVPair, error)
	Lookup(args ...any) (badgerutils.Iterator[Partition], error)
}

Indexer is an indexer.

type MapValueRetriever

type MapValueRetriever[T any] struct {
	// contains filtered or unexported fields
}

MapValueRetriever is a value retriever that retrieves the given field paths of struct and encodes them to bytes.

func NewMapValueRetriever

func NewMapValueRetriever[T any](
	extractor schema.PathExtractor[T],
	encodeFunc func(any) ([]byte, error),
	paths ...string,
) *MapValueRetriever[T]

NewMapValueRetriever creates a new map value retriever for the given struct type and field paths.

func (*MapValueRetriever[T]) RetrieveValue

func (r *MapValueRetriever[T]) RetrieveValue(v *T) ([]byte, error)

RetrieveValue implements the ValueRetriever interface.

type Partition

type Partition = expr.Range[[]byte]

Partition represents a range of keys from low to high with optional exclusivity on both ends.

func NewPartition

func NewPartition(low, high *expr.Bound[[]byte]) Partition

NewPartition creates a new partition with the given low and high keys and exclusivity.

type ValueInjector

type ValueInjector[T any] struct {
	// contains filtered or unexported fields
}

Indexer is a wrapper around an Indexer that injects custom values to the indexes.

func NewValueInjector

func NewValueInjector[T any](
	indexer Indexer[T],
	retriever ValueRetriever[T],
) *ValueInjector[T]

NewValueInjector creates a new value injector for the given indexer and value retriever

func (*ValueInjector[T]) Index

func (i *ValueInjector[T]) Index(v *T, set bool) ([]badgerutils.RawKVPair, error)

Index implements the Indexer interface.

func (*ValueInjector[T]) Lookup

func (i *ValueInjector[T]) Lookup(args ...any) (badgerutils.Iterator[Partition], error)

Lookup implements the Indexer interface.

type ValueRetriever

type ValueRetriever[T any] interface {
	RetrieveValue(v *T) ([]byte, error)
}

ValueRetriever is an interface that retrieves index custom values for index only scans from the indexed type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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