Jefffrey commented on code in PR #19738:
URL: https://github.com/apache/datafusion/pull/19738#discussion_r2684588623


##########
datafusion/spark/src/function/math/hex.rs:
##########
@@ -110,37 +111,88 @@ impl ScalarUDFImpl for SparkHex {
     }
 }
 
-fn hex_int64(num: i64) -> String {
-    format!("{num:X}")
-}
-
 /// Hex encoding lookup tables for fast byte-to-hex conversion
 const HEX_CHARS_LOWER: &[u8; 16] = b"0123456789abcdef";
 const HEX_CHARS_UPPER: &[u8; 16] = b"0123456789ABCDEF";
 
 #[inline]
-fn hex_encode<T: AsRef<[u8]>>(data: T, lower_case: bool) -> String {
-    let bytes = data.as_ref();
-    let mut s = String::with_capacity(bytes.len() * 2);
-    let hex_chars = if lower_case {
+fn hex_int64(num: i64, buffer: &mut Vec<u8>) {
+    if num == 0 {
+        buffer.push(HEX_CHARS_UPPER[0]);
+        return;
+    }
+
+    let mut n = num as u64;
+    let mut temp = [0u8; 16];
+    let mut i = 16;
+    while n != 0 {
+        i -= 1;
+        let digest = (n & 0xF) as u8;
+        temp[i] = HEX_CHARS_UPPER[digest as usize];
+        n >>= 4;
+    }

Review Comment:
   Thanks for checking this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to