indexing

package
v0.0.0-...-50414e9 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookupChunks

func LookupChunks(
	store *refstore.Instance,
	parts badgerutils.Iterator[[]byte, Chunk],
	opts badger.IteratorOptions,
) badgerutils.Iterator[[]byte, []byte]

LookupChunks returns an iterator that iterates over the keys in the given chunk iterator.

func NewExtension

func NewExtension[K, V any](indexer Indexer[V]) extstore.Extension[K, V]

NewExtension creates a new Extension.

func PopulateRoaring32

func PopulateRoaring32(bm *roaring.Bitmap, iter badgerutils.Iterator[[]byte, []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, []byte]) error

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

Types

type Chunk

type Chunk = expr.Range[[]byte]

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

func NewChunk

func NewChunk(low, high *expr.Bound[[]byte]) Chunk

NewChunk creates a new chunk with the given low and high keys and exclusivity.

type Extension

type Extension[K, V any] struct {
	// contains filtered or unexported fields
}

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

func (*Extension[K, V]) Instantiate

func (e *Extension[K, V]) Instantiate(txn *badger.Txn) extstore.ExtensionInstance[K, V]

Instantiate implements the extensible.Extension interface.

func (*Extension[K, V]) RegisterStore

func (e *Extension[K, V]) RegisterStore(store badgerutils.Instantiator[badgerutils.BadgerStore])

Init implements the extensible.Extension interface.

type ExtensionInstance

type ExtensionInstance[K, V any] struct {
	// contains filtered or unexported fields
}

func (*ExtensionInstance[K, V]) Lookup

func (e *ExtensionInstance[K, V]) Lookup(opts badger.IteratorOptions, args ...any) (badgerutils.Iterator[[]byte, []byte], error)

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

func (*ExtensionInstance[K, V]) OnDelete

func (e *ExtensionInstance[K, V]) OnDelete(_ context.Context, key K, value *V) error

OnDelete implements the extensible.Extension interface.

func (*ExtensionInstance[K, V]) OnSet

func (e *ExtensionInstance[K, V]) OnSet(ctx context.Context, key K, old, new *V, opts ...any) error

OnSet implements the extensible.Extension interface.

func (*ExtensionInstance[K, V]) SupportedQueries

func (e *ExtensionInstance[K, V]) SupportedQueries() []string

SupportedQueries returns the supported queries of the index.

func (*ExtensionInstance[K, V]) SupportedValues

func (e *ExtensionInstance[K, V]) SupportedValues() []string

SupportedValues returns the supported values of the index.

type IndexDescriptor

type IndexDescriptor interface {
	SupportedQueries() []string
	SupportedValues() []string
}

IndexDescriptor is an index describer.

type Indexer

type Indexer[T any] interface {
	Index(v *T, set bool) ([]badgerutils.RawKVPair, error)
	Lookup(args ...any) (badgerutils.Iterator[[]byte, Chunk], 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]) Paths

func (r *MapValueRetriever[T]) Paths() []string

Paths implements the ValueRetriever interface.

func (*MapValueRetriever[T]) RetrieveValue

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

RetrieveValue implements the ValueRetriever interface.

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[[]byte, Chunk], error)

Lookup implements the Indexer interface.

func (*ValueInjector[T]) SupportedQueries

func (i *ValueInjector[T]) SupportedQueries() []string

SupportedQueries implements the IndexDescriber interface.

func (*ValueInjector[T]) SupportedValues

func (i *ValueInjector[T]) SupportedValues() []string

SupportedValues implements the IndexDescriber interface.

type ValueRetriever

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

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