indexdb

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const SeriesDB = "series"

Variables

This section is empty.

Functions

This section is empty.

Types

type FileIndexDatabase

type FileIndexDatabase interface {
	series.Filter
	series.TagValueSuggester
}

FileIndexDatabase represents a database of index files, it is shard-level it provides the abilities to filter seriesID from the index. See `tsdb/doc` for index file layout.

type ForwardStore

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

ForwardStore represents int map using roaring bitmap

func NewForwardStore

func NewForwardStore() *ForwardStore

NewForwardStore creates a int map

func (*ForwardStore) Get

func (m *ForwardStore) Get(key uint32) (uint32, bool)

Get returns value by key, if exist returns it, else returns 0, false

func (*ForwardStore) Keys

func (m *ForwardStore) Keys() *roaring.Bitmap

Keys returns the all keys

func (*ForwardStore) Put

func (m *ForwardStore) Put(key uint32, value uint32)

Put puts the value by key

func (*ForwardStore) Size

func (m *ForwardStore) Size() int

Size returns the size of keys

func (*ForwardStore) Values

func (m *ForwardStore) Values() [][]uint32

Values returns the all values

func (*ForwardStore) WalkEntry

func (m *ForwardStore) WalkEntry(fn func(key uint32, value uint32) error) error

WalkEntry walks each kv entry via fn.

type IDMappingBackend

type IDMappingBackend interface {
	io.Closer
	// contains filtered or unexported methods
}

IDMappingBackend represents the id mapping backend storage, save series data(tags hash => series id) under metric

type IndexDatabase

type IndexDatabase interface {
	io.Closer
	flow.GroupingBuilder
	series.TagValueSuggester
	series.Filter
	// GetOrCreateSeriesID gets series by tags hash, if not exist generate new series id in memory,
	// if generate a new series id returns isCreate is true
	// if generate fail return err
	GetOrCreateSeriesID(namespace, metricName string, metricID metric.ID, tagsHash uint64,
		limits *models.Limits) (seriesID uint32, isCreated bool, err error)
	// BuildInvertIndex builds the inverted index for tag value => series ids,
	// the tags is considered as an empty key-value pair while tags is nil.
	BuildInvertIndex(namespace, metricName string, tagIterator *metric.KeyValueIterator, seriesID uint32, limits *models.Limits)
	// Flush flushes index data to disk
	Flush() error
}

IndexDatabase represents a index database includes memory/file storage, it is shard level. index database will generate series id if tags hash not exist in mapping storage, and builds inverted index for tags => series id

func NewIndexDatabase

func NewIndexDatabase(ctx context.Context, parent string, metadata metadb.Metadata,
	forwardFamily kv.Family, invertedFamily kv.Family,
) (IndexDatabase, error)

NewIndexDatabase creates a new index database

type InvertedIndex

type InvertedIndex interface {
	// GetSeriesIDsByTagValueIDs gets series ids by tag value ids for spec tag key of metric
	GetSeriesIDsByTagValueIDs(tagKeyID tag.KeyID, tagValueIDs *roaring.Bitmap) (*roaring.Bitmap, error)
	// GetSeriesIDsForTag gets series ids for spec tag key of metric
	GetSeriesIDsForTag(tagKeyID tag.KeyID) (*roaring.Bitmap, error)
	// GetSeriesIDsForTags gets series ids for spec tag keys of metric
	GetSeriesIDsForTags(tagKeyIDs []tag.KeyID) (*roaring.Bitmap, error)
	// GetGroupingContext returns the context of group by
	GetGroupingContext(ctx *flow.ShardExecuteContext) error

	// Flush flushes the inverted-index of tag value id=>series ids under tag key
	Flush() error
	// contains filtered or unexported methods
}

InvertedIndex represents the tag's inverted index (tag values => series id list)

type InvertedStore

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

InvertedStore represents int map using roaring bitmap

func NewInvertedStore

func NewInvertedStore() *InvertedStore

NewInvertedStore creates a int map

func (*InvertedStore) Get

func (m *InvertedStore) Get(key uint32) (*roaring.Bitmap, bool)

Get returns value by key, if exist returns it, else returns nil, false

func (*InvertedStore) Keys

func (m *InvertedStore) Keys() *roaring.Bitmap

Keys returns the all keys

func (*InvertedStore) Put

func (m *InvertedStore) Put(key uint32, value *roaring.Bitmap)

Put puts the value by key

func (*InvertedStore) Size

func (m *InvertedStore) Size() int

Size returns the size of keys

func (*InvertedStore) Values

func (m *InvertedStore) Values() [][]*roaring.Bitmap

Values returns the all values

func (*InvertedStore) WalkEntry

func (m *InvertedStore) WalkEntry(fn func(key uint32, value *roaring.Bitmap) error) error

WalkEntry walks each kv entry via fn.

type MetricIDMapping

type MetricIDMapping interface {
	// GetMetricID return the metric id.
	GetMetricID() metric.ID
	// GetSeriesID gets series id by tags hash, if exist return true.
	GetSeriesID(tagsHash uint64) (seriesID uint32, ok bool)
	// GenSeriesID generates series id by tags hash, then cache new series id.
	GenSeriesID(namespace, metricName string, tagsHash uint64, limit *models.Limits) (seriesID uint32, err error)
	// AddSeriesID adds the series id init cache.
	AddSeriesID(tagsHash uint64, seriesID uint32)
	// SeriesSequence returns series sequence.
	SeriesSequence() unique.Sequence
}

MetricIDMapping represents the metric id mapping, tag hash code => series id

type TagIndex

type TagIndex interface {
	// GetGroupingScanner returns the grouping scanners based on series ids
	GetGroupingScanner(seriesIDs *roaring.Bitmap, withLock func() (release func())) ([]flow.GroupingScanner, error)
	// contains filtered or unexported methods
}

TagIndex represents the tag inverted index

type TagIndexStore

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

TagIndexStore represents int map using roaring bitmap

func NewTagIndexStore

func NewTagIndexStore() *TagIndexStore

NewTagIndexStore creates a int map

func (*TagIndexStore) Get

func (m *TagIndexStore) Get(key uint32) (TagIndex, bool)

Get returns value by key, if exist returns it, else returns nil, false

func (*TagIndexStore) Keys

func (m *TagIndexStore) Keys() *roaring.Bitmap

Keys returns the all keys

func (*TagIndexStore) Put

func (m *TagIndexStore) Put(key uint32, value TagIndex)

Put puts the value by key

func (*TagIndexStore) Size

func (m *TagIndexStore) Size() int

Size returns the size of keys

func (*TagIndexStore) Values

func (m *TagIndexStore) Values() [][]TagIndex

Values returns the all values

func (*TagIndexStore) WalkEntry

func (m *TagIndexStore) WalkEntry(fn func(key uint32, value TagIndex) error) error

WalkEntry walks each kv entry via fn.

Jump to

Keyboard shortcuts

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