MCPcopy Create free account
hub / github.com/dolthub/doltgresql / newEncoded

Function newEncoded

postgres/parser/json/encoded.go:134–168  ·  view source on GitHub ↗
(e jEntry, v []byte)

Source from the content-addressed store, hash-verified

132}
133
134func newEncoded(e jEntry, v []byte) (JSON, error) {
135 var typ Type
136 var containerLen int
137 switch e.typCode {
138 case stringTag:
139 typ = StringJSONType
140 case numberTag:
141 typ = NumberJSONType
142 case nullTag: // Don't bother with returning a jsonEncoded for the singleton types.
143 return NullJSONValue, nil
144 case falseTag:
145 return FalseJSONValue, nil
146 case trueTag:
147 return TrueJSONValue, nil
148 case containerTag:
149 // Every container is prefixed with its uint32 container header.
150 containerHeader, err := getUint32At(v, 0)
151 if err != nil {
152 return nil, err
153 }
154 switch containerHeader & containerHeaderTypeMask {
155 case arrayContainerTag:
156 typ = ArrayJSONType
157 case objectContainerTag:
158 typ = ObjectJSONType
159 }
160 containerLen = int(containerHeader & containerHeaderLenMask)
161 }
162
163 return &jsonEncoded{
164 typ: typ,
165 containerLen: containerLen,
166 value: v,
167 }, nil
168}
169
170func getUint32At(v []byte, idx int) (uint32, error) {
171 if idx+4 > len(v) {

Callers 4

objectNthValueMethod · 0.85
FetchValIdxMethod · 0.85
shallowDecodeMethod · 0.85
ExistsMethod · 0.85

Calls 1

getUint32AtFunction · 0.85

Tested by

no test coverage detected