mirror of
https://github.com/prometheus/prometheus
synced 2025-01-13 10:22:46 +00:00
parent
3bb715031f
commit
c0250cf120
@ -1777,7 +1777,7 @@ func TestDB_LabelNames(t *testing.T) {
|
|||||||
err = db.compact()
|
err = db.compact()
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
// All blocks have same label names, hence check them individually.
|
// All blocks have same label names, hence check them individually.
|
||||||
// No need to aggregrate and check.
|
// No need to aggregate and check.
|
||||||
for _, b := range db.Blocks() {
|
for _, b := range db.Blocks() {
|
||||||
blockIndexr, err := b.Index()
|
blockIndexr, err := b.Index()
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
@ -1787,7 +1787,7 @@ func TestDB_LabelNames(t *testing.T) {
|
|||||||
testutil.Ok(t, blockIndexr.Close())
|
testutil.Ok(t, blockIndexr.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Addings more samples to head with new label names
|
// Adding more samples to head with new label names
|
||||||
// so that we can test (head+disk).LabelNames() (the union).
|
// so that we can test (head+disk).LabelNames() (the union).
|
||||||
appendSamples(db, 5, 9, tst.sampleLabels2)
|
appendSamples(db, 5, 9, tst.sampleLabels2)
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ const (
|
|||||||
// FormatV2 represents 2 version of index.
|
// FormatV2 represents 2 version of index.
|
||||||
FormatV2 = 2
|
FormatV2 = 2
|
||||||
|
|
||||||
labelNameSeperator = "\xff"
|
labelNameSeparator = "\xff"
|
||||||
|
|
||||||
indexFilename = "index"
|
indexFilename = "index"
|
||||||
)
|
)
|
||||||
@ -866,7 +866,7 @@ func (r *Reader) SymbolTableSize() uint64 {
|
|||||||
// LabelValues returns value tuples that exist for the given label name tuples.
|
// LabelValues returns value tuples that exist for the given label name tuples.
|
||||||
func (r *Reader) LabelValues(names ...string) (StringTuples, error) {
|
func (r *Reader) LabelValues(names ...string) (StringTuples, error) {
|
||||||
|
|
||||||
key := strings.Join(names, labelNameSeperator)
|
key := strings.Join(names, labelNameSeparator)
|
||||||
off, ok := r.labels[key]
|
off, ok := r.labels[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
// XXX(fabxc): hot fix. Should return a partial data error and handle cases
|
// XXX(fabxc): hot fix. Should return a partial data error and handle cases
|
||||||
@ -901,7 +901,7 @@ func (emptyStringTuples) Len() int { return 0 }
|
|||||||
func (r *Reader) LabelIndices() ([][]string, error) {
|
func (r *Reader) LabelIndices() ([][]string, error) {
|
||||||
var res [][]string
|
var res [][]string
|
||||||
for s := range r.labels {
|
for s := range r.labels {
|
||||||
res = append(res, strings.Split(s, labelNameSeperator))
|
res = append(res, strings.Split(s, labelNameSeparator))
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
@ -958,8 +958,8 @@ func (r *Reader) LabelNames() ([]string, error) {
|
|||||||
labelNamesMap := make(map[string]struct{}, len(r.labels))
|
labelNamesMap := make(map[string]struct{}, len(r.labels))
|
||||||
for key := range r.labels {
|
for key := range r.labels {
|
||||||
// 'key' contains the label names concatenated with the
|
// 'key' contains the label names concatenated with the
|
||||||
// delimiter 'labelNameSeperator'.
|
// delimiter 'labelNameSeparator'.
|
||||||
names := strings.Split(key, labelNameSeperator)
|
names := strings.Split(key, labelNameSeparator)
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
if name == allPostingsKey.Name {
|
if name == allPostingsKey.Name {
|
||||||
// This is not from any metric.
|
// This is not from any metric.
|
||||||
|
Loading…
Reference in New Issue
Block a user