pedrumj2 commented on code in PR #13274:
URL: https://github.com/apache/gluten/pull/13274#discussion_r4275719859
##########
cpp/velox/udf/examples/MyUDF.cc:
##########
@@ -108,6 +109,84 @@ class MyUdfPlusOneRegisterer final : public
gluten::UdfRegisterer {
} // namespace myudfplusone
+namespace myudfsumrow {
+
+template <typename T>
+struct MyUdfSumRowFunction {
+ VELOX_DEFINE_FUNCTION_TYPES(T);
+
+ FOLLY_ALWAYS_INLINE bool call(int64_t& result, const arg_type<Row<int64_t,
int64_t>>& row) {
+ const auto a = row.template at<0>();
+ const auto b = row.template at<1>();
+ if (!a.has_value() || !b.has_value()) {
+ return false;
+ }
+ result = a.value() + b.value();
+ return true;
+ }
+};
+
+// name: myudf_sum_row
+// signatures:
+// struct<a:bigint,b:bigint> -> bigint
+// type: SimpleFunction
+class MyUdfSumRowRegisterer final : public gluten::UdfRegisterer {
+ public:
+ int getNumUdf() override {
+ return 1;
+ }
+
+ void populateUdfEntries(int& index, gluten::UdfEntry* udfEntries) override {
+ udfEntries[index++] = {name_.c_str(), kBigInt, 1, arg_, false, false};
+ }
+
+ void registerSignatures() override {
+ facebook::velox::registerFunction<MyUdfSumRowFunction, int64_t,
Row<int64_t, int64_t>>({name_});
+ }
+
+ private:
+ const std::string name_ = "myudf_sum_row";
+ const char* arg_[1] = {kStructAB};
+};
+
+} // namespace myudfsumrow
+
+namespace myudfmakerow {
+
+template <typename T>
+struct MyUdfMakeRowFunction {
+ VELOX_DEFINE_FUNCTION_TYPES(T);
+
+ FOLLY_ALWAYS_INLINE void call(out_type<Row<int64_t, int64_t>>& result, const
int64_t& a) {
+ result = std::make_tuple(a, a + 1);
Review Comment:
Updated, applied those changes
--
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]