|
|
@ -186,8 +186,9 @@ func (h *HeadBlock) appendBatch(samples []hashedSample) error {
|
|
|
|
// Find head chunks for all samples and allocate new IDs/refs for
|
|
|
|
// Find head chunks for all samples and allocate new IDs/refs for
|
|
|
|
// ones we haven't seen before.
|
|
|
|
// ones we haven't seen before.
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
newSeries []labels.Labels
|
|
|
|
newSeries []labels.Labels
|
|
|
|
newHashes []uint64
|
|
|
|
newHashes []uint64
|
|
|
|
|
|
|
|
uniqueHashes = map[uint64]uint32{}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for i := range samples {
|
|
|
|
for i := range samples {
|
|
|
@ -200,7 +201,15 @@ func (h *HeadBlock) appendBatch(samples []hashedSample) error {
|
|
|
|
s.ref = ref
|
|
|
|
s.ref = ref
|
|
|
|
continue
|
|
|
|
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))
|
|
|
|
s.ref = uint32(len(h.descs) + len(newSeries))
|
|
|
|
|
|
|
|
uniqueHashes[s.hash] = s.ref
|
|
|
|
|
|
|
|
|
|
|
|
newSeries = append(newSeries, s.labels)
|
|
|
|
newSeries = append(newSeries, s.labels)
|
|
|
|
newHashes = append(newHashes, s.hash)
|
|
|
|
newHashes = append(newHashes, s.hash)
|
|
|
|