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

Method iterObject

pkg/util/json/encoded.go:252–278  ·  view source on GitHub ↗

iterObject iterates through all the keys and values of an encoded object without requiring decoding of all of them.

()

Source from the content-addressed store, hash-verified

250// iterObject iterates through all the keys and values of an encoded object
251// without requiring decoding of all of them.
252func (j *jsonEncoded) iterObject() (encodedObjectIterator, error) {
253 if j.typ != ObjectJSONType {
254 panic("can only iterate through the object values of an object")
255 }
256
257 curKeyIdx := containerHeaderLen + j.containerLen*jEntryLen*2
258 curValueIdx := curKeyIdx
259
260 // We have to seek to the start of the value data.
261 for i := 0; i < j.containerLen; i++ {
262 entry, err := getJEntryAt(j.value, containerHeaderLen+i*jEntryLen, curValueIdx-curKeyIdx)
263 if err != nil {
264 return encodedObjectIterator{}, err
265 }
266 curValueIdx += int(entry.length)
267 }
268
269 return encodedObjectIterator{
270 curKeyIdx: 0,
271 keyOffset: curKeyIdx,
272 curValueIdx: 0,
273 valueOffset: curValueIdx,
274 len: j.containerLen,
275 idx: 0,
276 data: j.value,
277 }, nil
278}
279
280func (j *jsonEncoded) StripNulls() (JSON, bool, error) {
281 dec, err := j.shallowDecode()

Callers 1

shallowDecodeMethod · 0.95

Calls 1

getJEntryAtFunction · 0.85

Tested by

no test coverage detected