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

Method TSVectorPGEncoding

pkg/util/tsearch/tsvector.go:105–117  ·  view source on GitHub ↗

TSVectorPGEncoding returns the PG-compatible wire protocol encoding for a given weight. Note that this is only allowable for TSVector tsweights, which can't have more than one weight set at the same time. In a TSQuery, you might have more than one weight per lexeme, which is not encodable using this

()

Source from the content-addressed store, hash-verified

103// have more than one weight per lexeme, which is not encodable using this
104// scheme.
105func (w tsWeight) TSVectorPGEncoding() (byte, error) {
106 switch w {
107 case weightA:
108 return 3, nil
109 case weightB:
110 return 2, nil
111 case weightC:
112 return 1, nil
113 case weightD, 0:
114 return 0, nil
115 }
116 return 0, errors.Errorf("invalid tsvector weight %d", w)
117}
118
119func (w tsWeight) val() int {
120 b, err := w.TSVectorPGEncoding()

Callers 3

valMethod · 0.95
EncodeTSVectorFunction · 0.80
EncodeTSVectorPGBinaryFunction · 0.80

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected