indexer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CopyOnWriteIndexer

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

CopyOnWriteIndexer allows user to update the index. Internally it uses a loader to periodically reload index by applying the ADD/DEL/UPD operations.

func NewCopyOnWriteIndexer

func NewCopyOnWriteIndexer(items []*expr.Conjunction, refreshInterval int) (*CopyOnWriteIndexer, error)

NewCopyOnWriteIndexer creats a new CopyOnWriteIndexer with given items. It internally uses a loader to periodically reload index.

func (*CopyOnWriteIndexer) Add

Add adds a new conjunction into index, this operation will be first buffered in a queue and be applied in a batcch way once the ticker is triggered. So the new item won't be updated immediately but with a lag.

func (*CopyOnWriteIndexer) Delete

func (u *CopyOnWriteIndexer) Delete(ID int) error

Delete deletes a conjunction by ID.

func (*CopyOnWriteIndexer) Get

func (u *CopyOnWriteIndexer) Get(conjunctionSize int, labels expr.Assignment) []*Record

Get gets the matched records.

func (*CopyOnWriteIndexer) MaxKSize

func (u *CopyOnWriteIndexer) MaxKSize() int

type IndexOp

type IndexOp struct {
	OpType string
	Data   interface{}
}

func (*IndexOp) Context

func (i *IndexOp) Context() interface{}

func (*IndexOp) Type

func (i *IndexOp) Type() string

type Indexer

type Indexer interface {
	MaxKSize() int
	Get(conjunctionSize int, labels expr.Assignment) []*Record
}

Indexer defines the top level indexer interface

type MemReadOnlyIndexer

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

MemReadOnlyIndexer implements the Indexer interface and stores all the entries in memory.

func NewMemReadOnlyIndexer

func NewMemReadOnlyIndexer(items []*expr.Conjunction) (*MemReadOnlyIndexer, error)

NewMemReadOnlyIndexer create a memory stored indexer. This kind of indexer is thread-safe.

func (*MemReadOnlyIndexer) Build

func (k *MemReadOnlyIndexer) Build() error

Build finalise the build-up of indexer by calling the Build on each shards.

func (*MemReadOnlyIndexer) Get

func (k *MemReadOnlyIndexer) Get(size int, labels expr.Assignment) []*Record

Get returns the list of Record, based on size and labels.

func (*MemReadOnlyIndexer) MaxKSize

func (k *MemReadOnlyIndexer) MaxKSize() int

MaxKSize returns the max K-size of the conjunctions stored in indexer.

type MutableIndexer

type MutableIndexer interface {
	MaxKSize() int
	Add(c *expr.Conjunction) error
	Delete(ID int) error
	Get(conjunctionSize int, labels expr.Assignment) []*Record
}

MutableIndexer top level interface

type Record

type Record struct {
	PostingList posting.List
	Key         string
	Value       string
}

Record represents a key-value entry in indexer shard.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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