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

Function EncodeTSQueryPGBinary

pkg/util/tsearch/encoding.go:210–218  ·  view source on GitHub ↗

EncodeTSQueryPGBinary encodes a tsquery into a serialized representation. The below comment explains the wire protocol representation. It is taken from this page: https://www.npgsql.org/dev/types.html the tree written in prefix notation: First the number of tokens (a token is an operand or an op

(appendTo []byte, query TSQuery)

Source from the content-addressed store, hash-verified

208// For oper: UInt8 oper (1 = not, 2 = and, 3 = or, 4 = phrase).
209// In case of phrase oper code, an additional UInt16 field is sent (distance value of operator). Default is 1 for <->, otherwise the n value in '<n>'.
210func EncodeTSQueryPGBinary(appendTo []byte, query TSQuery) []byte {
211 // First, append a uint32 of the number of nodes in the query. We'll come
212 // back and fill this in later.
213 lengthIdx := len(appendTo)
214 appendTo = encoding.EncodeUint32Ascending(appendTo, 0)
215 var encoder tsNodeCodec
216 appendTo = encoder.encodeTSNodePGBinary(query.root, appendTo)
217 return encoding.PutUint32Ascending(appendTo, uint32(encoder.nTokens), lengthIdx)
218}
219
220// DecodeTSQueryPGBinary deserializes a serialized TSQuery in pgwire format.
221func DecodeTSQueryPGBinary(b []byte) (ret TSQuery, err error) {

Callers

nothing calls this directly

Calls 3

encodeTSNodePGBinaryMethod · 0.95
EncodeUint32AscendingFunction · 0.92
PutUint32AscendingFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…