|
|
@ -97,7 +97,7 @@ func (c *HistoChunk) NumSamples() int {
|
|
|
|
|
|
|
|
|
|
|
|
// Meta returns the histogram metadata.
|
|
|
|
// Meta returns the histogram metadata.
|
|
|
|
// callers may only call this on chunks that have at least one sample
|
|
|
|
// callers may only call this on chunks that have at least one sample
|
|
|
|
func (c *HistoChunk) Meta() (int32, []histogram.Span, []histogram.Span, error) {
|
|
|
|
func (c *HistoChunk) Meta() (int32, float64, []histogram.Span, []histogram.Span, error) {
|
|
|
|
if c.NumSamples() == 0 {
|
|
|
|
if c.NumSamples() == 0 {
|
|
|
|
panic("HistoChunk.Meta() called on an empty chunk")
|
|
|
|
panic("HistoChunk.Meta() called on an empty chunk")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -131,6 +131,7 @@ func (c *HistoChunk) Appender() (Appender, error) {
|
|
|
|
b: &c.b,
|
|
|
|
b: &c.b,
|
|
|
|
|
|
|
|
|
|
|
|
schema: it.schema,
|
|
|
|
schema: it.schema,
|
|
|
|
|
|
|
|
zeroThreshold: it.zeroThreshold,
|
|
|
|
posSpans: it.posSpans,
|
|
|
|
posSpans: it.posSpans,
|
|
|
|
negSpans: it.negSpans,
|
|
|
|
negSpans: it.negSpans,
|
|
|
|
t: it.t,
|
|
|
|
t: it.t,
|
|
|
@ -199,6 +200,7 @@ type HistoAppender struct {
|
|
|
|
|
|
|
|
|
|
|
|
// Metadata:
|
|
|
|
// Metadata:
|
|
|
|
schema int32
|
|
|
|
schema int32
|
|
|
|
|
|
|
|
zeroThreshold float64
|
|
|
|
posSpans, negSpans []histogram.Span
|
|
|
|
posSpans, negSpans []histogram.Span
|
|
|
|
|
|
|
|
|
|
|
|
// For the fields that are tracked as dod's. Note that we expect to
|
|
|
|
// For the fields that are tracked as dod's. Note that we expect to
|
|
|
@ -245,8 +247,7 @@ func (a *HistoAppender) Append(int64, float64) {}
|
|
|
|
// * the zerobucket threshold has changed
|
|
|
|
// * the zerobucket threshold has changed
|
|
|
|
// * any buckets disappeared
|
|
|
|
// * any buckets disappeared
|
|
|
|
func (a *HistoAppender) Appendable(h histogram.SparseHistogram) ([]Interjection, []Interjection, bool) {
|
|
|
|
func (a *HistoAppender) Appendable(h histogram.SparseHistogram) ([]Interjection, []Interjection, bool) {
|
|
|
|
// TODO zerothreshold
|
|
|
|
if h.Schema != a.schema || h.ZeroThreshold != a.zeroThreshold {
|
|
|
|
if h.Schema != a.schema {
|
|
|
|
|
|
|
|
return nil, nil, false
|
|
|
|
return nil, nil, false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
posInterjections, ok := compareSpans(a.posSpans, h.PositiveSpans)
|
|
|
|
posInterjections, ok := compareSpans(a.posSpans, h.PositiveSpans)
|
|
|
@ -273,8 +274,9 @@ func (a *HistoAppender) AppendHistogram(t int64, h histogram.SparseHistogram) {
|
|
|
|
// the first append gets the privilege to dictate the metadata
|
|
|
|
// the first append gets the privilege to dictate the metadata
|
|
|
|
// but it's also responsible for encoding it into the chunk!
|
|
|
|
// but it's also responsible for encoding it into the chunk!
|
|
|
|
|
|
|
|
|
|
|
|
writeHistoChunkMeta(a.b, h.Schema, h.PositiveSpans, h.NegativeSpans)
|
|
|
|
writeHistoChunkMeta(a.b, h.Schema, h.ZeroThreshold, h.PositiveSpans, h.NegativeSpans)
|
|
|
|
a.schema = h.Schema
|
|
|
|
a.schema = h.Schema
|
|
|
|
|
|
|
|
a.zeroThreshold = h.ZeroThreshold
|
|
|
|
a.posSpans, a.negSpans = h.PositiveSpans, h.NegativeSpans
|
|
|
|
a.posSpans, a.negSpans = h.PositiveSpans, h.NegativeSpans
|
|
|
|
numPosBuckets, numNegBuckets := countSpans(h.PositiveSpans), countSpans(h.NegativeSpans)
|
|
|
|
numPosBuckets, numNegBuckets := countSpans(h.PositiveSpans), countSpans(h.NegativeSpans)
|
|
|
|
a.posbuckets = make([]int64, numPosBuckets)
|
|
|
|
a.posbuckets = make([]int64, numPosBuckets)
|
|
|
@ -442,6 +444,7 @@ type histoIterator struct {
|
|
|
|
|
|
|
|
|
|
|
|
// Metadata:
|
|
|
|
// Metadata:
|
|
|
|
schema int32
|
|
|
|
schema int32
|
|
|
|
|
|
|
|
zeroThreshold float64
|
|
|
|
posSpans, negSpans []histogram.Span
|
|
|
|
posSpans, negSpans []histogram.Span
|
|
|
|
|
|
|
|
|
|
|
|
// For the fields that are tracked as dod's.
|
|
|
|
// For the fields that are tracked as dod's.
|
|
|
@ -486,7 +489,7 @@ func (it *histoIterator) AtHistogram() (int64, histogram.SparseHistogram) {
|
|
|
|
Count: it.cnt,
|
|
|
|
Count: it.cnt,
|
|
|
|
ZeroCount: it.zcnt,
|
|
|
|
ZeroCount: it.zcnt,
|
|
|
|
Sum: it.sum,
|
|
|
|
Sum: it.sum,
|
|
|
|
ZeroThreshold: 0, // TODO
|
|
|
|
ZeroThreshold: it.zeroThreshold,
|
|
|
|
Schema: it.schema,
|
|
|
|
Schema: it.schema,
|
|
|
|
PositiveSpans: it.posSpans,
|
|
|
|
PositiveSpans: it.posSpans,
|
|
|
|
NegativeSpans: it.negSpans,
|
|
|
|
NegativeSpans: it.negSpans,
|
|
|
@ -532,12 +535,13 @@ func (it *histoIterator) Next() bool {
|
|
|
|
if it.numRead == 0 {
|
|
|
|
if it.numRead == 0 {
|
|
|
|
|
|
|
|
|
|
|
|
// first read is responsible for reading chunk metadata and initializing fields that depend on it
|
|
|
|
// first read is responsible for reading chunk metadata and initializing fields that depend on it
|
|
|
|
schema, posSpans, negSpans, err := readHistoChunkMeta(&it.br)
|
|
|
|
schema, zeroThreshold, posSpans, negSpans, err := readHistoChunkMeta(&it.br)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
it.err = err
|
|
|
|
it.err = err
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
it.schema = schema
|
|
|
|
it.schema = schema
|
|
|
|
|
|
|
|
it.zeroThreshold = zeroThreshold
|
|
|
|
it.posSpans, it.negSpans = posSpans, negSpans
|
|
|
|
it.posSpans, it.negSpans = posSpans, negSpans
|
|
|
|
numPosBuckets, numNegBuckets := countSpans(posSpans), countSpans(negSpans)
|
|
|
|
numPosBuckets, numNegBuckets := countSpans(posSpans), countSpans(negSpans)
|
|
|
|
it.posbuckets = make([]int64, numPosBuckets)
|
|
|
|
it.posbuckets = make([]int64, numPosBuckets)
|
|
|
|