Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions pkg/chunk/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/chunk/chunk_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunk/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions pkg/chunk/schema_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunk/schema_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down