diff --git a/pkg/chunk/chunk.go b/pkg/chunk/chunk.go index 546e70e2d3e..10642d9124e 100644 --- a/pkg/chunk/chunk.go +++ b/pkg/chunk/chunk.go @@ -57,10 +57,6 @@ type Chunk struct { Encoding prom_chunk.Encoding `json:"encoding"` Data prom_chunk.Chunk `json:"-"` - // This flag is used for very old chunks, where the metadata is read out - // of the index. - metadataInIndex bool - // The encoded version of the chunk, held so we don't need to re-encode it encoded []byte } @@ -258,17 +254,6 @@ func NewDecodeContext() *DecodeContext { // Decode the chunk from the given buffer, and confirm the chunk is the one we // expected. func (c *Chunk) Decode(decodeContext *DecodeContext, input []byte) error { - // Legacy chunks were written with metadata in the index. - if c.metadataInIndex { - var err error - c.Data, err = prom_chunk.NewForEncoding(prom_chunk.DoubleDelta) - if err != nil { - return err - } - c.encoded = input - return errors.Wrap(c.Data.UnmarshalFromBuf(input), "when unmarshalling legacy chunk") - } - // First, calculate the checksum of the chunk and confirm it matches // what we expected. if c.ChecksumSet && c.Checksum != crc32.Checksum(input, castagnoliTable) { diff --git a/pkg/chunk/chunk_store.go b/pkg/chunk/chunk_store.go index 326cefe8862..8a9f393dd47 100644 --- a/pkg/chunk/chunk_store.go +++ b/pkg/chunk/chunk_store.go @@ -206,7 +206,7 @@ func (c *store) LabelValuesForMetricName(ctx context.Context, userID string, fro var result UniqueStrings for _, entry := range entries { - _, labelValue, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value) + _, labelValue, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value) if err != nil { return nil, err } @@ -461,7 +461,7 @@ func (c *store) lookupEntriesByQueries(ctx context.Context, queries []IndexQuery func (c *store) parseIndexEntries(ctx context.Context, entries []IndexEntry, matcher *labels.Matcher) ([]string, error) { result := make([]string, 0, len(entries)) for _, entry := range entries { - chunkKey, labelValue, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value) + chunkKey, labelValue, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value) if err != nil { return nil, err } diff --git a/pkg/chunk/schema_test.go b/pkg/chunk/schema_test.go index 41c4b43379c..1749596c831 100644 --- a/pkg/chunk/schema_test.go +++ b/pkg/chunk/schema_test.go @@ -325,7 +325,7 @@ func TestSchemaRangeKey(t *testing.T) { _, err := parseMetricNameRangeValue(entry.RangeValue, entry.Value) require.NoError(t, err) case ChunkTimeRangeValue: - _, _, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value) + _, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value) require.NoError(t, err) case SeriesRangeValue: _, err := parseSeriesRangeValue(entry.RangeValue, entry.Value) diff --git a/pkg/chunk/schema_util.go b/pkg/chunk/schema_util.go index 46765ad93e7..e507e7c02e9 100644 --- a/pkg/chunk/schema_util.go +++ b/pkg/chunk/schema_util.go @@ -164,11 +164,10 @@ func parseSeriesRangeValue(rangeValue []byte, value []byte) (model.Metric, error } } -// parseChunkTimeRangeValue returns the chunkKey, labelValue and metadataInIndex -// for chunk time range values. +// parseChunkTimeRangeValue returns the chunkID and labelValue for chunk time +// range values. func parseChunkTimeRangeValue(rangeValue []byte, value []byte) ( - chunkID string, labelValue model.LabelValue, metadataInIndex bool, - isSeriesID bool, err error, + chunkID string, labelValue model.LabelValue, isSeriesID bool, err error, ) { components := decodeRangeKey(rangeValue) @@ -182,7 +181,6 @@ func parseChunkTimeRangeValue(rangeValue []byte, value []byte) ( case len(components) == 3: chunkID = string(components[2]) labelValue = model.LabelValue(components[1]) - metadataInIndex = true return // v3 schema had four components - label name, label value, chunk ID and version. diff --git a/pkg/chunk/schema_util_test.go b/pkg/chunk/schema_util_test.go index a8096b70dd7..96fc0aa10a3 100644 --- a/pkg/chunk/schema_util_test.go +++ b/pkg/chunk/schema_util_test.go @@ -92,7 +92,7 @@ func TestParseChunkTimeRangeValue(t *testing.T) { {[]byte("a1b2c3d4\x00Y29kZQ\x002:1484661279394:1484664879394\x004\x00"), "code", "2:1484661279394:1484664879394"}, } { - chunkID, labelValue, _, _, err := parseChunkTimeRangeValue(c.encoded, nil) + chunkID, labelValue, _, err := parseChunkTimeRangeValue(c.encoded, nil) require.NoError(t, err) assert.Equal(t, model.LabelValue(c.value), labelValue) assert.Equal(t, c.chunkID, chunkID)