MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / EncodeVarintAscending

Function EncodeVarintAscending

pkg/util/encoding/encoding.go:225–251  ·  view source on GitHub ↗

EncodeVarintAscending encodes the int64 value using a variable length (length-prefixed) representation. The length is encoded as a single byte. If the value to be encoded is negative the length is encoded as 8-numBytes. If the value is positive it is encoded as 8+numBytes. The encoded bytes are appe

(b []byte, v int64)

Source from the content-addressed store, hash-verified

223// 8+numBytes. The encoded bytes are appended to the supplied buffer
224// and the final buffer is returned.
225func EncodeVarintAscending(b []byte, v int64) []byte {
226 if v < 0 {
227 switch {
228 case v >= -0xff:
229 return append(b, IntMin+7, byte(v))
230 case v >= -0xffff:
231 return append(b, IntMin+6, byte(v>>8), byte(v))
232 case v >= -0xffffff:
233 return append(b, IntMin+5, byte(v>>16), byte(v>>8), byte(v))
234 case v >= -0xffffffff:
235 return append(b, IntMin+4, byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
236 case v >= -0xffffffffff:
237 return append(b, IntMin+3, byte(v>>32), byte(v>>24), byte(v>>16), byte(v>>8),
238 byte(v))
239 case v >= -0xffffffffffff:
240 return append(b, IntMin+2, byte(v>>40), byte(v>>32), byte(v>>24), byte(v>>16),
241 byte(v>>8), byte(v))
242 case v >= -0xffffffffffffff:
243 return append(b, IntMin+1, byte(v>>48), byte(v>>40), byte(v>>32), byte(v>>24),
244 byte(v>>16), byte(v>>8), byte(v))
245 default:
246 return append(b, IntMin, byte(v>>56), byte(v>>48), byte(v>>40), byte(v>>32),
247 byte(v>>24), byte(v>>16), byte(v>>8), byte(v))
248 }
249 }
250 return EncodeUvarintAscending(b, uint64(v))
251}
252
253// EncodeVarintDescending encodes the int64 value so that it sorts in reverse
254// order, from largest to smallest.

Callers 4

EncodeVarintDescendingFunction · 0.85
encodeTimeFunction · 0.85
encodeTimeTZFunction · 0.85
EncodeDurationAscendingFunction · 0.85

Calls 1

EncodeUvarintAscendingFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…