metadb

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: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespaceDB = "namespace"
	MetricDB    = "metric"
	TagKeyDB    = "tagkey"
	FieldDB     = "field"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IDGenerator

type IDGenerator interface {
	// GenMetricID generates the metric id in the memory
	GenMetricID(namespace, metricName string, limits *models.Limits) (metricID metric.ID, err error)
	// GenFieldID generates the field id in the memory
	// error-case1: field type doesn't match to before
	// error-case2: there are too many fields
	GenFieldID(namespace, metricName string, fieldName field.Name, fieldType field.Type, limits *models.Limits) (field.ID, error)
	// GenTagKeyID generates the tag key id in the memory
	GenTagKeyID(namespace, metricName, tagKey string, limits *models.Limits) (tag.KeyID, error)
}

IDGenerator generates unique ID numbers for metric, tag and field.

type IDGetter

type IDGetter interface {
	// GetMetricID gets the metric id by namespace and metric name,
	// if not exist return constants.ErrMetricIDNotFound
	GetMetricID(namespace, metricName string) (metricID metric.ID, err error)
	// GetTagKeyID gets the tag key id by namespace/metric name/tag key,
	// if not exist return constants.ErrTagKeyIDNotFound
	GetTagKeyID(namespace, metricName, tagKey string) (tagKeyID tag.KeyID, err error)
	// GetAllTagKeys returns the all tag keys by namespace/metric name,
	// if not exist return  constants.ErrMetricIDNotFound.
	GetAllTagKeys(namespace, metricName string) (tags tag.Metas, err error)
	// GetField gets the field meta by namespace/metric name/field name, if not exist return series.ErrNotFound
	GetField(namespace, metricName string, fieldName field.Name) (field field.Meta, err error)
	// GetAllFields returns the all visible fields by namespace/metric name,
	// if not exist return series.ErrNotFound
	GetAllFields(namespace, metricName string) (fields field.Metas, err error)
	// GetAllHistogramFields returns histogram-fields namespace/metric name,
	// if not exist return series.ErrNotFound
	GetAllHistogramFields(namespace, metricName string) (fields field.Metas, err error)
}

IDGetter represents the query ability for metric level, such as metric id, field meta etc.

type Metadata

type Metadata interface {
	io.Closer
	DatabaseName() string
	// MetadataDatabase returns the metric level metadata
	MetadataDatabase() MetadataDatabase
	// TagMetadata returns the tag metadata
	TagMetadata() TagMetadata
	// Flush flushes the metadata to disk
	Flush() error
}

Metadata represents all metadata of TSDB, like metric/tag metadata

func NewMetadata

func NewMetadata(ctx context.Context, databaseName, parent string, tagFamily kv.Family) (Metadata, error)

NewMetadata creates a metadata

type MetadataBackend

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

MetadataBackend represents the metadata backend storage.

type MetadataDatabase

type MetadataDatabase interface {
	io.Closer
	IDGetter
	IDGenerator
	series.MetricMetaSuggester

	// SuggestNamespace suggests the namespace by namespace's prefix
	SuggestNamespace(prefix string, limit int) (namespaces []string, err error)
	// Sync syncs the pending metadata update event
	Sync() error
}

MetadataDatabase represents the metadata storage includes namespace/metric metadata

func NewMetadataDatabase

func NewMetadataDatabase(ctx context.Context, databaseName, parent string) (MetadataDatabase, error)

NewMetadataDatabase creates new metadata database

type MetricMetadata

type MetricMetadata interface {
	// contains filtered or unexported methods
}

MetricMetadata represents the metric metadata for memory cache, it will cache all tag keys and fields in backend db

type TagEntry

type TagEntry interface {
	// contains filtered or unexported methods
}

TagEntry represents the tag value=>id under tag key

type TagMetadata

type TagMetadata interface {
	// GenTagValueID generates the tag value id for spec tag key
	GenTagValueID(tagKeyID tag.KeyID, tagValue string) (uint32, error)
	// SuggestTagValues returns suggestions from given tag key id and prefix of tag value
	SuggestTagValues(tagKeyID tag.KeyID, tagValuePrefix string, limit int) []string
	// FindTagValueDsByExpr finds tag value ids by tag filter expr for spec tag key,
	// if not exist, return nil, constants.ErrNotFound, else returns tag value ids
	FindTagValueDsByExpr(tagKeyID tag.KeyID, expr stmt.TagFilter) (*roaring.Bitmap, error)
	// GetTagValueIDsForTag get tag value ids for spec tag key of metric,
	// if not exist, return nil, constants.ErrNotFound, else returns tag value ids
	GetTagValueIDsForTag(tagKeyID tag.KeyID) (tagValueIDs *roaring.Bitmap, err error)
	// CollectTagValues collects the tag values by tag value ids,
	CollectTagValues(tagKeyID tag.KeyID,
		tagValueIDs *roaring.Bitmap,
		tagValues map[uint32]string,
	) error
	// Flush flushes the memory tag metadata into kv store
	Flush() error
}

TagMetadata represents the tag metadata, stores all tag values under spec tag key

func NewTagMetadata

func NewTagMetadata(databaseName string, family kv.Family) TagMetadata

NewTagMetadata creates a tag metadata

type TagStore

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

TagStore represents int map using roaring bitmap

func NewTagStore

func NewTagStore() *TagStore

NewTagStore creates a int map

func (*TagStore) Get

func (m *TagStore) Get(key uint32) (TagEntry, bool)

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

func (*TagStore) Keys

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

Keys returns the all keys

func (*TagStore) Put

func (m *TagStore) Put(key uint32, value TagEntry)

Put puts the value by key

func (*TagStore) Size

func (m *TagStore) Size() int

Size returns the size of keys

func (*TagStore) Values

func (m *TagStore) Values() [][]TagEntry

Values returns the all values

func (*TagStore) WalkEntry

func (m *TagStore) WalkEntry(fn func(key uint32, value TagEntry) 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