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

Function decodeJEntry

pkg/util/json/jentry.go:101–118  ·  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

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

Callers 2

DecodeJSONFunction · 0.85
decodeJEntriesFunction · 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…