index

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package index implements the index system for searching data.

Index

Constants

This section is empty.

Variables

View Source
var DummyFieldIterator = &dummyIterator{}

DummyFieldIterator never iterates.

Functions

func FieldStr added in v0.3.0

func FieldStr(key FieldKey, term []byte) string

FieldStr return a string represent of Field which is composed by key and term.

func UnmarshalTerm added in v0.3.0

func UnmarshalTerm(raw []byte) []byte

UnmarshalTerm decodes term from a encoded field.

Types

type Batch added in v0.6.0

type Batch struct {
	Applied   chan struct{}
	Documents Documents
}

Batch is a collection of documents.

type Document added in v0.6.0

type Document struct {
	Fields       []Field
	EntityValues []byte
	DocID        uint64
}

Document represents a document in a index.

type Documents added in v0.6.0

type Documents []Document

Documents is a collection of documents.

type Field

type Field struct {
	Term []byte
	Key  FieldKey
}

Field is a indexed item in a document.

func (Field) Marshal

func (f Field) Marshal() []byte

Marshal encodes f to bytes.

func (*Field) Unmarshal

func (f *Field) Unmarshal(raw []byte) error

Unmarshal decodes bytes to f.

type FieldIterable

type FieldIterable interface {
	Iterator(fieldKey FieldKey, termRange RangeOpts, order modelv1.Sort, preLoadSize int) (iter FieldIterator, err error)
	Sort(sids []common.SeriesID, fieldKey FieldKey, order modelv1.Sort, preLoadSize int) (FieldIterator, error)
}

FieldIterable allows building a FieldIterator.

type FieldIterator

type FieldIterator interface {
	Next() bool
	Val() (uint64, common.SeriesID)
	Close() error
}

FieldIterator allows iterating over a field's posting values.

type FieldKey

type FieldKey struct {
	SeriesID    common.SeriesID
	IndexRuleID uint32
	Analyzer    databasev1.IndexRule_Analyzer
}

FieldKey is the key of field in a document.

func (FieldKey) Equal

func (f FieldKey) Equal(other FieldKey) bool

Equal reports whether f and other have the same series id and index rule id.

func (FieldKey) HasSeriesID added in v0.4.0

func (f FieldKey) HasSeriesID() bool

HasSeriesID reports whether f has a series id.

func (FieldKey) Marshal

func (f FieldKey) Marshal() []byte

Marshal encodes f to bytes.

func (FieldKey) MarshalIndexRule added in v0.3.0

func (f FieldKey) MarshalIndexRule() string

MarshalIndexRule encodes the index rule id to string representation.

func (FieldKey) MarshalToStr added in v0.2.0

func (f FieldKey) MarshalToStr() string

MarshalToStr encodes f to string.

func (*FieldKey) Unmarshal

func (f *FieldKey) Unmarshal(raw []byte) error

Unmarshal decodes bytes to f.

type Filter added in v0.2.0

type Filter interface {
	fmt.Stringer
	Execute(getSearcher GetSearcher, seriesID common.SeriesID) (posting.List, error)
}

Filter is a node in the filter tree.

type GetSearcher added in v0.2.0

type GetSearcher func(location databasev1.IndexRule_Type) (Searcher, error)

GetSearcher returns a searcher associated with input index rule type.

type RangeOpts

type RangeOpts struct {
	Upper         []byte
	Lower         []byte
	IncludesUpper bool
	IncludesLower bool
}

RangeOpts contains options to performance a continuous scan.

func (RangeOpts) Between

func (r RangeOpts) Between(value []byte) int

Between reports whether value is in the range.

type Searcher

type Searcher interface {
	FieldIterable
	Match(fieldKey FieldKey, match []string) (list posting.List, err error)
	MatchField(fieldKey FieldKey) (list posting.List, err error)
	MatchTerms(field Field) (list posting.List, err error)
	Range(fieldKey FieldKey, opts RangeOpts) (list posting.List, err error)
}

Searcher allows searching a field either by its key or by its key and term.

type Series added in v0.6.0

type Series struct {
	EntityValues []byte
	ID           common.SeriesID
}

Series represents a series in a index.

func (Series) String added in v0.6.1

func (s Series) String() string

type SeriesMatcher added in v0.6.0

type SeriesMatcher struct {
	Match []byte
	Type  SeriesMatcherType
}

SeriesMatcher represents a series matcher.

func (SeriesMatcher) String added in v0.6.1

func (s SeriesMatcher) String() string

String returns a string representation of the series matcher.

type SeriesMatcherType added in v0.6.0

type SeriesMatcherType int

SeriesMatcherType represents the type of series matcher.

const (
	// SeriesMatcherTypeExact represents an exact matcher.
	SeriesMatcherTypeExact SeriesMatcherType = iota
	// SeriesMatcherTypePrefix represents a prefix matcher.
	SeriesMatcherTypePrefix
	// SeriesMatcherTypeWildcard represents a wildcard matcher.
	SeriesMatcherTypeWildcard
)

type SeriesStore added in v0.6.0

type SeriesStore interface {
	Store
	// Search returns a list of series that match the given matchers.
	Search(context.Context, []SeriesMatcher) ([]Series, error)
}

SeriesStore is an abstract of a series repository.

type Store

type Store interface {
	io.Closer
	Writer
	Searcher
	SizeOnDisk() int64
}

Store is an abstract of a index repository.

type Writer

type Writer interface {
	Write(fields []Field, docID uint64) error
	Batch(batch Batch) error
}

Writer allows writing fields and docID in a document to a index.

Directories

Path Synopsis
Package inverted implements a inverted index repository.
Package inverted implements a inverted index repository.
Package posting implements a posting list contains a list of document ids.
Package posting implements a posting list contains a list of document ids.
roaring
Package roaring implements the posting list by a roaring bitmap.
Package roaring implements the posting list by a roaring bitmap.
Package testcases implements common helpers for testing inverted and lsm indices.
Package testcases implements common helpers for testing inverted and lsm indices.

Jump to

Keyboard shortcuts

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