diff --git a/vendor/gopkg.in/raintank/schema.v1/archive.go b/vendor/gopkg.in/raintank/schema.v1/archive.go index fdb3b7486e..36d7fbb908 100644 --- a/vendor/gopkg.in/raintank/schema.v1/archive.go +++ b/vendor/gopkg.in/raintank/schema.v1/archive.go @@ -10,14 +10,14 @@ import ( // Archive represents a metric archive // the zero value represents a raw metric // any non-zero value represents a certain -// aggregation method (lower 4 bits) and -// aggregation span (higher 4 bits) -type Archive uint8 +// aggregation method (lower 8 bits) and +// aggregation span (higher 8 bits) +type Archive uint16 // important: caller must make sure to call IsSpanValid first func NewArchive(method Method, span uint32) Archive { - code := spanHumanToCode[span] - return Archive(uint8(method) | code<<4) + code := uint16(spanHumanToCode[span]) + return Archive(uint16(method) | code<<8) } // String returns the traditional key suffix like sum_600 etc @@ -31,7 +31,7 @@ func (a Archive) Method() Method { } func (a Archive) Span() uint32 { - return spanCodeToHuman[uint8(a>>4)] + return spanCodeToHuman[uint8(a>>8)] } func IsSpanValid(span uint32) bool { diff --git a/vendor/gopkg.in/raintank/schema.v1/archive_test.go b/vendor/gopkg.in/raintank/schema.v1/archive_test.go index d9ed3f3feb..78dbf8e167 100644 --- a/vendor/gopkg.in/raintank/schema.v1/archive_test.go +++ b/vendor/gopkg.in/raintank/schema.v1/archive_test.go @@ -10,8 +10,14 @@ func TestArchive(t *testing.T) { expStr string } cases := []c{ - {Avg, 15, 0x31, "avg_15"}, - {Cnt, 120, 0x76, "cnt_120"}, + {Avg, 15, 0x301, "avg_15"}, + {Cnt, 120, 0x706, "cnt_120"}, + {Cnt, 3600, 0xF06, "cnt_3600"}, + {Lst, 7200, 0x1103, "lst_7200"}, + {Min, 6 * 3600, 0x1505, "min_21600"}, + {Cnt, 2, 0x6, "cnt_2"}, + {Avg, 5, 0x101, "avg_5"}, + {Cnt, 3600 + 30*60, 0x1006, "cnt_5400"}, } for i, cas := range cases { arch := NewArchive(cas.method, cas.span)