inmem

package
v1.2.3-0...-72df1fe Latest Latest
Warning

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

Go to latest
Published: May 3, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package inmem implements a shared, in-memory index for each database.

The in-memory index is the original index implementation and provides fast access to index data. However, it also forces high memory usage for large datasets and can cause OOM errors.

Index is the shared index structure that provides most of the functionality. However, ShardIndex is a light per-shard wrapper that adapts this original shared index format to the new per-shard format.

Index

Constants

View Source
const IndexName = "inmem"

IndexName is the name of this index.

Variables

This section is empty.

Functions

func NewShardIndex

func NewShardIndex(id uint64, path string, opt tsdb.EngineOptions) tsdb.Index

NewShardIndex returns a new index for a shard.

Types

type Index

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

Index is the in memory index of a collection of measurements, time series, and their tags. Exported functions are goroutine safe while un-exported functions assume the caller will use the appropriate locks.

func NewIndex

func NewIndex() *Index

NewIndex returns a new initialized Index.

func (*Index) AssignShard

func (i *Index) AssignShard(k string, shardID uint64)

AssignShard update the index to indicate that series k exists in the given shardID.

func (*Index) Close

func (i *Index) Close() error

func (*Index) CreateMeasurementIndexIfNotExists

func (i *Index) CreateMeasurementIndexIfNotExists(name string) *tsdb.Measurement

CreateMeasurementIndexIfNotExists creates or retrieves an in memory index object for the measurement

func (*Index) CreateSeriesIfNotExists

func (i *Index) CreateSeriesIfNotExists(shardID uint64, key, name []byte, tags models.Tags, opt *tsdb.EngineOptions, ignoreLimits bool) error

CreateSeriesIfNotExists adds the series for the given measurement to the index and sets its ID or returns the existing series object

func (*Index) DropMeasurement

func (i *Index) DropMeasurement(name []byte) error

DropMeasurement removes the measurement and all of its underlying series from the database index

func (*Index) DropSeries

func (i *Index) DropSeries(key []byte) error

DropSeries removes the series key and its tags from the index.

func (*Index) ForEachMeasurementName

func (i *Index) ForEachMeasurementName(fn func(name []byte) error) error

ForEachMeasurementName iterates over each measurement name.

func (*Index) ForEachMeasurementSeriesByExpr

func (i *Index) ForEachMeasurementSeriesByExpr(name []byte, expr influxql.Expr, fn func(tags models.Tags) error) error

ForEachMeasurementSeriesByExpr iterates over all series in a measurement filtered by an expression.

func (*Index) ForEachMeasurementTagKey

func (i *Index) ForEachMeasurementTagKey(name []byte, fn func(key []byte) error) error

ForEachMeasurementTagKey iterates over all tag keys for a measurement.

func (*Index) HasTagKey

func (i *Index) HasTagKey(name, key []byte) (bool, error)

HasTagKey returns true if tag key exists.

func (*Index) HasTagValue

func (i *Index) HasTagValue(name, key, value []byte) bool

HasTagValue returns true if tag value exists.

func (*Index) Measurement

func (i *Index) Measurement(name []byte) (*tsdb.Measurement, error)

Measurement returns the measurement object from the index by the name

func (*Index) MeasurementExists

func (i *Index) MeasurementExists(name []byte) (bool, error)

MeasurementExists returns true if the measurement exists.

func (*Index) MeasurementNamesByExpr

func (i *Index) MeasurementNamesByExpr(expr influxql.Expr) ([][]byte, error)

MeasurementNamesByExpr takes an expression containing only tags and returns a list of matching meaurement names.

func (*Index) MeasurementNamesByRegex

func (i *Index) MeasurementNamesByRegex(re *regexp.Regexp) ([][]byte, error)

MeasurementNamesByRegex returns the measurements that match the regex.

func (*Index) MeasurementSeriesKeysByExpr

func (i *Index) MeasurementSeriesKeysByExpr(name []byte, condition influxql.Expr) ([][]byte, error)

func (*Index) MeasurementTagKeysByExpr

func (i *Index) MeasurementTagKeysByExpr(name []byte, expr influxql.Expr) (map[string]struct{}, error)

MeasurementTagKeysByExpr returns an ordered set of tag keys filtered by an expression.

func (*Index) MeasurementsByName

func (i *Index) MeasurementsByName(names [][]byte) ([]*tsdb.Measurement, error)

MeasurementsByName returns a list of measurements.

func (*Index) MeasurementsSketches

func (i *Index) MeasurementsSketches() (estimator.Sketch, estimator.Sketch, error)

MeasurementsSketches returns the sketches for the measurements.

func (*Index) Open

func (i *Index) Open() (err error)

func (*Index) RemoveShard

func (i *Index) RemoveShard(shardID uint64)

RemoveShard removes all references to shardID from any series or measurements in the index. If the shard was the only owner of data for the series, the series is removed from the index.

func (*Index) Series

func (i *Index) Series(key []byte) (*tsdb.Series, error)

Series returns a series by key.

func (*Index) SeriesKeys

func (i *Index) SeriesKeys() []string

func (*Index) SeriesN

func (i *Index) SeriesN() int64

SeriesN returns the number of unique non-tombstoned series in the index. Since indexes are not shared across shards, the count returned by SeriesN cannot be combined with other shards' counts.

func (*Index) SeriesPointIterator

func (i *Index) SeriesPointIterator(opt influxql.IteratorOptions) (influxql.Iterator, error)

SeriesPointIterator returns an influxql iterator over all series.

func (*Index) SeriesSketches

func (i *Index) SeriesSketches() (estimator.Sketch, estimator.Sketch, error)

SeriesSketches returns the sketches for the series.

func (*Index) SetFieldName

func (i *Index) SetFieldName(measurement, name string)

SetFieldName adds a field name to a measurement.

func (*Index) SetFieldSet

func (i *Index) SetFieldSet(*tsdb.MeasurementFieldSet)

SetFieldSet sets a shared field set from the engine.

func (*Index) SnapshotTo

func (i *Index) SnapshotTo(path string) error

SnapshotTo is a no-op since this is an in-memory index.

func (*Index) TagKeyCardinality

func (i *Index) TagKeyCardinality(name, key []byte) int

TagKeyCardinality returns the number of values for a measurement/tag key.

func (*Index) TagSets

func (i *Index) TagSets(shardID uint64, name []byte, opt influxql.IteratorOptions) ([]*influxql.TagSet, error)

TagSets returns a list of tag sets.

func (*Index) TagValueN

func (i *Index) TagValueN(name, key []byte) int

TagValueN returns the cardinality of a tag value.

func (*Index) TagsForSeries

func (i *Index) TagsForSeries(key string) (models.Tags, error)

TagsForSeries returns the tag map for the passed in series

func (*Index) Type

func (i *Index) Type() string

func (*Index) UnassignShard

func (i *Index) UnassignShard(k string, shardID uint64) error

UnassignShard updates the index to indicate that series k does not exist in the given shardID.

type ShardIndex

type ShardIndex struct {
	*Index
	// contains filtered or unexported fields
}

ShardIndex represents a shim between the TSDB index interface and the shared in-memory index. This is required because per-shard in-memory indexes will grow the heap size too large.

func (*ShardIndex) CreateSeriesIfNotExists

func (i *ShardIndex) CreateSeriesIfNotExists(key, name []byte, tags models.Tags) error

func (*ShardIndex) CreateSeriesListIfNotExists

func (idx *ShardIndex) CreateSeriesListIfNotExists(keys, names [][]byte, tagsSlice []models.Tags) error

CreateSeriesListIfNotExists creates a list of series if they doesn't exist in bulk.

func (*ShardIndex) InitializeSeries

func (i *ShardIndex) InitializeSeries(key, name []byte, tags models.Tags) error

InitializeSeries is called during startup. This works the same as CreateSeriesIfNotExists except it ignore limit errors.

func (*ShardIndex) TagSets

func (i *ShardIndex) TagSets(name []byte, opt influxql.IteratorOptions) ([]*influxql.TagSet, error)

TagSets returns a list of tag sets based on series filtering.

Jump to

Keyboard shortcuts

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