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

Function EncodeValueTag

pkg/util/encoding/encoding.go:2568–2580  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
2568func 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.

Callers 15

EncodeNullValueFunction · 0.85
EncodeNotNullValueFunction · 0.85
EncodeBoolValueFunction · 0.85
EncodeIntValueFunction · 0.85
EncodeFloatValueFunction · 0.85
EncodeBytesValueFunction · 0.85
EncodeArrayValueFunction · 0.85
EncodeTimeValueFunction · 0.85
EncodeTimeTZValueFunction · 0.85
EncodeVoidValueFunction · 0.85
EncodeBox2DValueFunction · 0.85
EncodeGeoValueFunction · 0.85

Calls 1

EncodeNonsortingUvarintFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…