Skip to content

Commit 1243d2f

Browse files
committed
Review feedback.
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
1 parent 4e3e8c6 commit 1243d2f

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

pkg/chunk/encoding/chunk_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ func TestChunk(t *testing.T) {
8888
testChunkBatch(t, tc.encoding, samples)
8989
})
9090

91-
t.Run(fmt.Sprintf("testChunkRebound/%s/%d", tc.encoding.String(), samples), func(t *testing.T) {
92-
testChunkRebound(t, tc.encoding, samples)
93-
})
91+
if tc.encoding != PrometheusXorChunk {
92+
t.Run(fmt.Sprintf("testChunkRebound/%s/%d", tc.encoding.String(), samples), func(t *testing.T) {
93+
testChunkRebound(t, tc.encoding, samples)
94+
})
95+
}
9496
}
9597
}
9698
}

pkg/chunk/encoding/prometheus_chunk.go

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import (
88
"github.com/prometheus/prometheus/tsdb/chunkenc"
99
)
1010

11-
// Wrapper around Prometheus chunk. While it supports adding more samples, that is only implemented
12-
// to make tests work, and should not be used in production.
11+
// Wrapper around Prometheus chunk.
1312
type prometheusXorChunk struct {
1413
chunk chunkenc.Chunk
1514
}
@@ -18,6 +17,9 @@ func newPrometheusXorChunk() *prometheusXorChunk {
1817
return &prometheusXorChunk{}
1918
}
2019

20+
// Add adds another sample to the chunk. While Add works, it is only implemented
21+
// to make tests work, and should not be used in production. In particular, it appends
22+
// all samples to single chunk, and uses new Appender for each Add.
2123
func (p *prometheusXorChunk) Add(m model.SamplePair) (Chunk, error) {
2224
if p.chunk == nil {
2325
p.chunk = chunkenc.NewXORChunk()
@@ -78,32 +80,7 @@ func (p *prometheusXorChunk) Slice(_, _ model.Time) Chunk {
7880
}
7981

8082
func (p *prometheusXorChunk) Rebound(from, to model.Time) (Chunk, error) {
81-
if p.chunk == nil {
82-
return p, nil
83-
}
84-
85-
nc := chunkenc.NewXORChunk()
86-
app, err := nc.Appender()
87-
if err != nil {
88-
return nil, err
89-
}
90-
91-
it := p.chunk.Iterator(nil)
92-
for ok := it.Seek(int64(from)); ok; ok = it.Next() {
93-
t, v := it.At()
94-
if t <= int64(to) {
95-
app.Append(t, v)
96-
} else {
97-
break
98-
}
99-
}
100-
101-
nc.Compact()
102-
if nc.NumSamples() == 0 {
103-
return nil, ErrSliceNoDataInRange
104-
}
105-
106-
return &prometheusXorChunk{chunk: nc}, nil
83+
return nil, errors.New("Rebound not supported by PrometheusXorChunk")
10784
}
10885

10986
func (p *prometheusXorChunk) Len() int {

0 commit comments

Comments
 (0)