diff --git a/pkg/storage/bloom/v1/index.go b/pkg/storage/bloom/v1/index.go index a4bcd450650c0..caadfa26ddf74 100644 --- a/pkg/storage/bloom/v1/index.go +++ b/pkg/storage/bloom/v1/index.go @@ -427,14 +427,14 @@ func (r *ChunkRef) Less(other ChunkRef) bool { func (r *ChunkRef) Cmp(other ChunkRef) int { if r.From != other.From { - return int(other.From) - int(r.From) + return int(r.From) - int(other.From) } if r.Through != other.Through { - return int(other.Through) - int(r.Through) + return int(r.Through) - int(other.Through) } - return int(other.Checksum) - int(r.Checksum) + return int(r.Checksum) - int(other.Checksum) } func (r *ChunkRef) Encode(enc *encoding.Encbuf, previousEnd model.Time) model.Time { diff --git a/pkg/storage/bloom/v1/index_test.go b/pkg/storage/bloom/v1/index_test.go index 95e35617b568f..45d967fb11916 100644 --- a/pkg/storage/bloom/v1/index_test.go +++ b/pkg/storage/bloom/v1/index_test.go @@ -74,42 +74,42 @@ func TestChunkRefCmpLess(t *testing.T) { desc: "From is before", left: ChunkRef{0, 1, 0}, right: ChunkRef{1, 1, 0}, - expCmp: 1, + expCmp: -1, expLess: true, }, { desc: "From is after", left: ChunkRef{1, 1, 0}, right: ChunkRef{0, 1, 0}, - expCmp: -1, + expCmp: 1, expLess: false, }, { desc: "Through is before", left: ChunkRef{0, 1, 0}, right: ChunkRef{0, 2, 0}, - expCmp: 1, + expCmp: -1, expLess: true, }, { desc: "Through is after", left: ChunkRef{0, 2, 0}, right: ChunkRef{0, 1, 0}, - expCmp: -1, + expCmp: 1, expLess: false, }, { desc: "Checksum is smaller", left: ChunkRef{0, 1, 0}, right: ChunkRef{0, 1, 1}, - expCmp: 1, + expCmp: -1, expLess: true, }, { desc: "Checksum is bigger", left: ChunkRef{0, 0, 1}, right: ChunkRef{0, 0, 0}, - expCmp: -1, + expCmp: 1, expLess: false, }, } {