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

Method encodeInvertedIndexKeys

pkg/util/json/json.go:1386–1412  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

1384}
1385
1386func (j jsonObject) encodeInvertedIndexKeys(b []byte) ([][]byte, error) {
1387 // Checking for an empty object.
1388 if len(j) == 0 {
1389 return [][]byte{encoding.EncodeJSONEmptyObject(b)}, nil
1390 }
1391
1392 var outKeys [][]byte
1393 for i := range j {
1394 children, err := j[i].v.encodeInvertedIndexKeys(nil)
1395 if err != nil {
1396 return nil, err
1397 }
1398
1399 // We're trying to see if this is the end of the JSON path. If it is, then we don't want to
1400 // add an extra separator.
1401 end := isEnd(j[i].v)
1402
1403 for _, childBytes := range children {
1404 encodedKey := bytes.Join([][]byte{b,
1405 encoding.EncodeJSONKeyStringAscending(nil, string(j[i].k), end),
1406 childBytes}, nil)
1407
1408 outKeys = append(outKeys, encodedKey)
1409 }
1410 }
1411 return outKeys, nil
1412}
1413
1414func (j jsonObject) encodeContainingInvertedIndexSpans(
1415 b []byte, isRoot, isObjectValue bool,

Callers

nothing calls this directly

Calls 4

EncodeJSONEmptyObjectFunction · 0.92
isEndFunction · 0.85

Tested by

no test coverage detected