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

Method encodeInvertedIndexKeys

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

Source from the content-addressed store, hash-verified

711 return [][]byte{encoding.EncodeDecimalAscending(b, &dec)}, nil
712}
713func (j jsonArray) encodeInvertedIndexKeys(b []byte) ([][]byte, error) {
714 // Checking for an empty array.
715 if len(j) == 0 {
716 return [][]byte{encoding.EncodeJSONEmptyArray(b)}, nil
717 }
718
719 prefix := encoding.EncodeArrayAscending(b)
720 var outKeys [][]byte
721 for i := range j {
722 children, err := j[i].encodeInvertedIndexKeys(prefix[:len(prefix):len(prefix)])
723 if err != nil {
724 return nil, err
725 }
726 outKeys = append(outKeys, children...)
727 }
728
729 // Deduplicate the entries, since arrays can have duplicates - we don't want
730 // to emit duplicate keys from this method, as it's more expensive to
731 // deduplicate keys via KV (which will actually write the keys) than via SQL
732 // (just an in-memory sort and distinct).
733 outKeys = unique.UniquifyByteSlices(outKeys)
734 return outKeys, nil
735}
736
737func (j jsonObject) encodeInvertedIndexKeys(b []byte) ([][]byte, error) {
738 // Checking for an empty object.

Callers 1

Calls 4

EncodeJSONEmptyArrayFunction · 0.92
EncodeArrayAscendingFunction · 0.92
UniquifyByteSlicesFunction · 0.92

Tested by

no test coverage detected