MCPcopy Create free account
hub / github.com/apache/datafusion / hex_int64

Function hex_int64

datafusion/spark/src/function/math/hex.rs:134–157  ·  view source on GitHub ↗
(num: i64, buffer: &mut [u8; 16])

Source from the content-addressed store, hash-verified

132
133#[inline]
134fn hex_int64(num: i64, buffer: &mut [u8; 16]) -> &[u8] {
135 if num == 0 {
136 return b"0";
137 }
138
139 // Walk the value two nibbles (one full byte) at a time. The buffer is
140 // filled from the right so the high-order nibbles end up first; the
141 // returned slice trims leading zeros automatically.
142 let mut n = num as u64;
143 let mut i = 16;
144 while n >= 0x10 {
145 i -= 2;
146 let pair = HEX_LOOKUP_UPPER[(n & 0xFF) as usize];
147 buffer[i] = pair[0];
148 buffer[i + 1] = pair[1];
149 n >>= 8;
150 }
151 if n > 0 {
152 // Single remaining high nibble (value 0x1..=0xF).
153 i -= 1;
154 buffer[i] = HEX_CHARS_UPPER_NIBBLES[n as usize];
155 }
156 &buffer[i..]
157}
158
159/// Generic hex encoding for byte array types
160fn hex_encode_bytes<'a, I, T>(

Callers 2

hex_encode_int64Function · 0.85
test_hex_int64Function · 0.85

Calls

no outgoing calls

Tested by 1

test_hex_int64Function · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…