diff --git a/tsdb/block.go b/tsdb/block.go index 44c6ef5053..dcbb172e72 100644 --- a/tsdb/block.go +++ b/tsdb/block.go @@ -102,11 +102,6 @@ type IndexReader interface { // LabelNames returns all the unique label names present in the index in sorted order. LabelNames(ctx context.Context, matchers ...*labels.Matcher) ([]string, error) - // LabelValueFor returns label value for the given label name in the series referred to by ID. - // If the series couldn't be found or the series doesn't have the requested label a - // storage.ErrNotFound is returned as error. - LabelValueFor(ctx context.Context, id storage.SeriesRef, label string) (string, error) - // LabelNamesFor returns all the label names for the series referred to by the postings. // The names returned are sorted. LabelNamesFor(ctx context.Context, postings index.Postings) ([]string, error) @@ -551,11 +546,6 @@ func (r blockIndexReader) Close() error { return nil } -// LabelValueFor returns label value for the given label name in the series referred to by ID. -func (r blockIndexReader) LabelValueFor(ctx context.Context, id storage.SeriesRef, label string) (string, error) { - return r.ir.LabelValueFor(ctx, id, label) -} - // LabelNamesFor returns all the label names for the series referred to by the postings. // The names returned are sorted. func (r blockIndexReader) LabelNamesFor(ctx context.Context, postings index.Postings) ([]string, error) { diff --git a/tsdb/head_read.go b/tsdb/head_read.go index 8485d65435..f2681accc0 100644 --- a/tsdb/head_read.go +++ b/tsdb/head_read.go @@ -261,21 +261,6 @@ func unpackHeadChunkRef(ref chunks.ChunkRef) (seriesID chunks.HeadSeriesRef, chu return sid, (cid & (oooChunkIDMask - 1)), (cid & oooChunkIDMask) != 0 } -// LabelValueFor returns label value for the given label name in the series referred to by ID. -func (h *headIndexReader) LabelValueFor(_ context.Context, id storage.SeriesRef, label string) (string, error) { - memSeries := h.head.series.getByID(chunks.HeadSeriesRef(id)) - if memSeries == nil { - return "", storage.ErrNotFound - } - - value := memSeries.labels().Get(label) - if value == "" { - return "", storage.ErrNotFound - } - - return value, nil -} - // LabelNamesFor returns all the label names for the series referred to by the postings. // The names returned are sorted. func (h *headIndexReader) LabelNamesFor(ctx context.Context, series index.Postings) ([]string, error) { diff --git a/tsdb/index/index.go b/tsdb/index/index.go index 28eacd7c00..253a515815 100644 --- a/tsdb/index/index.go +++ b/tsdb/index/index.go @@ -1447,32 +1447,6 @@ func (r *Reader) LabelNamesFor(ctx context.Context, postings Postings) ([]string return names, nil } -// LabelValueFor returns label value for the given label name in the series referred to by ID. -func (r *Reader) LabelValueFor(ctx context.Context, id storage.SeriesRef, label string) (string, error) { - offset := id - // In version 2 series IDs are no longer exact references but series are 16-byte padded - // and the ID is the multiple of 16 of the actual position. - if r.version != FormatV1 { - offset = id * seriesByteAlign - } - d := encoding.NewDecbufUvarintAt(r.b, int(offset), castagnoliTable) - buf := d.Get() - if d.Err() != nil { - return "", fmt.Errorf("label values for: %w", d.Err()) - } - - value, err := r.dec.LabelValueFor(ctx, buf, label) - if err != nil { - return "", storage.ErrNotFound - } - - if value == "" { - return "", storage.ErrNotFound - } - - return value, nil -} - // Series reads the series with the given ID and writes its labels and chunks into builder and chks. func (r *Reader) Series(id storage.SeriesRef, builder *labels.ScratchBuilder, chks *[]chunks.Meta) error { offset := id @@ -1809,37 +1783,6 @@ func (*Decoder) LabelNamesOffsetsFor(b []byte) ([]uint32, error) { return offsets, d.Err() } -// LabelValueFor decodes a label for a given series. -func (dec *Decoder) LabelValueFor(ctx context.Context, b []byte, label string) (string, error) { - d := encoding.Decbuf{B: b} - k := d.Uvarint() - - for range k { - lno := uint32(d.Uvarint()) - lvo := uint32(d.Uvarint()) - - if d.Err() != nil { - return "", fmt.Errorf("read series label offsets: %w", d.Err()) - } - - ln, err := dec.LookupSymbol(ctx, lno) - if err != nil { - return "", fmt.Errorf("lookup label name: %w", err) - } - - if ln == label { - lv, err := dec.LookupSymbol(ctx, lvo) - if err != nil { - return "", fmt.Errorf("lookup label value: %w", err) - } - - return lv, nil - } - } - - return "", d.Err() -} - // Series decodes a series entry from the given byte slice into builder and chks. // Previous contents of builder can be overwritten - make sure you copy before retaining. // Skips reading chunks metadata if chks is nil. diff --git a/tsdb/ooo_head_read.go b/tsdb/ooo_head_read.go index af8f9b1f83..4cecb9fd6c 100644 --- a/tsdb/ooo_head_read.go +++ b/tsdb/ooo_head_read.go @@ -500,10 +500,6 @@ func (*OOOCompactionHeadIndexReader) LabelNames(context.Context, ...*labels.Matc return nil, errors.New("not implemented") } -func (*OOOCompactionHeadIndexReader) LabelValueFor(context.Context, storage.SeriesRef, string) (string, error) { - return "", errors.New("not implemented") -} - func (*OOOCompactionHeadIndexReader) LabelNamesFor(context.Context, index.Postings) ([]string, error) { return nil, errors.New("not implemented") } diff --git a/tsdb/querier_test.go b/tsdb/querier_test.go index 6c3e37792f..4fe21c31ff 100644 --- a/tsdb/querier_test.go +++ b/tsdb/querier_test.go @@ -2294,10 +2294,6 @@ func (m mockIndex) LabelValues(_ context.Context, name string, hints *storage.La return values, nil } -func (m mockIndex) LabelValueFor(_ context.Context, id storage.SeriesRef, label string) (string, error) { - return m.series[id].l.Get(label), nil -} - func (m mockIndex) LabelNamesFor(_ context.Context, postings index.Postings) ([]string, error) { namesMap := make(map[string]bool) for postings.Next() { @@ -3315,10 +3311,6 @@ func (mockMatcherIndex) LabelValues(context.Context, string, *storage.LabelHints return []string{}, errors.New("label values called") } -func (mockMatcherIndex) LabelValueFor(context.Context, storage.SeriesRef, string) (string, error) { - return "", errors.New("label value for called") -} - func (mockMatcherIndex) LabelNamesFor(context.Context, index.Postings) ([]string, error) { return nil, errors.New("label names for called") } @@ -3739,10 +3731,6 @@ func (mockReaderOfLabels) LabelValues(context.Context, string, *storage.LabelHin return make([]string, mockReaderOfLabelsSeriesCount), nil } -func (mockReaderOfLabels) LabelValueFor(context.Context, storage.SeriesRef, string) (string, error) { - panic("LabelValueFor called") -} - func (mockReaderOfLabels) SortedLabelValues(context.Context, string, *storage.LabelHints, ...*labels.Matcher) ([]string, error) { panic("SortedLabelValues called") }