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

Function EncodeContainedInvertedIndexSpans

pkg/util/json/json.go:1095–1114  ·  view source on GitHub ↗

EncodeContainedInvertedIndexSpans takes in a key prefix and returns the spans that must be scanned in the inverted index to evaluate a contained by (<@) predicate with the given JSON (i.e., find the objects in the index that could be contained by the given JSON). The spans are returned in an invert

(
	b []byte, json JSON,
)

Source from the content-addressed store, hash-verified

1093//
1094// The input inKey is prefixed to the keys in all returned spans.
1095func EncodeContainedInvertedIndexSpans(
1096 b []byte, json JSON,
1097) (invertedExpr inverted.Expression, err error) {
1098 invertedExpr, err = json.encodeContainedInvertedIndexSpans(
1099 encoding.EncodeJSONAscending(b), true /* isRoot */, false, /* isObjectValue */
1100 )
1101 if err != nil {
1102 return nil, err
1103 }
1104 // The produced inverted expression will never be tight. This is because the
1105 // span expression produced will match all objects that contain at least one
1106 // of the keys, which does not guarantee they only contain the keys.
1107 // In other words, there may be false positives included that will need to
1108 // pass through an additional filter.
1109 // For example, the spans produced for '{"a": "b"}' will include both
1110 // '{"a": "b"}' and '{"a": "b", "c", "d"}', but the second row should be
1111 // filtered out since '{"a": "b", "c", "d"}' <@ '{"a": "b"}' is false.
1112 invertedExpr.SetNotTight()
1113 return invertedExpr, nil
1114}
1115
1116// EncodeExistsInvertedIndexSpans takes in a key prefix and returns the
1117// spans that must be scanned in the inverted index to evaluate an exists (?)

Callers

nothing calls this directly

Calls 3

EncodeJSONAscendingFunction · 0.92
SetNotTightMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…