github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/logproto/extensions.go (about) 1 package logproto 2 3 import "github.com/prometheus/prometheus/model/labels" 4 5 // Note, this is not very efficient and use should be minimized as it requires label construction on each comparison 6 type SeriesIdentifiers []SeriesIdentifier 7 8 func (ids SeriesIdentifiers) Len() int { return len(ids) } 9 func (ids SeriesIdentifiers) Swap(i, j int) { ids[i], ids[j] = ids[j], ids[i] } 10 func (ids SeriesIdentifiers) Less(i, j int) bool { 11 a, b := labels.FromMap(ids[i].Labels), labels.FromMap(ids[j].Labels) 12 return labels.Compare(a, b) <= 0 13 } 14 15 type Streams []Stream 16 17 func (xs Streams) Len() int { return len(xs) } 18 func (xs Streams) Swap(i, j int) { xs[i], xs[j] = xs[j], xs[i] } 19 func (xs Streams) Less(i, j int) bool { return xs[i].Labels <= xs[j].Labels } 20 21 func (s Series) Len() int { return len(s.Samples) } 22 func (s Series) Swap(i, j int) { s.Samples[i], s.Samples[j] = s.Samples[j], s.Samples[i] } 23 func (s Series) Less(i, j int) bool { return s.Samples[i].Timestamp < s.Samples[j].Timestamp }