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

Function newEncoded

pkg/util/json/encoded.go:117–151  ·  view source on GitHub ↗
(e jEntry, v []byte)

Source from the content-addressed store, hash-verified

115}
116
117func newEncoded(e jEntry, v []byte) (JSON, error) {
118 var typ Type
119 var containerLen int
120 switch e.typCode {
121 case stringTag:
122 typ = StringJSONType
123 case numberTag:
124 typ = NumberJSONType
125 case nullTag: // Don't bother with returning a jsonEncoded for the singleton types.
126 return NullJSONValue, nil
127 case falseTag:
128 return FalseJSONValue, nil
129 case trueTag:
130 return TrueJSONValue, nil
131 case containerTag:
132 // Every container is prefixed with its uint32 container header.
133 containerHeader, err := getUint32At(v, 0)
134 if err != nil {
135 return nil, err
136 }
137 switch containerHeader & containerHeaderTypeMask {
138 case arrayContainerTag:
139 typ = ArrayJSONType
140 case objectContainerTag:
141 typ = ObjectJSONType
142 }
143 containerLen = int(containerHeader & containerHeaderLenMask)
144 }
145
146 return &jsonEncoded{
147 typ: typ,
148 containerLen: containerLen,
149 value: v,
150 }, nil
151}
152
153func getUint32At(v []byte, idx int) (uint32, error) {
154 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…