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, )
| 2864 | // will return the same thing. PeekValueLength works as expected with either of |
| 2865 | // `b` or `b[typeOffset:]`. |
| 2866 | func 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. |
| 2897 | func DecodeBoolValue(buf []byte) (remaining []byte, b bool, err error) { |
no test coverage detected
searching dependent graphs…