@@ -19,7 +19,6 @@ import (
19
19
"time"
20
20
21
21
log "github.com/Sirupsen/logrus"
22
- "github.com/grafana/metrictank/api"
23
22
"github.com/grafana/metrictank/conf"
24
23
"github.com/grafana/metrictank/mdata/chunk"
25
24
"github.com/grafana/metrictank/mdata/chunk/archive"
@@ -287,7 +286,7 @@ func getMetric(w *whisper.Whisper, file, name string) (archive.Metric, error) {
287
286
OrgId : * orgId ,
288
287
}
289
288
md .SetId ()
290
- _ , schema := schemas .Match (md .Name , int (w .Header .Archives [0 ].SecondsPerPoint ))
289
+ _ , schem := schemas .Match (md .Name , int (w .Header .Archives [0 ].SecondsPerPoint ))
291
290
292
291
points := make (map [int ][]whisper.Point )
293
292
for i := range w .Header .Archives {
@@ -299,20 +298,24 @@ func getMetric(w *whisper.Whisper, file, name string) (archive.Metric, error) {
299
298
}
300
299
301
300
conversion := newConversion (w .Header .Archives , points , method )
302
- for retIdx , retention := range schema .Retentions {
301
+ for retIdx , retention := range schem .Retentions {
303
302
convertedPoints := conversion .getPoints (retIdx , uint32 (retention .SecondsPerPoint ), uint32 (retention .NumberOfPoints ))
304
303
for m , p := range convertedPoints {
305
304
if len (p ) == 0 {
306
305
continue
307
306
}
308
- rowKey := getRowKey (retIdx , md .Id , m , retention .SecondsPerPoint )
307
+ mkey , err := schema .MKeyFromString (md .Id )
308
+ if err != nil {
309
+ panic (err )
310
+ }
311
+ rowKey := getRowKey (retIdx , mkey , m , retention .SecondsPerPoint )
309
312
encodedChunks := encodedChunksFromPoints (p , uint32 (retention .SecondsPerPoint ), retention .ChunkSpan )
310
313
log .Debugf ("Archive %d Method %s got %d points = %d chunks at a span of %d" , retIdx , m , len (p ), len (encodedChunks ), retention .ChunkSpan )
311
314
res .Archives = append (res .Archives , archive.Archive {
312
315
SecondsPerPoint : uint32 (retention .SecondsPerPoint ),
313
316
Points : uint32 (retention .NumberOfPoints ),
314
317
Chunks : encodedChunks ,
315
- RowKey : rowKey ,
318
+ RowKey : rowKey . String () ,
316
319
})
317
320
if int64 (p [len (p )- 1 ].Timestamp ) > md .Time {
318
321
md .Time = int64 (p [len (p )- 1 ].Timestamp )
@@ -324,15 +327,14 @@ func getMetric(w *whisper.Whisper, file, name string) (archive.Metric, error) {
324
327
return res , nil
325
328
}
326
329
327
- func getRowKey (retIdx int , id , meth string , secondsPerPoint int ) string {
330
+ func getRowKey (retIdx int , mkey schema. MKey , meth string , secondsPerPoint int ) schema. AMKey {
328
331
if retIdx == 0 {
329
- return id
330
- } else {
331
- return api .AggMetricKey (
332
- id ,
333
- meth ,
334
- uint32 (secondsPerPoint ),
335
- )
332
+ return schema.AMKey {MKey : mkey }
333
+ }
334
+ m , _ := schema .MethodFromString (meth )
335
+ return schema.AMKey {
336
+ MKey : mkey ,
337
+ Archive : schema .NewArchive (m , uint32 (secondsPerPoint )),
336
338
}
337
339
}
338
340
0 commit comments