emkornfield commented on a change in pull request #9707:
URL: https://github.com/apache/arrow/pull/9707#discussion_r597389422



##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -122,6 +123,133 @@ int32_t gdv_fn_populate_varlen_vector(int64_t 
context_ptr, int8_t* data_ptr,
   return 0;
 }
 
+#define SHA128_HASH_FUNCTION(TYPE)                                             
       \
+  GANDIVA_EXPORT                                                               
       \
+  const char *gdv_fn_sha128_##TYPE(int64_t context, gdv_##TYPE value,          
       \
+                                        bool validity, int32_t *out_length) {  
       \
+    if (!validity) {                                                           
       \
+      *out_length = 0;                                                         
       \
+      return "";                                                               
       \
+    }                                                                          
       \
+    auto value_as_long = gandiva::HashUtils::DoubleToLong((double)value);      
       \
+    const char *result = gandiva::HashUtils::HashUsingSha128(context,          
       \
+                                                               &value_as_long, 
       \
+                                                               
sizeof(value_as_long), \
+                                                               out_length);    
       \
+                                                                               
       \
+    return result;                                                             
       \
+  }                                                                            
       \
+
+#define SHA128_HASH_FUNCTION_BUF(TYPE)                                         
    \
+  GANDIVA_EXPORT                                                               
    \
+  const char *gdv_fn_sha128_##TYPE(int64_t context,                            
    \
+                                        gdv_##TYPE value,                      
    \
+                                        int32_t value_length,                  
    \
+                                        bool value_validity,                   
    \
+                                        int32_t *out_length) {                 
    \
+    if (!value_validity) {                                                     
    \
+      *out_length = 0;                                                         
    \
+      return "";                                                               
    \
+    }                                                                          
    \
+    return gandiva::HashUtils::HashUsingSha128(context, value,                 
    \
+    value_length, out_length);                                                 
    \
+  }
+
+#define SHA256_HASH_FUNCTION(TYPE)                                             
         \
+  GANDIVA_EXPORT                                                               
         \
+  const char *gdv_fn_sha256_##TYPE(int64_t context, gdv_##TYPE value,          
         \
+                                        bool validity, int32_t *out_length) {  
         \
+    if (!validity) {                                                           
         \
+      *out_length = 0;                                                         
         \
+      return "";                                                               
         \
+    }                                                                          
         \
+    auto value_as_long = gandiva::HashUtils::DoubleToLong((double)value);      
         \
+    const char *result = gandiva::HashUtils::HashUsingSha256(context,          
         \
+                                                               &value_as_long, 
         \

Review comment:
       it looks like this is a void*?  Why is the doubletolong conversion 
necessary?




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

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


Reply via email to