MCPcopy Create free account
hub / github.com/dolthub/doltgresql / encodeInvertedIndexKeys

Method encodeInvertedIndexKeys

postgres/parser/json/json.go:813–845  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

811}
812
813func (j jsonObject) encodeInvertedIndexKeys(b []byte) ([][]byte, error) {
814 // Checking for an empty object.
815 if len(j) == 0 {
816 return [][]byte{encoding.EncodeJSONEmptyObject(b)}, nil
817 }
818
819 var outKeys [][]byte
820 for i := range j {
821 children, err := j[i].v.encodeInvertedIndexKeys(nil)
822 if err != nil {
823 return nil, err
824 }
825
826 // We're trying to see if this is the end of the JSON path. If it is, then we don't want to
827 // add an extra separator.
828 end := true
829 switch j[i].v.(type) {
830 case jsonArray, jsonObject:
831 if j[i].v.Len() != 0 {
832 end = false
833 }
834 }
835
836 for _, childBytes := range children {
837 encodedKey := bytes.Join([][]byte{b,
838 encoding.EncodeJSONKeyStringAscending(nil, string(j[i].k), end),
839 childBytes}, nil)
840
841 outKeys = append(outKeys, encodedKey)
842 }
843 }
844 return outKeys, nil
845}
846
847// NumInvertedIndexEntries returns the number of inverted index entries that
848// would be created for the given JSON value. Since identical elements of an

Callers

nothing calls this directly

Calls 4

EncodeJSONEmptyObjectFunction · 0.92
LenMethod · 0.65

Tested by

no test coverage detected