MCPcopy Create free account
hub / github.com/distributedio/titan / DecodeObject

Function DecodeObject

db/codec.go:21–35  ·  view source on GitHub ↗

DecodeObject decode the object from binary

(b []byte)

Source from the content-addressed store, hash-verified

19
20// DecodeObject decode the object from binary
21func DecodeObject(b []byte) (obj *Object, err error) {
22 if len(b) < ObjectEncodingLength {
23 return nil, ErrInvalidLength
24 }
25 obj = &Object{
26 ID: make([]byte, 16),
27 CreatedAt: int64(binary.BigEndian.Uint64(b[16:])),
28 UpdatedAt: int64(binary.BigEndian.Uint64(b[24:])),
29 ExpireAt: int64(binary.BigEndian.Uint64(b[32:])), // 40 bit fields
30 Type: ObjectType(b[40]), // 41 bit
31 Encoding: ObjectEncoding(b[41]), // 42 bit
32 }
33 copy(obj.ID, b[0:16])
34 return obj, nil
35}
36
37// EncodeInt64 encode the int64 object to binary
38func EncodeInt64(v int64) ([]byte, error) {

Callers 14

doExpireFunction · 0.92
GetSetFunction · 0.85
DecodeHashMetaFunction · 0.85
KeysMethod · 0.85
DeleteMethod · 0.85
ExpireAtMethod · 0.85
ExistsMethod · 0.85
TouchMethod · 0.85
decodeMethod · 0.85
GetZSetFunction · 0.85
getObjectFunction · 0.85
loadZListFunction · 0.85

Calls 2

ObjectTypeTypeAlias · 0.85
ObjectEncodingTypeAlias · 0.85

Tested by 1

TestCodecObjectFunction · 0.68