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)
| 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>'. |
| 210 | func 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. |
| 221 | func DecodeTSQueryPGBinary(b []byte) (ret TSQuery, err error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…