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
- func NewShardIndex(id uint64, path string, opt tsdb.EngineOptions) tsdb.Index
- type Index
- func (i *Index) AssignShard(k string, shardID uint64)
- func (i *Index) Close() error
- func (i *Index) CreateMeasurementIndexIfNotExists(name string) *tsdb.Measurement
- func (i *Index) CreateSeriesIfNotExists(shardID uint64, key, name []byte, tags models.Tags, opt *tsdb.EngineOptions, ...) error
- func (i *Index) DropMeasurement(name []byte) error
- func (i *Index) DropSeries(key []byte) error
- func (i *Index) ForEachMeasurementName(fn func(name []byte) error) error
- func (i *Index) ForEachMeasurementSeriesByExpr(name []byte, expr influxql.Expr, fn func(tags models.Tags) error) error
- func (i *Index) ForEachMeasurementTagKey(name []byte, fn func(key []byte) error) error
- func (i *Index) HasTagKey(name, key []byte) (bool, error)
- func (i *Index) HasTagValue(name, key, value []byte) bool
- func (i *Index) Measurement(name []byte) (*tsdb.Measurement, error)
- func (i *Index) MeasurementExists(name []byte) (bool, error)
- func (i *Index) MeasurementNamesByExpr(expr influxql.Expr) ([][]byte, error)
- func (i *Index) MeasurementNamesByRegex(re *regexp.Regexp) ([][]byte, error)
- func (i *Index) MeasurementSeriesKeysByExpr(name []byte, condition influxql.Expr) ([][]byte, error)
- func (i *Index) MeasurementTagKeysByExpr(name []byte, expr influxql.Expr) (map[string]struct{}, error)
- func (i *Index) MeasurementsByName(names [][]byte) ([]*tsdb.Measurement, error)
- func (i *Index) MeasurementsSketches() (estimator.Sketch, estimator.Sketch, error)
- func (i *Index) Open() (err error)
- func (i *Index) RemoveShard(shardID uint64)
- func (i *Index) Series(key []byte) (*tsdb.Series, error)
- func (i *Index) SeriesKeys() []string
- func (i *Index) SeriesN() int64
- func (i *Index) SeriesPointIterator(opt influxql.IteratorOptions) (influxql.Iterator, error)
- func (i *Index) SeriesSketches() (estimator.Sketch, estimator.Sketch, error)
- func (i *Index) SetFieldName(measurement, name string)
- func (i *Index) SetFieldSet(*tsdb.MeasurementFieldSet)
- func (i *Index) SnapshotTo(path string) error
- func (i *Index) TagKeyCardinality(name, key []byte) int
- func (i *Index) TagSets(shardID uint64, name []byte, opt influxql.IteratorOptions) ([]*influxql.TagSet, error)
- func (i *Index) TagValueN(name, key []byte) int
- func (i *Index) TagsForSeries(key string) (models.Tags, error)
- func (i *Index) Type() string
- func (i *Index) UnassignShard(k string, shardID uint64) error
- type ShardIndex
- func (i *ShardIndex) CreateSeriesIfNotExists(key, name []byte, tags models.Tags) error
- func (idx *ShardIndex) CreateSeriesListIfNotExists(keys, names [][]byte, tagsSlice []models.Tags) error
- func (i *ShardIndex) InitializeSeries(key, name []byte, tags models.Tags) error
- func (i *ShardIndex) TagSets(name []byte, opt influxql.IteratorOptions) ([]*influxql.TagSet, error)
Constants ¶
const IndexName = "inmem"
IndexName is the name of this index.
Variables ¶
This section is empty.
Functions ¶
func NewShardIndex ¶
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 (*Index) AssignShard ¶
AssignShard update the index to indicate that series k exists in the given shardID.
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 ¶
DropMeasurement removes the measurement and all of its underlying series from the database index
func (*Index) DropSeries ¶
DropSeries removes the series key and its tags from the index.
func (*Index) ForEachMeasurementName ¶
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 ¶
ForEachMeasurementTagKey iterates over all tag keys for a measurement.
func (*Index) HasTagValue ¶
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 ¶
MeasurementExists returns true if the measurement exists.
func (*Index) MeasurementNamesByExpr ¶
MeasurementNamesByExpr takes an expression containing only tags and returns a list of matching meaurement names.
func (*Index) MeasurementNamesByRegex ¶
MeasurementNamesByRegex returns the measurements that match the regex.
func (*Index) MeasurementSeriesKeysByExpr ¶
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 ¶
MeasurementsSketches returns the sketches for the measurements.
func (*Index) RemoveShard ¶
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) SeriesKeys ¶
func (*Index) SeriesN ¶
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 ¶
SeriesPointIterator returns an influxql iterator over all series.
func (*Index) SeriesSketches ¶
SeriesSketches returns the sketches for the series.
func (*Index) SetFieldName ¶
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 ¶
SnapshotTo is a no-op since this is an in-memory index.
func (*Index) TagKeyCardinality ¶
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) TagsForSeries ¶
TagsForSeries returns the tag map for the passed in series
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.