projjal commented on a change in pull request #9861:
URL: https://github.com/apache/arrow/pull/9861#discussion_r622906780



##########
File path: cpp/src/gandiva/function_registry_string.cc
##########
@@ -209,6 +209,71 @@ std::vector<NativeFunction> GetStringFunctionRegistry() {
                      "convert_replace_invalid_fromUTF8_binary",
                      NativeFunction::kNeedsContext),
 
+      NativeFunction("convert_toDOUBLE", {"convert_todouble"}, 
DataTypeVector{float64()},

Review comment:
       Can you add a comment explaining convert_toX functions converts X type 
to binary

##########
File path: cpp/src/gandiva/function_registry_string.cc
##########
@@ -209,6 +209,71 @@ std::vector<NativeFunction> GetStringFunctionRegistry() {
                      "convert_replace_invalid_fromUTF8_binary",
                      NativeFunction::kNeedsContext),
 
+      NativeFunction("convert_toDOUBLE", {"convert_todouble"}, 
DataTypeVector{float64()},
+                     binary(), kResultNullIfNull, "convert_toDOUBLE_binary",
+                     NativeFunction::kNeedsContext),
+
+      NativeFunction("convert_toDOUBLE_BE", {"convert_todouble_be"},
+                     DataTypeVector{float64()}, binary(), kResultNullIfNull,
+                     "convert_toDOUBLE_binary_be", 
NativeFunction::kNeedsContext),
+
+      NativeFunction("convert_toFLOAT", {"convert_tofloat"}, 
DataTypeVector{float32()},
+                     binary(), kResultNullIfNull, "convert_toFLOAT_binary",

Review comment:
       convert_toFLOAT_binary name seems ambigious..lets keep the function name 
as convert_toFLOAT

##########
File path: cpp/src/gandiva/function_registry_string.cc
##########
@@ -209,6 +209,71 @@ std::vector<NativeFunction> GetStringFunctionRegistry() {
                      "convert_replace_invalid_fromUTF8_binary",
                      NativeFunction::kNeedsContext),
 
+      NativeFunction("convert_toDOUBLE", {"convert_todouble"}, 
DataTypeVector{float64()},
+                     binary(), kResultNullIfNull, "convert_toDOUBLE_binary",
+                     NativeFunction::kNeedsContext),
+
+      NativeFunction("convert_toDOUBLE_BE", {"convert_todouble_be"},

Review comment:
       function name should not be case sensitive..so no need to having same 
name in lower case as alias

##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1310,6 +1311,196 @@ const char* 
convert_replace_invalid_fromUTF8_binary(int64_t context, const char*
   return ret;
 }
 
+FORCE_INLINE
+const char* convert_toDOUBLE_binary(int64_t context, double value, int32_t* 
out_len) {
+  *out_len = sizeof(value);
+  char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, 
*out_len));
+
+  if (ret == nullptr) {
+    gdv_fn_context_set_error_msg(context,
+                                 "Could not allocate memory for the output 
string");
+
+    *out_len = 0;
+    return "";
+  }
+
+  memcpy(ret, &value, *out_len);
+
+  return ret;
+}
+
+FORCE_INLINE
+const char* convert_toDOUBLE_binary_be(int64_t context, double value, int32_t* 
out_len) {
+  // The function behaves like convert_toDOUBLE_binary, but always return the 
result
+  // in big endian format
+  char* ret = const_cast<char*>(convert_toDOUBLE_binary(context, value, 
out_len));
+
+#if ARROW_LITTLE_ENDIAN
+  std::reverse(ret, ret + *out_len);

Review comment:
       lets not use c++ stdlib functions in precompiled.




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