mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Add back indexFormatV1
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
597202ae43
commit
62fca18f0a
|
@ -36,6 +36,7 @@ const (
|
||||||
// MagicIndex 4 bytes at the head of an index file.
|
// MagicIndex 4 bytes at the head of an index file.
|
||||||
MagicIndex = 0xBAAAD700
|
MagicIndex = 0xBAAAD700
|
||||||
|
|
||||||
|
indexFormatV1 = 1
|
||||||
indexFormatV2 = 2
|
indexFormatV2 = 2
|
||||||
|
|
||||||
labelNameSeperator = "\xff"
|
labelNameSeperator = "\xff"
|
||||||
|
@ -617,7 +618,7 @@ func newReader(b ByteSlice, c io.Closer) (*Reader, error) {
|
||||||
}
|
}
|
||||||
r.version = int(r.b.Range(4, 5)[0])
|
r.version = int(r.b.Range(4, 5)[0])
|
||||||
|
|
||||||
if r.version != 1 && r.version != 2 {
|
if r.version != indexFormatV1 && r.version != indexFormatV2 {
|
||||||
return nil, errors.Errorf("unknown index file version %d", r.version)
|
return nil, errors.Errorf("unknown index file version %d", r.version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,14 +792,14 @@ func (r *Reader) readSymbols(off int) error {
|
||||||
basePos = uint32(off) + 4
|
basePos = uint32(off) + 4
|
||||||
nextPos = basePos + uint32(origLen-d.len())
|
nextPos = basePos + uint32(origLen-d.len())
|
||||||
)
|
)
|
||||||
if r.version == 2 {
|
if r.version == indexFormatV2 {
|
||||||
r.symbolSlice = make([]string, 0, cnt)
|
r.symbolSlice = make([]string, 0, cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
for d.err() == nil && d.len() > 0 && cnt > 0 {
|
for d.err() == nil && d.len() > 0 && cnt > 0 {
|
||||||
s := d.uvarintStr()
|
s := d.uvarintStr()
|
||||||
|
|
||||||
if r.version == 2 {
|
if r.version == indexFormatV2 {
|
||||||
r.symbolSlice = append(r.symbolSlice, s)
|
r.symbolSlice = append(r.symbolSlice, s)
|
||||||
} else {
|
} else {
|
||||||
r.symbols[nextPos] = s
|
r.symbols[nextPos] = s
|
||||||
|
@ -924,7 +925,7 @@ func (r *Reader) Series(id uint64, lbls *labels.Labels, chks *[]chunks.Meta) err
|
||||||
offset := id
|
offset := id
|
||||||
// In version 2 series IDs are no longer exact references but series are 16-byte padded
|
// 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.
|
// and the ID is the multiple of 16 of the actual position.
|
||||||
if r.version == 2 {
|
if r.version == indexFormatV2 {
|
||||||
offset = id * 16
|
offset = id * 16
|
||||||
}
|
}
|
||||||
d := r.decbufUvarintAt(int(offset))
|
d := r.decbufUvarintAt(int(offset))
|
||||||
|
|
Loading…
Reference in a new issue