diff --git a/db.go b/db.go index bfc7f1f96..90d944f23 100644 --- a/db.go +++ b/db.go @@ -356,6 +356,7 @@ type chunkDesc struct { firsTimestamp int64 lastTimestamp int64 lastValue float64 + numSamples int app chunks.Appender // Current appender for the chunks. } @@ -374,6 +375,7 @@ func (cd *chunkDesc) append(ts int64, v float64) (err error) { cd.lastTimestamp = ts cd.lastValue = v + cd.numSamples++ return nil } diff --git a/head.go b/head.go index c09bf92e4..5f801e028 100644 --- a/head.go +++ b/head.go @@ -190,7 +190,9 @@ func (h *HeadBlock) appendBatch(samples []hashedSample) error { newHashes []uint64 ) - for _, s := range samples { + for i := range samples { + s := &samples[i] + cd, ref := h.get(s.hash, s.labels) if cd != nil { // TODO(fabxc): sample refs are only scoped within a block for @@ -198,8 +200,8 @@ func (h *HeadBlock) appendBatch(samples []hashedSample) error { s.ref = ref continue } - s.ref = uint32(len(h.descs) + len(newSeries)) + newSeries = append(newSeries, s.labels) newHashes = append(newHashes, s.hash) }