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

Function formatEncodedJSONArray

pkg/util/json/encoded_format.go:79–117  ·  view source on GitHub ↗
(buf *bytes.Buffer, containerHeader uint32, b []byte)

Source from the content-addressed store, hash-verified

77}
78
79func formatEncodedJSONArray(buf *bytes.Buffer, containerHeader uint32, b []byte) ([]byte, error) {
80 length := int(containerHeader & containerHeaderLenMask)
81
82 // There are `length` JEntries in the array.
83 entOff, valOff := uint32(0), uint32(0)
84 entB, valB := b, b
85 // Skip past the JEntries to find the first value, permitting parallel
86 // iteration through the JEntries and values below.
87 var err error
88 for i := 0; i < length; i++ {
89 // Decode and ignore.
90 var ent jEntry
91 valB, ent, err = decodeJEntry(valB, valOff)
92 if err != nil {
93 return nil, err
94 }
95 valOff += ent.length
96 }
97
98 buf.WriteByte('[')
99 for i := 0; i < length; i++ {
100 if i != 0 {
101 buf.WriteString(", ")
102 }
103 var ent jEntry
104 var err error
105 entB, ent, err = decodeJEntry(entB, entOff)
106 if err != nil {
107 return nil, err
108 }
109 entOff += ent.length
110 valB, err = formatEncodedJSONValue(buf, ent, valB)
111 if err != nil {
112 return nil, err
113 }
114 }
115 buf.WriteByte(']')
116 return valB, nil
117}
118
119func formatEncodedJSONObject(buf *bytes.Buffer, containerHeader uint32, b []byte) ([]byte, error) {
120 length := int(containerHeader & containerHeaderLenMask)

Callers 1

formatEncodedJSONFunction · 0.85

Calls 2

decodeJEntryFunction · 0.85
formatEncodedJSONValueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…