mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Merge pull request #14939 from prometheus/redo-14934
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
[release-2.55] TSDB: Backward compatibility with upcoming index v3
This commit is contained in:
commit
85cc1e941d
|
@ -43,10 +43,12 @@ const (
|
||||||
// HeaderLen represents number of bytes reserved of index for header.
|
// HeaderLen represents number of bytes reserved of index for header.
|
||||||
HeaderLen = 5
|
HeaderLen = 5
|
||||||
|
|
||||||
// FormatV1 represents 1 version of index.
|
// FormatV1 represents version 1 of index.
|
||||||
FormatV1 = 1
|
FormatV1 = 1
|
||||||
// FormatV2 represents 2 version of index.
|
// FormatV2 represents version 2 of index.
|
||||||
FormatV2 = 2
|
FormatV2 = 2
|
||||||
|
// FormatV3 represents version 3 of index.
|
||||||
|
FormatV3 = 3
|
||||||
|
|
||||||
indexFilename = "index"
|
indexFilename = "index"
|
||||||
|
|
||||||
|
@ -1193,7 +1195,9 @@ 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 != FormatV1 && r.version != FormatV2 {
|
switch r.version {
|
||||||
|
case FormatV1, FormatV2, FormatV3:
|
||||||
|
default:
|
||||||
return nil, fmt.Errorf("unknown index file version %d", r.version)
|
return nil, fmt.Errorf("unknown index file version %d", r.version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1351,7 +1355,9 @@ func (s Symbols) Lookup(o uint32) (string, error) {
|
||||||
B: s.bs.Range(0, s.bs.Len()),
|
B: s.bs.Range(0, s.bs.Len()),
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.version == FormatV2 {
|
if s.version == FormatV1 {
|
||||||
|
d.Skip(int(o))
|
||||||
|
} else {
|
||||||
if int(o) >= s.seen {
|
if int(o) >= s.seen {
|
||||||
return "", fmt.Errorf("unknown symbol offset %d", o)
|
return "", fmt.Errorf("unknown symbol offset %d", o)
|
||||||
}
|
}
|
||||||
|
@ -1360,8 +1366,6 @@ func (s Symbols) Lookup(o uint32) (string, error) {
|
||||||
for i := o - (o / symbolFactor * symbolFactor); i > 0; i-- {
|
for i := o - (o / symbolFactor * symbolFactor); i > 0; i-- {
|
||||||
d.UvarintBytes()
|
d.UvarintBytes()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
d.Skip(int(o))
|
|
||||||
}
|
}
|
||||||
sym := d.UvarintStr()
|
sym := d.UvarintStr()
|
||||||
if d.Err() != nil {
|
if d.Err() != nil {
|
||||||
|
@ -1407,10 +1411,10 @@ func (s Symbols) ReverseLookup(sym string) (uint32, error) {
|
||||||
if lastSymbol != sym {
|
if lastSymbol != sym {
|
||||||
return 0, fmt.Errorf("unknown symbol %q", sym)
|
return 0, fmt.Errorf("unknown symbol %q", sym)
|
||||||
}
|
}
|
||||||
if s.version == FormatV2 {
|
if s.version == FormatV1 {
|
||||||
return uint32(res), nil
|
return uint32(s.bs.Len() - lastLen), nil
|
||||||
}
|
}
|
||||||
return uint32(s.bs.Len() - lastLen), nil
|
return uint32(res), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Symbols) Size() int {
|
func (s Symbols) Size() int {
|
||||||
|
@ -1569,7 +1573,7 @@ func (r *Reader) LabelNamesFor(ctx context.Context, postings Postings) ([]string
|
||||||
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 == FormatV2 {
|
if r.version != FormatV1 {
|
||||||
offset = id * seriesByteAlign
|
offset = id * seriesByteAlign
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,7 +1612,7 @@ func (r *Reader) LabelValueFor(ctx context.Context, id storage.SeriesRef, label
|
||||||
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 == FormatV2 {
|
if r.version != FormatV1 {
|
||||||
offset = id * seriesByteAlign
|
offset = id * seriesByteAlign
|
||||||
}
|
}
|
||||||
d := encoding.NewDecbufUvarintAt(r.b, int(offset), castagnoliTable)
|
d := encoding.NewDecbufUvarintAt(r.b, int(offset), castagnoliTable)
|
||||||
|
@ -1634,7 +1638,7 @@ func (r *Reader) Series(id storage.SeriesRef, builder *labels.ScratchBuilder, ch
|
||||||
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 == FormatV2 {
|
if r.version != FormatV1 {
|
||||||
offset = id * seriesByteAlign
|
offset = id * seriesByteAlign
|
||||||
}
|
}
|
||||||
d := encoding.NewDecbufUvarintAt(r.b, int(offset), castagnoliTable)
|
d := encoding.NewDecbufUvarintAt(r.b, int(offset), castagnoliTable)
|
||||||
|
|
Loading…
Reference in a new issue