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

Function DecodeValueTag

pkg/util/encoding/encoding.go:2036–2062  ·  view source on GitHub ↗

DecodeValueTag decodes a value encoded by EncodeValueTag, used as a prefix in each of the other EncodeFooValue methods. The tag is structured such that the encoded column id can be dropped from the front by removing the first `typeOffset` bytes. DecodeValueTag, PeekValueLength and each of the Decod

(b []byte)

Source from the content-addressed store, hash-verified

2034// will return the same thing. PeekValueLength works as expected with either of
2035// `b` or `b[typeOffset:]`.
2036func DecodeValueTag(b []byte) (typeOffset int, dataOffset int, colID uint32, typ Type, err error) {
2037 // TODO(dan): This can be made faster by special casing the single byte
2038 // version and skipping the column id extraction when it's not needed.
2039 if len(b) == 0 {
2040 return 0, 0, 0, Unknown, fmt.Errorf("empty array")
2041 }
2042 var n int
2043 var tag uint64
2044 b, n, tag, err = DecodeNonsortingUvarint(b)
2045 if err != nil {
2046 return 0, 0, 0, Unknown, err
2047 }
2048 colID = uint32(tag >> 4)
2049
2050 typ = Type(tag & 0xf)
2051 typeOffset = n - 1
2052 dataOffset = n
2053 if typ == SentinelType {
2054 _, n, tag, err = DecodeNonsortingUvarint(b)
2055 if err != nil {
2056 return 0, 0, 0, Unknown, err
2057 }
2058 typ = Type(tag)
2059 dataOffset += n
2060 }
2061 return typeOffset, dataOffset, colID, typ, nil
2062}
2063
2064// DecodeBoolValue decodes a value encoded by EncodeBoolValue.
2065func DecodeBoolValue(buf []byte) (remaining []byte, b bool, err error) {

Callers 4

DecodeBoolValueFunction · 0.85
decodeValueTypeAssertFunction · 0.85
PeekValueLengthFunction · 0.85
PrettyPrintValueEncodedFunction · 0.85

Calls 2

DecodeNonsortingUvarintFunction · 0.85
TypeTypeAlias · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…