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

Method decode

db/string.go:274–296  ·  view source on GitHub ↗

decode if obj has been existed , stop parse

(b []byte)

Source from the content-addressed store, hash-verified

272
273// decode if obj has been existed , stop parse
274func (s *String) decode(b []byte) error {
275 obj, err := DecodeObject(b)
276 if err != nil {
277 return err
278 }
279
280 if IsExpired(obj, Now()) {
281 return ErrKeyNotFound
282 }
283
284 if obj.Type != ObjectString {
285 return ErrTypeMismatch
286 }
287
288 if obj.Encoding != ObjectEncodingRaw {
289 return ErrTypeMismatch
290 }
291 s.Meta.Object = *obj
292 if len(b) >= ObjectEncodingLength {
293 s.Meta.Value = b[ObjectEncodingLength:]
294 }
295 return nil
296}

Callers 2

GetStringFunction · 0.95
StringsMethod · 0.95

Calls 3

DecodeObjectFunction · 0.85
IsExpiredFunction · 0.85
NowFunction · 0.85

Tested by

no test coverage detected