MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / decodeJEntry

Function decodeJEntry

pkg/util/json/jentry.go:98–115  ·  view source on GitHub ↗

decodeJEntry decodes a 4-byte JEntry from a buffer. The current offset is required because a JEntry can either encode a length or an offset, and while a length can be interpreted locally, the current decoding offset is required in order to interpret the encoded offset.

(b []byte, offset uint32)

Source from the content-addressed store, hash-verified

96// a length can be interpreted locally, the current decoding offset is required
97// in order to interpret the encoded offset.
98func decodeJEntry(b []byte, offset uint32) ([]byte, jEntry, error) {
99 b, encoded, err := encoding.DecodeUint32Ascending(b)
100 if err != nil {
101 return b, jEntry{}, err
102 }
103
104 length := encoded & jEntryOffLenMask
105
106 isOff := (encoded & jEntryIsOffFlag) != 0
107 if isOff {
108 length -= offset
109 }
110
111 return b, jEntry{
112 typCode: encoded & jEntryTypeMask,
113 length: length,
114 }, nil
115}

Callers 5

DecodeJSONFunction · 0.85
decodeJEntriesFunction · 0.85
formatEncodedJSONFunction · 0.85
formatEncodedJSONArrayFunction · 0.85
formatEncodedJSONObjectFunction · 0.85

Calls 1

DecodeUint32AscendingFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…