Skip to content

Commit 4eb9373

Browse files
pracuccigouthamve
authored andcommitted
Removed chunk.metadataInIndex because unused (#1836)
Signed-off-by: Marco Pracucci <[email protected]>
1 parent 5384a44 commit 4eb9373

File tree

5 files changed

+7
-24
lines changed

5 files changed

+7
-24
lines changed

pkg/chunk/chunk.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ type Chunk struct {
5757
Encoding prom_chunk.Encoding `json:"encoding"`
5858
Data prom_chunk.Chunk `json:"-"`
5959

60-
// This flag is used for very old chunks, where the metadata is read out
61-
// of the index.
62-
metadataInIndex bool
63-
6460
// The encoded version of the chunk, held so we don't need to re-encode it
6561
encoded []byte
6662
}
@@ -258,17 +254,6 @@ func NewDecodeContext() *DecodeContext {
258254
// Decode the chunk from the given buffer, and confirm the chunk is the one we
259255
// expected.
260256
func (c *Chunk) Decode(decodeContext *DecodeContext, input []byte) error {
261-
// Legacy chunks were written with metadata in the index.
262-
if c.metadataInIndex {
263-
var err error
264-
c.Data, err = prom_chunk.NewForEncoding(prom_chunk.DoubleDelta)
265-
if err != nil {
266-
return err
267-
}
268-
c.encoded = input
269-
return errors.Wrap(c.Data.UnmarshalFromBuf(input), "when unmarshalling legacy chunk")
270-
}
271-
272257
// First, calculate the checksum of the chunk and confirm it matches
273258
// what we expected.
274259
if c.ChecksumSet && c.Checksum != crc32.Checksum(input, castagnoliTable) {

pkg/chunk/chunk_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (c *store) LabelValuesForMetricName(ctx context.Context, userID string, fro
206206

207207
var result UniqueStrings
208208
for _, entry := range entries {
209-
_, labelValue, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value)
209+
_, labelValue, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value)
210210
if err != nil {
211211
return nil, err
212212
}
@@ -461,7 +461,7 @@ func (c *store) lookupEntriesByQueries(ctx context.Context, queries []IndexQuery
461461
func (c *store) parseIndexEntries(ctx context.Context, entries []IndexEntry, matcher *labels.Matcher) ([]string, error) {
462462
result := make([]string, 0, len(entries))
463463
for _, entry := range entries {
464-
chunkKey, labelValue, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value)
464+
chunkKey, labelValue, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value)
465465
if err != nil {
466466
return nil, err
467467
}

pkg/chunk/schema_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func TestSchemaRangeKey(t *testing.T) {
325325
_, err := parseMetricNameRangeValue(entry.RangeValue, entry.Value)
326326
require.NoError(t, err)
327327
case ChunkTimeRangeValue:
328-
_, _, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value)
328+
_, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value)
329329
require.NoError(t, err)
330330
case SeriesRangeValue:
331331
_, err := parseSeriesRangeValue(entry.RangeValue, entry.Value)

pkg/chunk/schema_util.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,10 @@ func parseSeriesRangeValue(rangeValue []byte, value []byte) (model.Metric, error
164164
}
165165
}
166166

167-
// parseChunkTimeRangeValue returns the chunkKey, labelValue and metadataInIndex
168-
// for chunk time range values.
167+
// parseChunkTimeRangeValue returns the chunkID and labelValue for chunk time
168+
// range values.
169169
func parseChunkTimeRangeValue(rangeValue []byte, value []byte) (
170-
chunkID string, labelValue model.LabelValue, metadataInIndex bool,
171-
isSeriesID bool, err error,
170+
chunkID string, labelValue model.LabelValue, isSeriesID bool, err error,
172171
) {
173172
components := decodeRangeKey(rangeValue)
174173

@@ -182,7 +181,6 @@ func parseChunkTimeRangeValue(rangeValue []byte, value []byte) (
182181
case len(components) == 3:
183182
chunkID = string(components[2])
184183
labelValue = model.LabelValue(components[1])
185-
metadataInIndex = true
186184
return
187185

188186
// v3 schema had four components - label name, label value, chunk ID and version.

pkg/chunk/schema_util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestParseChunkTimeRangeValue(t *testing.T) {
9292
{[]byte("a1b2c3d4\x00Y29kZQ\x002:1484661279394:1484664879394\x004\x00"),
9393
"code", "2:1484661279394:1484664879394"},
9494
} {
95-
chunkID, labelValue, _, _, err := parseChunkTimeRangeValue(c.encoded, nil)
95+
chunkID, labelValue, _, err := parseChunkTimeRangeValue(c.encoded, nil)
9696
require.NoError(t, err)
9797
assert.Equal(t, model.LabelValue(c.value), labelValue)
9898
assert.Equal(t, c.chunkID, chunkID)

0 commit comments

Comments
 (0)