Documentation ¶
Overview ¶
originally from https://github.com/cortexproject/cortex/blob/868898a2921c662dcd4f90683e8b95c927a8edd8/pkg/ingester/index/index.go but modified to support sharding queries.
Index ¶
- Constants
- Variables
- func ValidateBitPrefixShardFactor(factor uint32) error
- type BitPrefixInvertedIndex
- func (ii *BitPrefixInvertedIndex) Add(labels []logproto.LabelAdapter, fp model.Fingerprint) labels.Labels
- func (ii *BitPrefixInvertedIndex) Delete(labels labels.Labels, fp model.Fingerprint)
- func (ii *BitPrefixInvertedIndex) LabelNames(shard *logql.Shard) ([]string, error)
- func (ii *BitPrefixInvertedIndex) LabelValues(name string, shard *logql.Shard) ([]string, error)
- func (ii *BitPrefixInvertedIndex) Lookup(matchers []*labels.Matcher, shard *logql.Shard) ([]model.Fingerprint, error)
- type Interface
- type InvertedIndex
- func (ii *InvertedIndex) Add(labels []logproto.LabelAdapter, fp model.Fingerprint) labels.Labels
- func (ii *InvertedIndex) Delete(labels labels.Labels, fp model.Fingerprint)
- func (ii *InvertedIndex) LabelNames(s *logql.Shard) ([]string, error)
- func (ii *InvertedIndex) LabelValues(name string, s *logql.Shard) ([]string, error)
- func (ii *InvertedIndex) Lookup(matchers []*labels.Matcher, s *logql.Shard) ([]model.Fingerprint, error)
- type Multi
- func (m *Multi) Add(labels []logproto.LabelAdapter, fp model.Fingerprint) (result labels.Labels)
- func (m *Multi) Delete(labels labels.Labels, fp model.Fingerprint)
- func (m *Multi) LabelNames(t time.Time, shard *logql.Shard) ([]string, error)
- func (m *Multi) LabelValues(t time.Time, name string, shard *logql.Shard) ([]string, error)
- func (m *Multi) Lookup(t time.Time, matchers []*labels.Matcher, shard *logql.Shard) ([]model.Fingerprint, error)
Constants ¶
const DefaultIndexShards = 32
Variables ¶
var ErrInvalidShardQuery = errors.New("incompatible index shard query")
Functions ¶
Types ¶
type BitPrefixInvertedIndex ¶
type BitPrefixInvertedIndex struct {
// contains filtered or unexported fields
}
BitPrefixInvertedIndex is another inverted index implementation that uses the bit prefix sharding algorithm in tsdb/index/shard.go instead of a modulo approach. This is the standard for TSDB compatibility because the same series must resolve to the same shard (for each period config), whether it's resolved on the ingester or via the store.
func NewBitPrefixWithShards ¶
func NewBitPrefixWithShards(totalShards uint32) (*BitPrefixInvertedIndex, error)
func (*BitPrefixInvertedIndex) Add ¶
func (ii *BitPrefixInvertedIndex) Add(labels []logproto.LabelAdapter, fp model.Fingerprint) labels.Labels
Add a fingerprint under the specified labels. NOTE: memory for `labels` is unsafe; anything retained beyond the life of this function must be copied
func (*BitPrefixInvertedIndex) Delete ¶
func (ii *BitPrefixInvertedIndex) Delete(labels labels.Labels, fp model.Fingerprint)
Delete a fingerprint with the given label pairs.
func (*BitPrefixInvertedIndex) LabelNames ¶
func (ii *BitPrefixInvertedIndex) LabelNames(shard *logql.Shard) ([]string, error)
LabelNames returns all label names.
func (*BitPrefixInvertedIndex) LabelValues ¶
LabelValues returns the values for the given label.
func (*BitPrefixInvertedIndex) Lookup ¶
func (ii *BitPrefixInvertedIndex) Lookup(matchers []*labels.Matcher, shard *logql.Shard) ([]model.Fingerprint, error)
Lookup all fingerprints for the provided matchers.
type Interface ¶
type Interface interface { Add(labels []logproto.LabelAdapter, fp model.Fingerprint) labels.Labels Lookup(matchers []*labels.Matcher, shard *logql.Shard) ([]model.Fingerprint, error) LabelNames(shard *logql.Shard) ([]string, error) LabelValues(name string, shard *logql.Shard) ([]string, error) Delete(labels labels.Labels, fp model.Fingerprint) }
type InvertedIndex ¶
type InvertedIndex struct {
// contains filtered or unexported fields
}
InvertedIndex implements a in-memory inverted index from label pairs to fingerprints. It is sharded to reduce lock contention on writes.
func NewWithShards ¶
func NewWithShards(totalShards uint32) *InvertedIndex
func (*InvertedIndex) Add ¶
func (ii *InvertedIndex) Add(labels []logproto.LabelAdapter, fp model.Fingerprint) labels.Labels
Add a fingerprint under the specified labels. NOTE: memory for `labels` is unsafe; anything retained beyond the life of this function must be copied
func (*InvertedIndex) Delete ¶
func (ii *InvertedIndex) Delete(labels labels.Labels, fp model.Fingerprint)
Delete a fingerprint with the given label pairs.
func (*InvertedIndex) LabelNames ¶
func (ii *InvertedIndex) LabelNames(s *logql.Shard) ([]string, error)
LabelNames returns all label names.
func (*InvertedIndex) LabelValues ¶
LabelValues returns the values for the given label.
func (*InvertedIndex) Lookup ¶
func (ii *InvertedIndex) Lookup(matchers []*labels.Matcher, s *logql.Shard) ([]model.Fingerprint, error)
Lookup all fingerprints for the provided matchers.
type Multi ¶
type Multi struct {
// contains filtered or unexported fields
}
func NewMultiInvertedIndex ¶
func NewMultiInvertedIndex(periods []config.PeriodConfig, indexShards uint32) (*Multi, error)
func (*Multi) Add ¶
func (m *Multi) Add(labels []logproto.LabelAdapter, fp model.Fingerprint) (result labels.Labels)