8
8
"github.com/prometheus/prometheus/tsdb/chunkenc"
9
9
)
10
10
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.
13
12
type prometheusXorChunk struct {
14
13
chunk chunkenc.Chunk
15
14
}
@@ -18,6 +17,9 @@ func newPrometheusXorChunk() *prometheusXorChunk {
18
17
return & prometheusXorChunk {}
19
18
}
20
19
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.
21
23
func (p * prometheusXorChunk ) Add (m model.SamplePair ) (Chunk , error ) {
22
24
if p .chunk == nil {
23
25
p .chunk = chunkenc .NewXORChunk ()
@@ -78,32 +80,7 @@ func (p *prometheusXorChunk) Slice(_, _ model.Time) Chunk {
78
80
}
79
81
80
82
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" )
107
84
}
108
85
109
86
func (p * prometheusXorChunk ) Len () int {
0 commit comments