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

Function DecodeValueTag

pkg/util/encoding/encoding.go:2866–2894  ·  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

2864// will return the same thing. PeekValueLength works as expected with either of
2865// `b` or `b[typeOffset:]`.
2866func DecodeValueTag(
2867 b []byte,
2868) (typeOffset int, dataOffset int, colIDDelta uint32, typ Type, err error) {
2869 // TODO(dan): This can be made faster by special casing the single byte
2870 // version and skipping the column id extraction when it's not needed.
2871 if len(b) == 0 {
2872 return 0, 0, 0, Unknown, fmt.Errorf("empty array")
2873 }
2874 var n int
2875 var tag uint64
2876 b, n, tag, err = DecodeNonsortingUvarint(b)
2877 if err != nil {
2878 return 0, 0, 0, Unknown, err
2879 }
2880 colIDDelta = uint32(tag >> 4)
2881
2882 typ = Type(tag & 0xf)
2883 typeOffset = n - 1
2884 dataOffset = n
2885 if typ == SentinelType {
2886 _, n, tag, err = DecodeNonsortingUvarint(b)
2887 if err != nil {
2888 return 0, 0, 0, Unknown, err
2889 }
2890 typ = Type(tag)
2891 dataOffset += n
2892 }
2893 return typeOffset, dataOffset, colIDDelta, typ, nil
2894}
2895
2896// DecodeBoolValue decodes a value encoded by EncodeBoolValue.
2897func DecodeBoolValue(buf []byte) (remaining []byte, b bool, err error) {

Callers 4

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

Calls 3

DecodeNonsortingUvarintFunction · 0.85
ErrorfMethod · 0.80
TypeTypeAlias · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…