2121
2222#include " codegen/annotator.h"
2323#include " codegen/dex.h"
24+ #include " codegen/function_holder_registry.h"
2425#include " codegen/function_registry.h"
2526#include " codegen/node.h"
2627#include " gandiva/function_signature.h"
@@ -53,10 +54,19 @@ Status ExprDecomposer::Visit(const FunctionNode &node) {
5354 // decompose the children.
5455 std::vector<ValueValidityPairPtr> args;
5556 for (auto &child : node.children ()) {
56- child->Accept (*this );
57+ auto status = child->Accept (*this );
58+ GANDIVA_RETURN_NOT_OK (status);
59+
5760 args.push_back (result ());
5861 }
5962
63+ // Make a function holder, if required.
64+ std::shared_ptr<FunctionHolder> holder;
65+ if (native_function->needs_holder ()) {
66+ auto status = FunctionHolderRegistry::Make (desc->name (), node, &holder);
67+ GANDIVA_RETURN_NOT_OK (status);
68+ }
69+
6070 if (native_function->result_nullable_type () == RESULT_NULL_IF_NULL ) {
6171 // These functions are decomposable, merge the validity bits of the children.
6272
@@ -68,11 +78,13 @@ Status ExprDecomposer::Visit(const FunctionNode &node) {
6878 decomposed->validity_exprs ().end ());
6979 }
7080
71- auto value_dex = std::make_shared<NonNullableFuncDex>(desc, native_function, args);
81+ auto value_dex =
82+ std::make_shared<NonNullableFuncDex>(desc, native_function, holder, args);
7283 result_ = std::make_shared<ValueValidityPair>(merged_validity, value_dex);
7384 } else if (native_function->result_nullable_type () == RESULT_NULL_NEVER ) {
7485 // These functions always output valid results. So, no validity dex.
75- auto value_dex = std::make_shared<NullableNeverFuncDex>(desc, native_function, args);
86+ auto value_dex =
87+ std::make_shared<NullableNeverFuncDex>(desc, native_function, holder, args);
7688 result_ = std::make_shared<ValueValidityPair>(value_dex);
7789 } else {
7890 DCHECK (native_function->result_nullable_type () == RESULT_NULL_INTERNAL );
@@ -81,8 +93,8 @@ Status ExprDecomposer::Visit(const FunctionNode &node) {
8193 int local_bitmap_idx = annotator_.AddLocalBitMap ();
8294 auto validity_dex = std::make_shared<LocalBitMapValidityDex>(local_bitmap_idx);
8395
84- auto value_dex = std::make_shared<NullableInternalFuncDex>(desc, native_function,
85- args, local_bitmap_idx);
96+ auto value_dex = std::make_shared<NullableInternalFuncDex>(
97+ desc, native_function, holder, args, local_bitmap_idx);
8698 result_ = std::make_shared<ValueValidityPair>(validity_dex, value_dex);
8799 }
88100 return Status::OK ();
@@ -91,16 +103,19 @@ Status ExprDecomposer::Visit(const FunctionNode &node) {
91103// Decompose an IfNode
92104Status ExprDecomposer::Visit (const IfNode &node) {
93105 // Add a local bitmap to track the output validity.
94- node.condition ()->Accept (*this );
106+ auto status = node.condition ()->Accept (*this );
107+ GANDIVA_RETURN_NOT_OK (status);
95108 auto condition_vv = result ();
96109
97110 int local_bitmap_idx = PushThenEntry (node);
98- node.then_node ()->Accept (*this );
111+ status = node.then_node ()->Accept (*this );
112+ GANDIVA_RETURN_NOT_OK (status);
99113 auto then_vv = result ();
100114 PopThenEntry (node);
101115
102116 PushElseEntry (node, local_bitmap_idx);
103- node.else_node ()->Accept (*this );
117+ status = node.else_node ()->Accept (*this );
118+ GANDIVA_RETURN_NOT_OK (status);
104119 auto else_vv = result ();
105120 bool is_terminal_else = PopElseEntry (node);
106121
@@ -118,7 +133,9 @@ Status ExprDecomposer::Visit(const BooleanNode &node) {
118133 // decompose the children.
119134 std::vector<ValueValidityPairPtr> args;
120135 for (auto &child : node.children ()) {
121- child->Accept (*this );
136+ auto status = child->Accept (*this );
137+ GANDIVA_RETURN_NOT_OK (status);
138+
122139 args.push_back (result ());
123140 }
124141
0 commit comments