index

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package index implements the index system for searching data.

Index

Constants

View Source
const (
	// AnalyzerUnspecified represents an unspecified analyzer.
	AnalyzerUnspecified = ""
	// AnalyzerKeyword is a “noop” analyzer which returns the entire input string as a single token.
	AnalyzerKeyword = "keyword"
	// AnalyzerSimple breaks text into tokens at any non-letter character.
	AnalyzerSimple = "simple"
	// AnalyzerStandard provides grammar based tokenization.
	AnalyzerStandard = "standard"
	// AnalyzerURL breaks test into tokens at any non-letter and non-digit character.
	AnalyzerURL = "url"
)

Variables

View Source
var DummyFieldIterator = &dummyIterator{}

DummyFieldIterator never iterates.

Functions

This section is empty.

Types

type Batch added in v0.6.0

type Batch struct {
	Documents Documents
}

Batch is a collection of documents.

type Document added in v0.6.0

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

Document represents a document in an index.

type DocumentResult added in v0.7.0

type DocumentResult struct {
	EntityValues []byte
	Values       map[string][]byte
	SortedValue  []byte
	SeriesID     common.SeriesID
	DocID        uint64
	Timestamp    int64
}

DocumentResult represents a document in an index.

func (DocumentResult) SortedField added in v0.7.0

func (ir DocumentResult) SortedField() []byte

SortedField returns the value of the sorted field.

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
	NoSort bool
	Store  bool
}

Field is a indexed item in a document.

type FieldIterable

type FieldIterable interface {
	BuildQuery(seriesMatchers []SeriesMatcher, secondaryQuery Query) (Query, error)
	Iterator(ctx context.Context, fieldKey FieldKey, termRange RangeOpts, order modelv1.Sort,
		preLoadSize int) (iter FieldIterator[*DocumentResult], err error)
	Sort(ctx context.Context, sids []common.SeriesID, fieldKey FieldKey,
		order modelv1.Sort, timeRange *timestamp.TimeRange, preLoadSize int) (FieldIterator[*DocumentResult], error)
}

FieldIterable allows building a FieldIterator.

type FieldIterator

type FieldIterator[T sort.Comparable] interface {
	Next() bool
	Val() T
	Close() error
	Query() Query
}

FieldIterator allows iterating over a field's posting values.

type FieldKey

type FieldKey struct {
	Analyzer    string
	SeriesID    common.SeriesID
	IndexRuleID uint32
}

FieldKey is the key of field in a document.

func (FieldKey) Marshal

func (f FieldKey) Marshal() string

Marshal encodes f to string.

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 Query added in v0.7.0

type Query interface {
	fmt.Stringer
}

Query is an abstract of an index query.

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, opts *modelv1.Condition_MatchOption) (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 an index.

func (Series) SortedField added in v0.7.1

func (s Series) SortedField() []byte

SortedField returns the value of the sorted field.

func (Series) String added in v0.6.1

func (s Series) String() string

type SeriesDocument added in v0.7.0

type SeriesDocument struct {
	Fields map[string][]byte
	Key    Series
}

SeriesDocument represents a series document in an index.

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, []FieldKey, Query) ([]SeriesDocument, error)
	SeriesIterator(context.Context) (FieldIterator[Series], error)
	SeriesSort(ctx context.Context, fieldKey FieldKey, termRange RangeOpts, order modelv1.Sort,
		preLoadSize int, query Query, fieldKeys []FieldKey) (iter FieldIterator[*DocumentResult], err error)
}

SeriesStore is an abstract of a series repository.

type Store

type Store interface {
	io.Closer
	Writer
	Searcher
	CollectMetrics(...string)
}

Store is an abstract of an index repository.

type Writer

type Writer interface {
	Batch(batch Batch) error
	SeriesBatch(batch Batch) error
}

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

Directories

Path Synopsis
Package inverted implements an inverted index repository.
Package inverted implements an 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