index

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, query Query, fieldKeys []FieldKey) (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) 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() 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) 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)
}

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
}

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