Skip to content

Commit e6a4e49

Browse files
authored
cleanup unused newTimeSeriesSet (#5978)
Signed-off-by: Ben Ye <[email protected]>
1 parent 221a0e9 commit e6a4e49

File tree

5 files changed

+0
-515
lines changed

5 files changed

+0
-515
lines changed

pkg/distributor/query.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -317,43 +317,3 @@ func (d *Distributor) queryIngesterStream(ctx context.Context, replicationSet ri
317317

318318
return resp, nil
319319
}
320-
321-
// Merges and dedupes two sorted slices with samples together.
322-
func mergeSamples(a, b []cortexpb.Sample) []cortexpb.Sample {
323-
if sameSamples(a, b) {
324-
return a
325-
}
326-
327-
result := make([]cortexpb.Sample, 0, len(a)+len(b))
328-
i, j := 0, 0
329-
for i < len(a) && j < len(b) {
330-
if a[i].TimestampMs < b[j].TimestampMs {
331-
result = append(result, a[i])
332-
i++
333-
} else if a[i].TimestampMs > b[j].TimestampMs {
334-
result = append(result, b[j])
335-
j++
336-
} else {
337-
result = append(result, a[i])
338-
i++
339-
j++
340-
}
341-
}
342-
// Add the rest of a or b. One of them is empty now.
343-
result = append(result, a[i:]...)
344-
result = append(result, b[j:]...)
345-
return result
346-
}
347-
348-
func sameSamples(a, b []cortexpb.Sample) bool {
349-
if len(a) != len(b) {
350-
return false
351-
}
352-
353-
for i := 0; i < len(a); i++ {
354-
if a[i] != b[i] {
355-
return false
356-
}
357-
}
358-
return true
359-
}

pkg/distributor/query_test.go

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -13,109 +13,6 @@ import (
1313
ingester_client "github.com/cortexproject/cortex/pkg/ingester/client"
1414
)
1515

16-
func TestMergeSamplesIntoFirstDuplicates(t *testing.T) {
17-
t.Parallel()
18-
a := []cortexpb.Sample{
19-
{Value: 1.084537996, TimestampMs: 1583946732744},
20-
{Value: 1.086111723, TimestampMs: 1583946750366},
21-
{Value: 1.086111723, TimestampMs: 1583946768623},
22-
{Value: 1.087776094, TimestampMs: 1583946795182},
23-
{Value: 1.089301187, TimestampMs: 1583946810018},
24-
{Value: 1.089301187, TimestampMs: 1583946825064},
25-
{Value: 1.089301187, TimestampMs: 1583946835547},
26-
{Value: 1.090722985, TimestampMs: 1583946846629},
27-
{Value: 1.090722985, TimestampMs: 1583946857608},
28-
{Value: 1.092038719, TimestampMs: 1583946882302},
29-
}
30-
31-
b := []cortexpb.Sample{
32-
{Value: 1.084537996, TimestampMs: 1583946732744},
33-
{Value: 1.086111723, TimestampMs: 1583946750366},
34-
{Value: 1.086111723, TimestampMs: 1583946768623},
35-
{Value: 1.087776094, TimestampMs: 1583946795182},
36-
{Value: 1.089301187, TimestampMs: 1583946810018},
37-
{Value: 1.089301187, TimestampMs: 1583946825064},
38-
{Value: 1.089301187, TimestampMs: 1583946835547},
39-
{Value: 1.090722985, TimestampMs: 1583946846629},
40-
{Value: 1.090722985, TimestampMs: 1583946857608},
41-
{Value: 1.092038719, TimestampMs: 1583946882302},
42-
}
43-
44-
a = mergeSamples(a, b)
45-
46-
// should be the same
47-
require.Equal(t, a, b)
48-
}
49-
50-
func TestMergeSamplesIntoFirst(t *testing.T) {
51-
t.Parallel()
52-
a := []cortexpb.Sample{
53-
{Value: 1, TimestampMs: 10},
54-
{Value: 2, TimestampMs: 20},
55-
{Value: 3, TimestampMs: 30},
56-
{Value: 4, TimestampMs: 40},
57-
{Value: 5, TimestampMs: 45},
58-
{Value: 5, TimestampMs: 50},
59-
}
60-
61-
b := []cortexpb.Sample{
62-
{Value: 1, TimestampMs: 5},
63-
{Value: 2, TimestampMs: 15},
64-
{Value: 3, TimestampMs: 25},
65-
{Value: 3, TimestampMs: 30},
66-
{Value: 4, TimestampMs: 35},
67-
{Value: 5, TimestampMs: 45},
68-
{Value: 6, TimestampMs: 55},
69-
}
70-
71-
a = mergeSamples(a, b)
72-
73-
require.Equal(t, []cortexpb.Sample{
74-
{Value: 1, TimestampMs: 5},
75-
{Value: 1, TimestampMs: 10},
76-
{Value: 2, TimestampMs: 15},
77-
{Value: 2, TimestampMs: 20},
78-
{Value: 3, TimestampMs: 25},
79-
{Value: 3, TimestampMs: 30},
80-
{Value: 4, TimestampMs: 35},
81-
{Value: 4, TimestampMs: 40},
82-
{Value: 5, TimestampMs: 45},
83-
{Value: 5, TimestampMs: 50},
84-
{Value: 6, TimestampMs: 55},
85-
}, a)
86-
}
87-
88-
func TestMergeSamplesIntoFirstNilA(t *testing.T) {
89-
t.Parallel()
90-
b := []cortexpb.Sample{
91-
{Value: 1, TimestampMs: 5},
92-
{Value: 2, TimestampMs: 15},
93-
{Value: 3, TimestampMs: 25},
94-
{Value: 4, TimestampMs: 35},
95-
{Value: 5, TimestampMs: 45},
96-
{Value: 6, TimestampMs: 55},
97-
}
98-
99-
a := mergeSamples(nil, b)
100-
101-
require.Equal(t, b, a)
102-
}
103-
104-
func TestMergeSamplesIntoFirstNilB(t *testing.T) {
105-
t.Parallel()
106-
a := []cortexpb.Sample{
107-
{Value: 1, TimestampMs: 10},
108-
{Value: 2, TimestampMs: 20},
109-
{Value: 3, TimestampMs: 30},
110-
{Value: 4, TimestampMs: 40},
111-
{Value: 5, TimestampMs: 50},
112-
}
113-
114-
b := mergeSamples(a, nil)
115-
116-
require.Equal(t, b, a)
117-
}
118-
11916
func TestMergeExemplars(t *testing.T) {
12017
t.Parallel()
12118
now := timestamp.FromTime(time.Now())

pkg/querier/duplicates_test.go

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)