Fix erroneous value assignments

This commit is contained in:
Fabian Reinartz 2016-12-22 20:57:00 +01:00
parent 8aba95048a
commit 787199a88e
2 changed files with 6 additions and 2 deletions

2
db.go
View file

@ -356,6 +356,7 @@ type chunkDesc struct {
firsTimestamp int64 firsTimestamp int64
lastTimestamp int64 lastTimestamp int64
lastValue float64 lastValue float64
numSamples int
app chunks.Appender // Current appender for the chunks. 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.lastTimestamp = ts
cd.lastValue = v cd.lastValue = v
cd.numSamples++
return nil return nil
} }

View file

@ -190,7 +190,9 @@ func (h *HeadBlock) appendBatch(samples []hashedSample) error {
newHashes []uint64 newHashes []uint64
) )
for _, s := range samples { for i := range samples {
s := &samples[i]
cd, ref := h.get(s.hash, s.labels) cd, ref := h.get(s.hash, s.labels)
if cd != nil { if cd != nil {
// TODO(fabxc): sample refs are only scoped within a block for // 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 s.ref = ref
continue continue
} }
s.ref = uint32(len(h.descs) + len(newSeries)) s.ref = uint32(len(h.descs) + len(newSeries))
newSeries = append(newSeries, s.labels) newSeries = append(newSeries, s.labels)
newHashes = append(newHashes, s.hash) newHashes = append(newHashes, s.hash)
} }