Fix uniqueness of new series

pull/5805/head
Fabian Reinartz 8 years ago
parent 5efe1d178e
commit 201d7687b6

@ -188,6 +188,7 @@ func (h *HeadBlock) appendBatch(samples []hashedSample) error {
var (
newSeries []labels.Labels
newHashes []uint64
uniqueHashes = map[uint64]uint32{}
)
for i := range samples {
@ -200,7 +201,15 @@ func (h *HeadBlock) appendBatch(samples []hashedSample) error {
s.ref = ref
continue
}
// There may be several samples for a new series in a batch.
// We don't want to reserve a new space for each.
if ref, ok := uniqueHashes[s.hash]; ok {
s.ref = ref
continue
}
s.ref = uint32(len(h.descs) + len(newSeries))
uniqueHashes[s.hash] = s.ref
newSeries = append(newSeries, s.labels)
newHashes = append(newHashes, s.hash)

Loading…
Cancel
Save