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

Method encodeInvertedIndexKeys

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

Source from the content-addressed store, hash-verified

735}
736
737func (j jsonObject) encodeInvertedIndexKeys(b []byte) ([][]byte, error) {
738 // Checking for an empty object.
739 if len(j) == 0 {
740 return [][]byte{encoding.EncodeJSONEmptyObject(b)}, nil
741 }
742
743 var outKeys [][]byte
744 for i := range j {
745 children, err := j[i].v.encodeInvertedIndexKeys(nil)
746 if err != nil {
747 return nil, err
748 }
749
750 // We're trying to see if this is the end of the JSON path. If it is, then we don't want to
751 // add an extra separator.
752 end := true
753 switch j[i].v.(type) {
754 case jsonArray, jsonObject:
755 if j[i].v.Len() != 0 {
756 end = false
757 }
758 }
759
760 for _, childBytes := range children {
761 encodedKey := bytes.Join([][]byte{b,
762 encoding.EncodeJSONKeyStringAscending(nil, string(j[i].k), end),
763 childBytes}, nil)
764
765 outKeys = append(outKeys, encodedKey)
766 }
767 }
768 return outKeys, nil
769}
770
771// NumInvertedIndexEntries returns the number of inverted index entries that
772// 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