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

Method EncodeForwardIndex

pkg/util/json/json.go:2091–2118  ·  view source on GitHub ↗
(buf []byte, dir encoding.Direction)

Source from the content-addressed store, hash-verified

2089}
2090
2091func (j jsonObject) EncodeForwardIndex(buf []byte, dir encoding.Direction) ([]byte, error) {
2092 buf = encoding.EncodeJSONObjectKeyMarker(buf, dir)
2093 buf = encoding.EncodeJSONValueLength(buf, dir, int64(len(j)))
2094
2095 if buildutil.CrdbTestBuild {
2096 keys := make([]string, 0, j.Len())
2097 for _, a := range j {
2098 keys = append(keys, string(a.k))
2099 }
2100 if !sort.StringsAreSorted(keys) {
2101 return nil, errors.AssertionFailedf("unexpectedly unordered keys in jsonObject %s", j)
2102 }
2103 }
2104
2105 var err error
2106 for _, a := range j {
2107 buf, err = a.k.EncodeForwardIndex(buf, dir)
2108 if err != nil {
2109 return nil, err
2110 }
2111 buf, err = a.v.EncodeForwardIndex(buf, dir)
2112 if err != nil {
2113 return nil, err
2114 }
2115 }
2116 buf = encoding.EncodeJSONKeyTerminator(buf, dir)
2117 return buf, nil
2118}
2119
2120func (jsonNull) FetchValKey(string) (JSON, error) { return nil, nil }
2121func (jsonTrue) FetchValKey(string) (JSON, error) { return nil, nil }

Callers

nothing calls this directly

Calls 5

LenMethod · 0.95
EncodeJSONValueLengthFunction · 0.92
EncodeJSONKeyTerminatorFunction · 0.92
EncodeForwardIndexMethod · 0.65

Tested by

no test coverage detected