MCPcopy Create free account
hub / github.com/cortexproject/cortex / FromChunks

Function FromChunks

pkg/util/chunkcompat/compat.go:60–80  ·  view source on GitHub ↗

FromChunks converts []client.Chunk to []chunk.Chunk.

(metric labels.Labels, in []client.Chunk)

Source from the content-addressed store, hash-verified

58
59// FromChunks converts []client.Chunk to []chunk.Chunk.
60func FromChunks(metric labels.Labels, in []client.Chunk) ([]chunk.Chunk, error) {
61 out := make([]chunk.Chunk, 0, len(in))
62 for _, i := range in {
63 e := prom_chunk.Encoding(byte(i.Encoding))
64 chunkEnc := e.PromChunkEncoding()
65 if chunkEnc == chunkenc.EncNone {
66 return nil, fmt.Errorf("unknown chunk encoding: %v", e)
67 }
68
69 chk, err := chunkenc.FromData(chunkEnc, i.Data)
70 if err != nil {
71 return nil, err
72 }
73
74 firstTime, lastTime := model.Time(i.StartTimestampMs), model.Time(i.EndTimestampMs)
75 // As the lifetime of this chunk is scopes to this request, we don't need
76 // to supply a fingerprint.
77 out = append(out, chunk.NewChunk(metric, chk, firstTime, lastTime))
78 }
79 return out, nil
80}
81
82// ToChunks converts []chunk.Chunk to []client.Chunk.
83func ToChunks(in []chunk.Chunk) ([]client.Chunk, error) {

Callers 3

streamingSelectMethod · 0.92
SeriesChunksToMatrixFunction · 0.85

Calls 2

NewChunkFunction · 0.92
PromChunkEncodingMethod · 0.80

Tested by 1