MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / DecodeValueKey

Function DecodeValueKey

internal/metrics/stat.go:48–68  ·  view source on GitHub ↗
(valueKey string)

Source from the content-addressed store, hash-verified

46}
47
48func DecodeValueKey(valueKey string) (serverId int64, timeString string, version int32, value int64, hash string, err error) {
49 var b = []byte(valueKey)
50 var timeIndex = bytes.Index(b, []byte{'_'})
51 if timeIndex < 0 {
52 return
53 }
54
55 timeString = string(b[:timeIndex])
56 b = b[timeIndex+1:]
57
58 if len(b) < 20+1 {
59 err = errors.New("invalid value key")
60 return
61 }
62
63 version = int32(binary.BigEndian.Uint32(b[0:4]))
64 serverId = int64(binary.BigEndian.Uint64(b[4:12]))
65 value = int64(binary.BigEndian.Uint64(b[12:20]))
66 hash = string(b[20:])
67 return
68}
69
70func DecodeSumKey(sumKey string) (serverId int64, timeString string, version int32, err error) {
71 var b = []byte(sumKey)

Callers 3

TestStat_EncodeValueKeyFunction · 0.92
TestInspectMethod · 0.85
uploadServerStatsMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestStat_EncodeValueKeyFunction · 0.74