EncodeValueTag encodes the prefix that is used by each of the EncodeFooValue methods. The prefix uses varints to encode a column id and type, packing them into a single byte when they're small (colID < 8 and typ < 15). This works by shifting the colID "left" by 4 and putting any type less than 15 i
(appendTo []byte, colID uint32, typ Type)
| 1810 | // Together, this means the everything but the last byte of the first uvarint |
| 1811 | // can be dropped if the column id isn't needed. |
| 1812 | func EncodeValueTag(appendTo []byte, colID uint32, typ Type) []byte { |
| 1813 | if typ >= SentinelType { |
| 1814 | appendTo = EncodeNonsortingUvarint(appendTo, uint64(colID)<<4|uint64(SentinelType)) |
| 1815 | return EncodeNonsortingUvarint(appendTo, uint64(typ)) |
| 1816 | } |
| 1817 | if colID == NoColumnID { |
| 1818 | // TODO(dan): EncodeValueTag is not inlined by the compiler. Copying this |
| 1819 | // special case into one of the EncodeFooValue functions speeds it up by |
| 1820 | // ~4ns. |
| 1821 | return append(appendTo, byte(typ)) |
| 1822 | } |
| 1823 | return EncodeNonsortingUvarint(appendTo, uint64(colID)<<4|uint64(typ)) |
| 1824 | } |
| 1825 | |
| 1826 | // EncodeNullValue encodes a null value, appends it to the supplied buffer, and |
| 1827 | // returns the final buffer. |
no test coverage detected
searching dependent graphs…