mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Update package tsdb/index for new labels.Labels type
Incomplete - needs further changes to `Decoder.Series()`. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
623d306f91
commit
927a14b0e9
|
@ -423,7 +423,7 @@ func (w *Writer) AddSeries(ref storage.SeriesRef, lset labels.Labels, chunks ...
|
|||
return errors.Errorf("out-of-order series added with label set %q", lset)
|
||||
}
|
||||
|
||||
if ref < w.lastRef && len(w.lastSeries) != 0 {
|
||||
if ref < w.lastRef && !w.lastSeries.IsEmpty() {
|
||||
return errors.Errorf("series with reference greater than %d already added", ref)
|
||||
}
|
||||
// We add padding to 16 bytes to increase the addressable space we get through 4 byte
|
||||
|
@ -437,9 +437,9 @@ func (w *Writer) AddSeries(ref storage.SeriesRef, lset labels.Labels, chunks ...
|
|||
}
|
||||
|
||||
w.buf2.Reset()
|
||||
w.buf2.PutUvarint(len(lset))
|
||||
w.buf2.PutUvarint(lset.Len())
|
||||
|
||||
for _, l := range lset {
|
||||
if err := lset.Validate(func(l labels.Label) error {
|
||||
var err error
|
||||
cacheEntry, ok := w.symbolCache[l.Name]
|
||||
nameIndex := cacheEntry.index
|
||||
|
@ -465,6 +465,9 @@ func (w *Writer) AddSeries(ref storage.SeriesRef, lset labels.Labels, chunks ...
|
|||
}
|
||||
}
|
||||
w.buf2.PutUvarint32(valueIndex)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
w.buf2.PutUvarint(len(chunks))
|
||||
|
@ -496,7 +499,7 @@ func (w *Writer) AddSeries(ref storage.SeriesRef, lset labels.Labels, chunks ...
|
|||
return errors.Wrap(err, "write series data")
|
||||
}
|
||||
|
||||
w.lastSeries = append(w.lastSeries[:0], lset...)
|
||||
w.lastSeries.CopyFrom(lset)
|
||||
w.lastRef = ref
|
||||
|
||||
return nil
|
||||
|
|
|
@ -353,9 +353,9 @@ func (p *MemPostings) Iter(f func(labels.Label, Postings) error) error {
|
|||
func (p *MemPostings) Add(id storage.SeriesRef, lset labels.Labels) {
|
||||
p.mtx.Lock()
|
||||
|
||||
for _, l := range lset {
|
||||
lset.Range(func(l labels.Label) {
|
||||
p.addFor(id, l)
|
||||
}
|
||||
})
|
||||
p.addFor(id, allPostingsKey)
|
||||
|
||||
p.mtx.Unlock()
|
||||
|
|
Loading…
Reference in a new issue