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 (colIDDelta < 8 and typ < 15). This works by shifting the colIDDelta "left" by 4 and putting any type less
(appendTo []byte, colIDDelta uint32, typ Type)
| 2566 | // Together, this means the everything but the last byte of the first uvarint |
| 2567 | // can be dropped if the column id isn't needed. |
| 2568 | func EncodeValueTag(appendTo []byte, colIDDelta uint32, typ Type) []byte { |
| 2569 | if typ >= SentinelType { |
| 2570 | appendTo = EncodeNonsortingUvarint(appendTo, uint64(colIDDelta)<<4|uint64(SentinelType)) |
| 2571 | return EncodeNonsortingUvarint(appendTo, uint64(typ)) |
| 2572 | } |
| 2573 | if colIDDelta == NoColumnID { |
| 2574 | // TODO(dan): EncodeValueTag is not inlined by the compiler. Copying this |
| 2575 | // special case into one of the EncodeFooValue functions speeds it up by |
| 2576 | // ~4ns. |
| 2577 | return append(appendTo, byte(typ)) |
| 2578 | } |
| 2579 | return EncodeNonsortingUvarint(appendTo, uint64(colIDDelta)<<4|uint64(typ)) |
| 2580 | } |
| 2581 | |
| 2582 | // EncodeNullValue encodes a null value, appends it to the supplied buffer, and |
| 2583 | // returns the final buffer. |
no test coverage detected
searching dependent graphs…