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

Method encodeInvertedIndexKeys

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

Source from the content-addressed store, hash-verified

1258}
1259
1260func (j jsonArray) encodeInvertedIndexKeys(b []byte) ([][]byte, error) {
1261 // Checking for an empty array.
1262 if len(j) == 0 {
1263 return [][]byte{encoding.EncodeJSONEmptyArray(b)}, nil
1264 }
1265
1266 prefix := encoding.EncodeArrayAscending(b)
1267 var outKeys [][]byte
1268 for i := range j {
1269 children, err := j[i].encodeInvertedIndexKeys(prefix[:len(prefix):len(prefix)])
1270 if err != nil {
1271 return nil, err
1272 }
1273 outKeys = append(outKeys, children...)
1274 }
1275
1276 // Deduplicate the entries, since arrays can have duplicates - we don't want
1277 // to emit duplicate keys from this method, as it's more expensive to
1278 // deduplicate keys via KV (which will actually write the keys) than to do
1279 // it now (just an in-memory sort and distinct).
1280 outKeys = deduplicate.ByteSlices(outKeys)
1281 return outKeys, nil
1282}
1283
1284func (j jsonArray) encodeContainingInvertedIndexSpans(
1285 b []byte, isRoot, isObjectValue bool,

Callers 1

Calls 4

EncodeJSONEmptyArrayFunction · 0.92
EncodeArrayAscendingFunction · 0.92
ByteSlicesFunction · 0.92

Tested by

no test coverage detected