Metadata -> Layout renaming
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
parent
4e206c7c77
commit
dcaf568279
|
@ -64,18 +64,18 @@ func (c *HistogramChunk) NumSamples() int {
|
|||
return int(binary.BigEndian.Uint16(c.Bytes()))
|
||||
}
|
||||
|
||||
// Meta returns the histogram metadata. Only call this on chunks that have at
|
||||
// Layout returns the histogram layout. Only call this on chunks that have at
|
||||
// least one sample.
|
||||
func (c *HistogramChunk) Meta() (
|
||||
func (c *HistogramChunk) Layout() (
|
||||
schema int32, zeroThreshold float64,
|
||||
negativeSpans, positiveSpans []histogram.Span,
|
||||
err error,
|
||||
) {
|
||||
if c.NumSamples() == 0 {
|
||||
panic("HistoChunk.Meta() called on an empty chunk")
|
||||
panic("HistoChunk.Layout() called on an empty chunk")
|
||||
}
|
||||
b := newBReader(c.Bytes()[2:])
|
||||
return readHistogramChunkMeta(&b)
|
||||
return readHistogramChunkLayout(&b)
|
||||
}
|
||||
|
||||
// CounterResetHeader defines the first 2 bits of the chunk header.
|
||||
|
@ -176,9 +176,9 @@ func newHistogramIterator(b []byte) *histogramIterator {
|
|||
numTotal: binary.BigEndian.Uint16(b),
|
||||
t: math.MinInt64,
|
||||
}
|
||||
// The first 2 bytes contain chunk headers.
|
||||
// The first 3 bytes contain chunk headers.
|
||||
// We skip that for actual samples.
|
||||
_, _ = it.br.readBits(16)
|
||||
_, _ = it.br.readBits(24)
|
||||
return it
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ func (c *HistogramChunk) Iterator(it Iterator) Iterator {
|
|||
type HistogramAppender struct {
|
||||
b *bstream
|
||||
|
||||
// Metadata:
|
||||
// Layout:
|
||||
schema int32
|
||||
zThreshold float64
|
||||
pSpans, nSpans []histogram.Span
|
||||
|
@ -394,15 +394,15 @@ func (a *HistogramAppender) AppendHistogram(t int64, h histogram.Histogram) {
|
|||
|
||||
if value.IsStaleNaN(h.Sum) {
|
||||
// Emptying out other fields to write no buckets, and an empty
|
||||
// meta in case of first histogram in the chunk.
|
||||
// layout in case of first histogram in the chunk.
|
||||
h = histogram.Histogram{Sum: h.Sum}
|
||||
}
|
||||
|
||||
switch num {
|
||||
case 0:
|
||||
// The first append gets the privilege to dictate the metadata
|
||||
// The first append gets the privilege to dictate the layout
|
||||
// but it's also responsible for encoding it into the chunk!
|
||||
writeHistogramChunkMeta(a.b, h.Schema, h.ZeroThreshold, h.PositiveSpans, h.NegativeSpans)
|
||||
writeHistogramChunkLayout(a.b, h.Schema, h.ZeroThreshold, h.PositiveSpans, h.NegativeSpans)
|
||||
a.schema = h.Schema
|
||||
a.zThreshold = h.ZeroThreshold
|
||||
|
||||
|
@ -591,7 +591,7 @@ type histogramIterator struct {
|
|||
numTotal uint16
|
||||
numRead uint16
|
||||
|
||||
// Metadata:
|
||||
// Layout:
|
||||
schema int32
|
||||
zThreshold float64
|
||||
pSpans, nSpans []histogram.Span
|
||||
|
@ -687,11 +687,10 @@ func (it *histogramIterator) Next() bool {
|
|||
}
|
||||
|
||||
if it.numRead == 0 {
|
||||
|
||||
// The first read is responsible for reading the chunk metadata
|
||||
// The first read is responsible for reading the chunk layout
|
||||
// and for initializing fields that depend on it. We give
|
||||
// counter reset info at chunk level, hence we discard it here.
|
||||
schema, zeroThreshold, posSpans, negSpans, err := readHistogramChunkMeta(&it.br)
|
||||
schema, zeroThreshold, posSpans, negSpans, err := readHistogramChunkLayout(&it.br)
|
||||
if err != nil {
|
||||
it.err = err
|
||||
return false
|
||||
|
|
|
@ -17,14 +17,14 @@ import (
|
|||
"github.com/prometheus/prometheus/model/histogram"
|
||||
)
|
||||
|
||||
func writeHistogramChunkMeta(b *bstream, schema int32, zeroThreshold float64, positiveSpans, negativeSpans []histogram.Span) {
|
||||
func writeHistogramChunkLayout(b *bstream, schema int32, zeroThreshold float64, positiveSpans, negativeSpans []histogram.Span) {
|
||||
putVarbitInt(b, int64(schema))
|
||||
putVarbitFloat(b, zeroThreshold)
|
||||
putHistogramChunkMetaSpans(b, positiveSpans)
|
||||
putHistogramChunkMetaSpans(b, negativeSpans)
|
||||
putHistogramChunkLayoutSpans(b, positiveSpans)
|
||||
putHistogramChunkLayoutSpans(b, negativeSpans)
|
||||
}
|
||||
|
||||
func putHistogramChunkMetaSpans(b *bstream, spans []histogram.Span) {
|
||||
func putHistogramChunkLayoutSpans(b *bstream, spans []histogram.Span) {
|
||||
putVarbitInt(b, int64(len(spans)))
|
||||
for _, s := range spans {
|
||||
putVarbitInt(b, int64(s.Length))
|
||||
|
@ -32,16 +32,11 @@ func putHistogramChunkMetaSpans(b *bstream, spans []histogram.Span) {
|
|||
}
|
||||
}
|
||||
|
||||
func readHistogramChunkMeta(b *bstreamReader) (
|
||||
func readHistogramChunkLayout(b *bstreamReader) (
|
||||
schema int32, zeroThreshold float64,
|
||||
positiveSpans, negativeSpans []histogram.Span,
|
||||
err error,
|
||||
) {
|
||||
_, err = b.ReadByte() // The header.
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
v, err := readVarbitInt(b)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -53,12 +48,12 @@ func readHistogramChunkMeta(b *bstreamReader) (
|
|||
return
|
||||
}
|
||||
|
||||
positiveSpans, err = readHistogramChunkMetaSpans(b)
|
||||
positiveSpans, err = readHistogramChunkLayoutSpans(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
negativeSpans, err = readHistogramChunkMetaSpans(b)
|
||||
negativeSpans, err = readHistogramChunkLayoutSpans(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -66,7 +61,7 @@ func readHistogramChunkMeta(b *bstreamReader) (
|
|||
return
|
||||
}
|
||||
|
||||
func readHistogramChunkMetaSpans(b *bstreamReader) ([]histogram.Span, error) {
|
||||
func readHistogramChunkLayoutSpans(b *bstreamReader) ([]histogram.Span, error) {
|
||||
var spans []histogram.Span
|
||||
num, err := readVarbitInt(b)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue