summaryrefslogtreecommitdiffstats
path: root/src/arrow/c_glib/gandiva-glib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/arrow/c_glib/gandiva-glib
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/arrow/c_glib/gandiva-glib')
-rw-r--r--src/arrow/c_glib/gandiva-glib/enums.c.template52
-rw-r--r--src/arrow/c_glib/gandiva-glib/enums.h.template41
-rw-r--r--src/arrow/c_glib/gandiva-glib/expression.cpp294
-rw-r--r--src/arrow/c_glib/gandiva-glib/expression.h63
-rw-r--r--src/arrow/c_glib/gandiva-glib/expression.hpp39
-rw-r--r--src/arrow/c_glib/gandiva-glib/filter.cpp257
-rw-r--r--src/arrow/c_glib/gandiva-glib/filter.h49
-rw-r--r--src/arrow/c_glib/gandiva-glib/filter.hpp33
-rw-r--r--src/arrow/c_glib/gandiva-glib/function-registry.cpp116
-rw-r--r--src/arrow/c_glib/gandiva-glib/function-registry.h44
-rw-r--r--src/arrow/c_glib/gandiva-glib/function-signature.cpp243
-rw-r--r--src/arrow/c_glib/gandiva-glib/function-signature.h48
-rw-r--r--src/arrow/c_glib/gandiva-glib/function-signature.hpp27
-rw-r--r--src/arrow/c_glib/gandiva-glib/gandiva-glib.h31
-rw-r--r--src/arrow/c_glib/gandiva-glib/gandiva-glib.hpp28
-rw-r--r--src/arrow/c_glib/gandiva-glib/meson.build120
-rw-r--r--src/arrow/c_glib/gandiva-glib/native-function.cpp282
-rw-r--r--src/arrow/c_glib/gandiva-glib/native-function.h65
-rw-r--r--src/arrow/c_glib/gandiva-glib/native-function.hpp36
-rw-r--r--src/arrow/c_glib/gandiva-glib/node.cpp1688
-rw-r--r--src/arrow/c_glib/gandiva-glib/node.h395
-rw-r--r--src/arrow/c_glib/gandiva-glib/node.hpp49
-rw-r--r--src/arrow/c_glib/gandiva-glib/projector.cpp391
-rw-r--r--src/arrow/c_glib/gandiva-glib/projector.h75
-rw-r--r--src/arrow/c_glib/gandiva-glib/projector.hpp39
-rw-r--r--src/arrow/c_glib/gandiva-glib/selection-vector.cpp323
-rw-r--r--src/arrow/c_glib/gandiva-glib/selection-vector.h128
-rw-r--r--src/arrow/c_glib/gandiva-glib/selection-vector.hpp32
-rw-r--r--src/arrow/c_glib/gandiva-glib/version.h.in218
29 files changed, 5206 insertions, 0 deletions
diff --git a/src/arrow/c_glib/gandiva-glib/enums.c.template b/src/arrow/c_glib/gandiva-glib/enums.c.template
new file mode 100644
index 000000000..7ea2ea7b5
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/enums.c.template
@@ -0,0 +1,52 @@
+/*** BEGIN file-header ***/
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <gandiva-glib/gandiva-glib.h>
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type(void)
+{
+ static GType etype = 0;
+ if (G_UNLIKELY(etype == 0)) {
+ static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ {@VALUENAME@, "@VALUENAME@", "@valuenick@"},
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ {0, NULL, NULL}
+ };
+ etype = g_@type@_register_static(g_intern_static_string("@EnumName@"), values);
+ }
+ return etype;
+}
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+/*** END file-tail ***/
diff --git a/src/arrow/c_glib/gandiva-glib/enums.h.template b/src/arrow/c_glib/gandiva-glib/enums.h.template
new file mode 100644
index 000000000..8d7b46303
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/enums.h.template
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type(void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+
+G_END_DECLS
+/*** END file-tail ***/
diff --git a/src/arrow/c_glib/gandiva-glib/expression.cpp b/src/arrow/c_glib/gandiva-glib/expression.cpp
new file mode 100644
index 000000000..e4368f84d
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/expression.cpp
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <arrow-glib/field.hpp>
+
+#include <gandiva-glib/expression.hpp>
+#include <gandiva-glib/node.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: expression
+ * @title: Expression classes
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * #GGandivaExpression is a class for an expression tree with a root node,
+ * and a result field.
+ *
+ * #GGandivaCondition is a class for an expression that returns boolean.
+ *
+ * Since: 0.12.0
+ */
+
+typedef struct GGandivaExpressionPrivate_ {
+ std::shared_ptr<gandiva::Expression> expression;
+ GGandivaNode *root_node;
+ GArrowField *result_field;
+} GGandivaExpressionPrivate;
+
+enum {
+ PROP_EXPRESSION = 1,
+ PROP_ROOT_NODE,
+ PROP_RESULT_FIELD
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaExpression,
+ ggandiva_expression,
+ G_TYPE_OBJECT)
+
+#define GGANDIVA_EXPRESSION_GET_PRIVATE(object) \
+ static_cast<GGandivaExpressionPrivate *>( \
+ ggandiva_expression_get_instance_private( \
+ GGANDIVA_EXPRESSION(object)))
+
+static void
+ggandiva_expression_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_EXPRESSION_GET_PRIVATE(object);
+
+ if (priv->root_node) {
+ g_object_unref(priv->root_node);
+ priv->root_node = nullptr;
+ }
+
+ if (priv->result_field) {
+ g_object_unref(priv->result_field);
+ priv->result_field = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_expression_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_expression_finalize(GObject *object)
+{
+ auto priv = GGANDIVA_EXPRESSION_GET_PRIVATE(object);
+
+ priv->expression.~shared_ptr();
+
+ G_OBJECT_CLASS(ggandiva_expression_parent_class)->finalize(object);
+}
+
+static void
+ggandiva_expression_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_EXPRESSION_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_EXPRESSION:
+ priv->expression =
+ *static_cast<std::shared_ptr<gandiva::Expression> *>(g_value_get_pointer(value));
+ break;
+ case PROP_ROOT_NODE:
+ priv->root_node = GGANDIVA_NODE(g_value_dup_object(value));
+ break;
+ case PROP_RESULT_FIELD:
+ priv->result_field = GARROW_FIELD(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_expression_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_EXPRESSION_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_ROOT_NODE:
+ g_value_set_object(value, priv->root_node);
+ break;
+ case PROP_RESULT_FIELD:
+ g_value_set_object(value, priv->result_field);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_expression_init(GGandivaExpression *object)
+{
+ auto priv = GGANDIVA_EXPRESSION_GET_PRIVATE(object);
+ new(&priv->expression) std::shared_ptr<gandiva::Expression>;
+}
+
+static void
+ggandiva_expression_class_init(GGandivaExpressionClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_expression_dispose;
+ gobject_class->finalize = ggandiva_expression_finalize;
+ gobject_class->set_property = ggandiva_expression_set_property;
+ gobject_class->get_property = ggandiva_expression_get_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_pointer("expression",
+ "Expression",
+ "The raw std::shared<gandiva::Expression> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_EXPRESSION, spec);
+
+ spec = g_param_spec_object("root-node",
+ "Root Node",
+ "The root node for the expression",
+ GGANDIVA_TYPE_NODE,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_ROOT_NODE, spec);
+
+ spec = g_param_spec_object("result-field",
+ "Result Field",
+ "The name and type of returned value as #GArrowField",
+ GARROW_TYPE_FIELD,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_RESULT_FIELD, spec);
+}
+
+/**
+ * ggandiva_expression_new:
+ * @root_node: The root node for the expression.
+ * @result_field: The name and type of returned value as #GArrowField.
+ *
+ * Returns: A newly created #GGandivaExpression.
+ *
+ * Since: 0.12.0
+ */
+GGandivaExpression *
+ggandiva_expression_new(GGandivaNode *root_node,
+ GArrowField *result_field)
+{
+ auto gandiva_root_node = ggandiva_node_get_raw(root_node);
+ auto arrow_result_field = garrow_field_get_raw(result_field);
+ auto gandiva_expression =
+ gandiva::TreeExprBuilder::MakeExpression(gandiva_root_node,
+ arrow_result_field);
+ return ggandiva_expression_new_raw(&gandiva_expression,
+ root_node,
+ result_field);
+}
+
+/**
+ * ggandiva_expression_to_string:
+ * @expression: A #GGandivaExpression.
+ *
+ * Returns: (transfer full): The string representation of the node in the expression tree.
+ *
+ * It should be freed with g_free() when no longer needed.
+ *
+ * Since: 0.12.0
+ */
+gchar *
+ggandiva_expression_to_string(GGandivaExpression *expression)
+{
+ auto gandiva_expression = ggandiva_expression_get_raw(expression);
+ auto string = gandiva_expression->ToString();
+ return g_strndup(string.data(), string.size());
+}
+
+
+G_DEFINE_TYPE(GGandivaCondition,
+ ggandiva_condition,
+ GGANDIVA_TYPE_EXPRESSION)
+
+static void
+ggandiva_condition_init(GGandivaCondition *object)
+{
+}
+
+static void
+ggandiva_condition_class_init(GGandivaConditionClass *klass)
+{
+}
+
+/**
+ * ggandiva_condition_new:
+ * @root_node: The root node for the condition.
+ *
+ * Returns: A newly created #GGandivaCondition.
+ *
+ * Since: 4.0.0
+ */
+GGandivaCondition *
+ggandiva_condition_new(GGandivaNode *root_node)
+{
+ auto gandiva_root_node = ggandiva_node_get_raw(root_node);
+ auto gandiva_condition =
+ gandiva::TreeExprBuilder::MakeCondition(gandiva_root_node);
+ return ggandiva_condition_new_raw(&gandiva_condition,
+ root_node);
+}
+
+
+G_END_DECLS
+
+GGandivaExpression *
+ggandiva_expression_new_raw(std::shared_ptr<gandiva::Expression> *gandiva_expression,
+ GGandivaNode *root_node,
+ GArrowField *result_field)
+{
+ auto expression = g_object_new(GGANDIVA_TYPE_EXPRESSION,
+ "expression", gandiva_expression,
+ "root-node", root_node,
+ "result-field", result_field,
+ NULL);
+ return GGANDIVA_EXPRESSION(expression);
+}
+
+std::shared_ptr<gandiva::Expression>
+ggandiva_expression_get_raw(GGandivaExpression *expression)
+{
+ auto priv = GGANDIVA_EXPRESSION_GET_PRIVATE(expression);
+ return priv->expression;
+}
+
+
+GGandivaCondition *
+ggandiva_condition_new_raw(std::shared_ptr<gandiva::Condition> *gandiva_condition,
+ GGandivaNode *root_node)
+{
+ auto arrow_result_field = (*gandiva_condition)->result();
+ auto result_field = garrow_field_new_raw(&arrow_result_field, nullptr);
+ auto condition = g_object_new(GGANDIVA_TYPE_CONDITION,
+ "expression", gandiva_condition,
+ "root-node", root_node,
+ "result-field", result_field,
+ NULL);
+ return GGANDIVA_CONDITION(condition);
+}
+
+std::shared_ptr<gandiva::Condition>
+ggandiva_condition_get_raw(GGandivaCondition *condition)
+{
+ return std::static_pointer_cast<gandiva::Condition>(
+ ggandiva_expression_get_raw(GGANDIVA_EXPRESSION(condition)));
+}
diff --git a/src/arrow/c_glib/gandiva-glib/expression.h b/src/arrow/c_glib/gandiva-glib/expression.h
new file mode 100644
index 000000000..0a720d9af
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/expression.h
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <arrow-glib/arrow-glib.h>
+
+#include <gandiva-glib/node.h>
+
+G_BEGIN_DECLS
+
+#define GGANDIVA_TYPE_EXPRESSION (ggandiva_expression_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaExpression,
+ ggandiva_expression,
+ GGANDIVA,
+ EXPRESSION,
+ GObject)
+
+struct _GGandivaExpressionClass
+{
+ GObjectClass parent_class;
+};
+
+GGandivaExpression *
+ggandiva_expression_new(GGandivaNode *root_node,
+ GArrowField *result_field);
+gchar *ggandiva_expression_to_string(GGandivaExpression *expression);
+
+
+#define GGANDIVA_TYPE_CONDITION (ggandiva_condition_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaCondition,
+ ggandiva_condition,
+ GGANDIVA,
+ CONDITION,
+ GGandivaExpression)
+
+struct _GGandivaConditionClass
+{
+ GGandivaExpressionClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_4_0
+GGandivaCondition *
+ggandiva_condition_new(GGandivaNode *root_node);
+
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/expression.hpp b/src/arrow/c_glib/gandiva-glib/expression.hpp
new file mode 100644
index 000000000..45b659393
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/expression.hpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <gandiva/expression.h>
+#include <gandiva/tree_expr_builder.h>
+
+#include <gandiva-glib/expression.h>
+
+GGandivaExpression *
+ggandiva_expression_new_raw(std::shared_ptr<gandiva::Expression> *gandiva_expression,
+ GGandivaNode *root_node,
+ GArrowField *result_field);
+std::shared_ptr<gandiva::Expression> ggandiva_expression_get_raw(GGandivaExpression *expression);
+
+GGandivaCondition
+*ggandiva_condition_new_raw(std::shared_ptr<gandiva::Condition> *gandiva_expression,
+ GGandivaNode *root_node);
+std::shared_ptr<gandiva::Condition>
+ggandiva_condition_get_raw(GGandivaCondition *condition);
diff --git a/src/arrow/c_glib/gandiva-glib/filter.cpp b/src/arrow/c_glib/gandiva-glib/filter.cpp
new file mode 100644
index 000000000..baed69946
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/filter.cpp
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <limits>
+
+#include <arrow-glib/basic-array.hpp>
+#include <arrow-glib/error.hpp>
+#include <arrow-glib/record-batch.hpp>
+#include <arrow-glib/schema.hpp>
+
+#include <gandiva-glib/expression.hpp>
+#include <gandiva-glib/filter.hpp>
+#include <gandiva-glib/selection-vector.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: filter
+ * @title: Filter classes
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * #GGandivaFilter is a class for selecting records by a specific
+ * condition.
+ *
+ * Since: 4.0.0
+ */
+
+typedef struct GGandivaFilterPrivate_ {
+ std::shared_ptr<gandiva::Filter> filter;
+ GArrowSchema *schema;
+ GGandivaCondition *condition;
+} GGandivaFilterPrivate;
+
+enum {
+ PROP_FILTER = 1,
+ PROP_SCHEMA,
+ PROP_CONDITION,
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaFilter,
+ ggandiva_filter,
+ G_TYPE_OBJECT)
+
+#define GGANDIVA_FILTER_GET_PRIVATE(obj) \
+ static_cast<GGandivaFilterPrivate *>( \
+ ggandiva_filter_get_instance_private( \
+ GGANDIVA_FILTER(obj)))
+
+static void
+ggandiva_filter_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_FILTER_GET_PRIVATE(object);
+
+ if (priv->schema) {
+ g_object_unref(priv->schema);
+ priv->schema = nullptr;
+ }
+
+ if (priv->condition) {
+ g_object_unref(priv->condition);
+ priv->condition = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_filter_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_filter_finalize(GObject *object)
+{
+ auto priv = GGANDIVA_FILTER_GET_PRIVATE(object);
+
+ priv->filter.~shared_ptr();
+
+ G_OBJECT_CLASS(ggandiva_filter_parent_class)->finalize(object);
+}
+
+static void
+ggandiva_filter_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_FILTER_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_FILTER:
+ priv->filter =
+ *static_cast<std::shared_ptr<gandiva::Filter> *>(g_value_get_pointer(value));
+ break;
+ case PROP_SCHEMA:
+ priv->schema = GARROW_SCHEMA(g_value_dup_object(value));
+ break;
+ case PROP_CONDITION:
+ priv->condition = GGANDIVA_CONDITION(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_filter_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_FILTER_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_SCHEMA:
+ g_value_set_object(value, priv->schema);
+ break;
+ case PROP_CONDITION:
+ g_value_set_object(value, priv->condition);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_filter_init(GGandivaFilter *object)
+{
+ auto priv = GGANDIVA_FILTER_GET_PRIVATE(object);
+ new(&priv->filter) std::shared_ptr<gandiva::Filter>;
+}
+
+static void
+ggandiva_filter_class_init(GGandivaFilterClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_filter_dispose;
+ gobject_class->finalize = ggandiva_filter_finalize;
+ gobject_class->set_property = ggandiva_filter_set_property;
+ gobject_class->get_property = ggandiva_filter_get_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_pointer("filter",
+ "Filter",
+ "The raw std::shared<gandiva::Filter> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_FILTER, spec);
+
+ spec = g_param_spec_object("schema",
+ "Schema",
+ "The schema for input record batch",
+ GARROW_TYPE_SCHEMA,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_SCHEMA, spec);
+
+ spec = g_param_spec_object("condition",
+ "Condition",
+ "The condition for the filter",
+ GGANDIVA_TYPE_CONDITION,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_CONDITION, spec);
+}
+
+/**
+ * ggandiva_filter_new:
+ * @schema: A #GArrowSchema.
+ * @condition: The condition to be used.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GGandivaFilter on success,
+ * %NULL on error.
+ *
+ * Since: 4.0.0
+ */
+GGandivaFilter *
+ggandiva_filter_new(GArrowSchema *schema,
+ GGandivaCondition *condition,
+ GError **error)
+{
+ auto arrow_schema = garrow_schema_get_raw(schema);
+ auto gandiva_condition = ggandiva_condition_get_raw(condition);
+ std::shared_ptr<gandiva::Filter> gandiva_filter;
+ auto status = gandiva::Filter::Make(arrow_schema,
+ gandiva_condition,
+ &gandiva_filter);
+ if (garrow_error_check(error, status, "[gandiva][filter][new]")) {
+ return ggandiva_filter_new_raw(&gandiva_filter, schema, condition);
+ } else {
+ return NULL;
+ }
+}
+
+/**
+ * ggandiva_filter_evaluate:
+ * @filter: A #GGandivaFilter.
+ * @record_batch: A #GArrowRecordBatch.
+ * @selection_vector: A #GGandivaSelectionVector that is used as
+ * output.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE otherwise.
+ *
+ * Since: 4.0.0
+ */
+gboolean
+ggandiva_filter_evaluate(GGandivaFilter *filter,
+ GArrowRecordBatch *record_batch,
+ GGandivaSelectionVector *selection_vector,
+ GError **error)
+{
+ auto gandiva_filter = ggandiva_filter_get_raw(filter);
+ auto arrow_record_batch = garrow_record_batch_get_raw(record_batch);
+ auto gandiva_selection_vector =
+ ggandiva_selection_vector_get_raw(selection_vector);
+ auto status = gandiva_filter->Evaluate(*arrow_record_batch,
+ gandiva_selection_vector);
+ return garrow_error_check(error, status, "[gandiva][filter][evaluate]");
+}
+
+G_END_DECLS
+
+GGandivaFilter *
+ggandiva_filter_new_raw(std::shared_ptr<gandiva::Filter> *gandiva_filter,
+ GArrowSchema *schema,
+ GGandivaCondition *condition)
+{
+ auto filter = g_object_new(GGANDIVA_TYPE_FILTER,
+ "filter", gandiva_filter,
+ "schema", schema,
+ "condition", condition,
+ NULL);
+ return GGANDIVA_FILTER(filter);
+}
+
+std::shared_ptr<gandiva::Filter>
+ggandiva_filter_get_raw(GGandivaFilter *filter)
+{
+ auto priv = GGANDIVA_FILTER_GET_PRIVATE(filter);
+ return priv->filter;
+}
diff --git a/src/arrow/c_glib/gandiva-glib/filter.h b/src/arrow/c_glib/gandiva-glib/filter.h
new file mode 100644
index 000000000..9a0a5dc5d
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/filter.h
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva-glib/expression.h>
+#include <gandiva-glib/selection-vector.h>
+
+G_BEGIN_DECLS
+
+#define GGANDIVA_TYPE_FILTER (ggandiva_filter_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaFilter,
+ ggandiva_filter,
+ GGANDIVA,
+ FILTER,
+ GObject)
+
+struct _GGandivaFilterClass
+{
+ GObjectClass parent_class;
+};
+
+GGandivaFilter *
+ggandiva_filter_new(GArrowSchema *schema,
+ GGandivaCondition *condition,
+ GError **error);
+gboolean
+ggandiva_filter_evaluate(GGandivaFilter *filter,
+ GArrowRecordBatch *record_batch,
+ GGandivaSelectionVector *selection_vector,
+ GError **error);
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/filter.hpp b/src/arrow/c_glib/gandiva-glib/filter.hpp
new file mode 100644
index 000000000..a0bee9120
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/filter.hpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <gandiva/filter.h>
+
+#include <gandiva-glib/filter.h>
+
+GGandivaFilter *
+ggandiva_filter_new_raw(std::shared_ptr<gandiva::Filter> *gandiva_filter,
+ GArrowSchema *schema,
+ GGandivaCondition *condition);
+std::shared_ptr<gandiva::Filter>
+ggandiva_filter_get_raw(GGandivaFilter *filter);
diff --git a/src/arrow/c_glib/gandiva-glib/function-registry.cpp b/src/arrow/c_glib/gandiva-glib/function-registry.cpp
new file mode 100644
index 000000000..a95019bd6
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/function-registry.cpp
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <gandiva/function_registry.h>
+#include <gandiva-glib/function-registry.h>
+
+#include <gandiva-glib/function-signature.hpp>
+#include <gandiva-glib/native-function.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: function-registry
+ * @short_description: FunctionRegistry class
+ * @title: FunctionRegistry class
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * Since: 0.14.0
+ */
+
+G_DEFINE_TYPE(GGandivaFunctionRegistry,
+ ggandiva_function_registry,
+ G_TYPE_OBJECT)
+
+static void
+ggandiva_function_registry_init(GGandivaFunctionRegistry *object)
+{
+}
+
+static void
+ggandiva_function_registry_class_init(GGandivaFunctionRegistryClass *klass)
+{
+}
+
+/**
+ * ggandiva_function_registry_new:
+ *
+ * Returns: A newly created #GGandivaFunctionRegistry.
+ *
+ * Since: 0.14.0
+ */
+GGandivaFunctionRegistry *
+ggandiva_function_registry_new(void)
+{
+ return GGANDIVA_FUNCTION_REGISTRY(g_object_new(GGANDIVA_TYPE_FUNCTION_REGISTRY, NULL));
+}
+
+/**
+ * ggandiva_function_registry_lookup:
+ * @function_registry: A #GGandivaFunctionRegistry.
+ * @function_signature: A #GGandivaFunctionSignature to be looked up.
+ *
+ * Returns: (transfer full) (nullable):
+ * The native functions associated to the given #GGandivaFunctionSignature.
+ *
+ * Since: 0.14.0
+ */
+GGandivaNativeFunction *
+ggandiva_function_registry_lookup(GGandivaFunctionRegistry *function_registry,
+ GGandivaFunctionSignature *function_signature)
+{
+ gandiva::FunctionRegistry gandiva_function_registry;
+ auto gandiva_function_signature =
+ ggandiva_function_signature_get_raw(function_signature);
+ auto gandiva_native_function =
+ gandiva_function_registry.LookupSignature(*gandiva_function_signature);
+ if (gandiva_native_function) {
+ return ggandiva_native_function_new_raw(gandiva_native_function);
+ } else {
+ return NULL;
+ }
+}
+
+/**
+ * ggandiva_function_registry_get_native_functions:
+ * @function_registry: A #GGandivaFunctionRegistry.
+ *
+ * Returns: (transfer full) (element-type GGandivaNativeFunction):
+ * The native functions in the function registry.
+ *
+ * Since: 0.14.0
+ */
+GList *
+ggandiva_function_registry_get_native_functions(GGandivaFunctionRegistry *function_registry)
+{
+ gandiva::FunctionRegistry gandiva_function_registry;
+
+ GList *native_functions = nullptr;
+ for (auto gandiva_native_function = gandiva_function_registry.begin();
+ gandiva_native_function != gandiva_function_registry.end();
+ ++gandiva_native_function) {
+ auto native_function = ggandiva_native_function_new_raw(gandiva_native_function);
+ native_functions = g_list_prepend(native_functions, native_function);
+ }
+ native_functions = g_list_reverse(native_functions);
+
+ return native_functions;
+}
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/function-registry.h b/src/arrow/c_glib/gandiva-glib/function-registry.h
new file mode 100644
index 000000000..1a0d767d4
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/function-registry.h
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva-glib/native-function.h>
+
+G_BEGIN_DECLS
+
+#define GGANDIVA_TYPE_FUNCTION_REGISTRY (ggandiva_function_registry_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaFunctionRegistry,
+ ggandiva_function_registry,
+ GGANDIVA,
+ FUNCTION_REGISTRY,
+ GObject)
+
+struct _GGandivaFunctionRegistryClass
+{
+ GObjectClass parent_class;
+};
+
+GGandivaFunctionRegistry *ggandiva_function_registry_new(void);
+GGandivaNativeFunction *
+ggandiva_function_registry_lookup(GGandivaFunctionRegistry *function_registry,
+ GGandivaFunctionSignature *function_signature);
+GList *ggandiva_function_registry_get_native_functions(GGandivaFunctionRegistry *function_registry);
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/function-signature.cpp b/src/arrow/c_glib/gandiva-glib/function-signature.cpp
new file mode 100644
index 000000000..c344f3a92
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/function-signature.cpp
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <arrow-glib/basic-data-type.hpp>
+
+#include <gandiva-glib/function-signature.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: function-signature
+ * @short_description: FunctionSignature class
+ * @title: FunctionSignature class
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * Since: 0.14.0
+ */
+
+typedef struct GGandivaFunctionSignaturePrivate_ {
+ gandiva::FunctionSignature function_signature;
+} GGandivaFunctionSignaturePrivate;
+
+enum {
+ PROP_FUNCTION_SIGNATURE = 1
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaFunctionSignature,
+ ggandiva_function_signature,
+ G_TYPE_OBJECT)
+
+#define GGANDIVA_FUNCTION_SIGNATURE_GET_PRIVATE(obj) \
+ static_cast<GGandivaFunctionSignaturePrivate *>( \
+ ggandiva_function_signature_get_instance_private( \
+ GGANDIVA_FUNCTION_SIGNATURE(obj)))
+
+static void
+ggandiva_function_signature_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_FUNCTION_SIGNATURE_GET_PRIVATE(object);
+ switch (prop_id) {
+ case PROP_FUNCTION_SIGNATURE:
+ priv->function_signature =
+ *static_cast<const gandiva::FunctionSignature *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_function_signature_init(GGandivaFunctionSignature *object)
+{
+}
+
+static void
+ggandiva_function_signature_class_init(GGandivaFunctionSignatureClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->set_property = ggandiva_function_signature_set_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_pointer("function-signature",
+ "FunctionSignature",
+ "The raw gandiva::FunctionSignature *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_FUNCTION_SIGNATURE, spec);
+}
+
+/**
+ * ggandiva_function_signature_new:
+ * @base_name: A base name of a function.
+ * @parameter_types: (element-type GArrowDataType)
+ * A list of parameter data types.
+ * @return_type: A return data type.
+ *
+ * Returns:
+ * A #GGandivaFunctionSignature.
+ *
+ * Since: 0.14.0
+ */
+GGandivaFunctionSignature *
+ggandiva_function_signature_new(const gchar *base_name,
+ GList *parameter_types,
+ GArrowDataType *return_type)
+{
+ gandiva::DataTypeVector arrow_parameter_types;
+ for (auto node = parameter_types; node; node = g_list_next(node)) {
+ auto data_type = GARROW_DATA_TYPE(node->data);
+ auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ arrow_parameter_types.push_back(arrow_data_type);
+ }
+
+ auto arrow_return_type = garrow_data_type_get_raw(return_type);
+
+ gandiva::FunctionSignature gandiva_function_signature(base_name,
+ arrow_parameter_types,
+ arrow_return_type);
+ return ggandiva_function_signature_new_raw(&gandiva_function_signature);
+}
+
+/**
+ * ggandiva_function_signature_equal:
+ * @function_signature: A #GGandivaFunctionSignature.
+ * @other_function_signature: A #GGandivaFunctionSignature to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE otherwise.
+ *
+ * Since: 0.14.0
+ */
+gboolean
+ggandiva_function_signature_equal(GGandivaFunctionSignature *function_signature,
+ GGandivaFunctionSignature *other_function_signature)
+{
+ auto gandiva_function_signature =
+ ggandiva_function_signature_get_raw(function_signature);
+ auto gandiva_other_function_signature =
+ ggandiva_function_signature_get_raw(other_function_signature);
+
+ return (*gandiva_function_signature) == (*gandiva_other_function_signature);
+}
+
+/**
+ * ggandiva_function_signature_to_string:
+ * @function_signature: A #GGandivaFunctionSignature
+ *
+ * Returns: (transfer full): The string representation of the function signature.
+ *
+ * It should be freed with g_free() when no longer needed.
+ *
+ * Since: 0.14.0
+ */
+gchar *
+ggandiva_function_signature_to_string(GGandivaFunctionSignature *function_signature)
+{
+ auto gandiva_function_signature =
+ ggandiva_function_signature_get_raw(function_signature);
+ return g_strdup(gandiva_function_signature->ToString().c_str());
+}
+
+/**
+ * ggandiva_function_signature_get_return_type:
+ * @function_signature: A #GGandivaFunctionSignature
+ *
+ * Returns: (transfer full):
+ * A #GArrowDataType of the return value of the function signature.
+ *
+ * Since: 0.14.0
+ */
+GArrowDataType *
+ggandiva_function_signature_get_return_type(GGandivaFunctionSignature *function_signature)
+{
+ auto gandiva_function_signature =
+ ggandiva_function_signature_get_raw(function_signature);
+ auto arrow_data_type = gandiva_function_signature->ret_type();
+ auto data_type = garrow_data_type_new_raw(&arrow_data_type);
+ return data_type;
+}
+
+/**
+ * ggandiva_function_signature_get_base_name:
+ * @function_signature: A #GGandivaFunctionSignature
+ *
+ * Returns: (transfer full): A base name of the function signature.
+ *
+ * It should be freed with g_free() when no longer needed.
+ *
+ * Since: 0.14.0
+ */
+gchar *
+ggandiva_function_signature_get_base_name(GGandivaFunctionSignature *function_signature)
+{
+ auto gandiva_function_signature =
+ ggandiva_function_signature_get_raw(function_signature);
+ return g_strdup(gandiva_function_signature->base_name().c_str());
+}
+
+/**
+ * ggandiva_function_signature_get_param_types:
+ * @function_signature: A #GGandivaFunctionSignature
+ *
+ * Returns: (transfer full) (element-type GArrowDataType):
+ * A list of parameter data types of the function signature.
+ *
+ * Since: 0.14.0
+ */
+GList *
+ggandiva_function_signature_get_param_types(GGandivaFunctionSignature *function_signature)
+{
+ auto gandiva_function_signature =
+ ggandiva_function_signature_get_raw(function_signature);
+
+ GList *param_type_list = nullptr;
+ auto arrow_param_types = gandiva_function_signature->param_types();
+ for (auto &arrow_param_type : arrow_param_types) {
+ auto data_type = garrow_data_type_new_raw(&arrow_param_type);
+ param_type_list = g_list_prepend(param_type_list, data_type);
+ }
+ param_type_list = g_list_reverse(param_type_list);
+
+ return param_type_list;
+}
+
+G_END_DECLS
+
+GGandivaFunctionSignature *
+ggandiva_function_signature_new_raw(const gandiva::FunctionSignature *gandiva_function_signature)
+{
+ auto function_signature =
+ GGANDIVA_FUNCTION_SIGNATURE(g_object_new(GGANDIVA_TYPE_FUNCTION_SIGNATURE,
+ "function-signature",
+ gandiva_function_signature,
+ NULL));
+ return function_signature;
+}
+
+const gandiva::FunctionSignature *
+ggandiva_function_signature_get_raw(GGandivaFunctionSignature *function_signature)
+{
+ auto priv = GGANDIVA_FUNCTION_SIGNATURE_GET_PRIVATE(function_signature);
+ return &priv->function_signature;
+}
diff --git a/src/arrow/c_glib/gandiva-glib/function-signature.h b/src/arrow/c_glib/gandiva-glib/function-signature.h
new file mode 100644
index 000000000..b1099ff99
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/function-signature.h
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <arrow-glib/arrow-glib.h>
+
+G_BEGIN_DECLS
+
+#define GGANDIVA_TYPE_FUNCTION_SIGNATURE (ggandiva_function_signature_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaFunctionSignature,
+ ggandiva_function_signature,
+ GGANDIVA,
+ FUNCTION_SIGNATURE,
+ GObject)
+
+struct _GGandivaFunctionSignatureClass
+{
+ GObjectClass parent_class;
+};
+
+GGandivaFunctionSignature *ggandiva_function_signature_new(const gchar *base_name,
+ GList *parameter_types,
+ GArrowDataType *return_type);
+gboolean ggandiva_function_signature_equal(GGandivaFunctionSignature *function_signature,
+ GGandivaFunctionSignature *other_function_signature);
+gchar *ggandiva_function_signature_to_string(GGandivaFunctionSignature *function_signature);
+GArrowDataType *ggandiva_function_signature_get_return_type(GGandivaFunctionSignature *function_signature);
+gchar *ggandiva_function_signature_get_base_name(GGandivaFunctionSignature *function_signature);
+GList *ggandiva_function_signature_get_param_types(GGandivaFunctionSignature *function_signature);
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/function-signature.hpp b/src/arrow/c_glib/gandiva-glib/function-signature.hpp
new file mode 100644
index 000000000..24f71e6bc
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/function-signature.hpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva/function_signature.h>
+
+#include <gandiva-glib/function-signature.h>
+
+GGandivaFunctionSignature *ggandiva_function_signature_new_raw(const gandiva::FunctionSignature *gandiva_function_signature);
+const gandiva::FunctionSignature *ggandiva_function_signature_get_raw(GGandivaFunctionSignature *signature);
diff --git a/src/arrow/c_glib/gandiva-glib/gandiva-glib.h b/src/arrow/c_glib/gandiva-glib/gandiva-glib.h
new file mode 100644
index 000000000..9c1a1604d
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/gandiva-glib.h
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva-glib/version.h>
+
+#include <gandiva-glib/expression.h>
+#include <gandiva-glib/filter.h>
+#include <gandiva-glib/function-registry.h>
+#include <gandiva-glib/function-signature.h>
+#include <gandiva-glib/native-function.h>
+#include <gandiva-glib/node.h>
+#include <gandiva-glib/projector.h>
+#include <gandiva-glib/selection-vector.h>
diff --git a/src/arrow/c_glib/gandiva-glib/gandiva-glib.hpp b/src/arrow/c_glib/gandiva-glib/gandiva-glib.hpp
new file mode 100644
index 000000000..eb39f5838
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/gandiva-glib.hpp
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva-glib/gandiva-glib.h>
+
+#include <gandiva-glib/expression.hpp>
+#include <gandiva-glib/filter.hpp>
+#include <gandiva-glib/node.hpp>
+#include <gandiva-glib/projector.hpp>
+#include <gandiva-glib/selection-vector.hpp>
diff --git a/src/arrow/c_glib/gandiva-glib/meson.build b/src/arrow/c_glib/gandiva-glib/meson.build
new file mode 100644
index 000000000..5127d67af
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/meson.build
@@ -0,0 +1,120 @@
+# -*- indent-tabs-mode: nil -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+project_name = 'gandiva-glib'
+
+sources = files(
+ 'expression.cpp',
+ 'filter.cpp',
+ 'function-registry.cpp',
+ 'function-signature.cpp',
+ 'native-function.cpp',
+ 'node.cpp',
+ 'projector.cpp',
+ 'selection-vector.cpp',
+)
+
+c_headers = files(
+ 'expression.h',
+ 'filter.h',
+ 'function-registry.h',
+ 'function-signature.h',
+ 'gandiva-glib.h',
+ 'native-function.h',
+ 'node.h',
+ 'projector.h',
+ 'selection-vector.h',
+)
+
+cpp_headers = files(
+ 'expression.hpp',
+ 'filter.hpp',
+ 'function-signature.hpp',
+ 'gandiva-glib.hpp',
+ 'native-function.hpp',
+ 'node.hpp',
+ 'projector.hpp',
+ 'selection-vector.hpp',
+)
+
+version_h_conf = configuration_data()
+version_h_conf.set('GGANDIVA_VERSION_MAJOR', version_major)
+version_h_conf.set('GGANDIVA_VERSION_MINOR', version_minor)
+version_h_conf.set('GGANDIVA_VERSION_MICRO', version_micro)
+version_h_conf.set('GGANDIVA_VERSION_TAG', version_tag)
+version_h = configure_file(input: 'version.h.in',
+ output: 'version.h',
+ configuration: version_h_conf)
+c_headers += version_h
+
+enums = gnome.mkenums('enums',
+ sources: c_headers,
+ identifier_prefix: 'GGandiva',
+ symbol_prefix: 'ggandiva',
+ c_template: 'enums.c.template',
+ h_template: 'enums.h.template',
+ install_dir: join_paths(include_dir, meson.project_name()),
+ install_header: true)
+enums_source = enums[0]
+enums_header = enums[1]
+
+headers = c_headers + cpp_headers
+install_headers(headers, subdir: project_name)
+
+dependencies = [
+ gandiva,
+ arrow_glib,
+]
+libgandiva_glib = library('gandiva-glib',
+ sources: sources + enums,
+ install: true,
+ dependencies: dependencies,
+ include_directories: base_include_directories,
+ soversion: so_version,
+ version: library_version)
+gandiva_glib = declare_dependency(link_with: libgandiva_glib,
+ include_directories: base_include_directories,
+ dependencies: dependencies,
+ sources: enums_header)
+
+pkgconfig.generate(libgandiva_glib,
+ filebase: project_name,
+ name: 'Apache Arrow Gandiva GLib',
+ description: 'C API for Apache Arrow Gandiva based on GLib',
+ version: version,
+ requires: ['gandiva', 'arrow-glib'])
+
+if have_gi
+ gnome.generate_gir(libgandiva_glib,
+ dependencies: declare_dependency(sources: arrow_glib_gir),
+ sources: sources + c_headers + enums,
+ namespace: 'Gandiva',
+ nsversion: api_version,
+ identifier_prefix: 'GGandiva',
+ symbol_prefix: 'ggandiva',
+ export_packages: 'gandiva-glib',
+ includes: [
+ 'Arrow-1.0'
+ ],
+ install: true,
+ extra_args: [
+ '--warn-all',
+ '--include-uninstalled=./arrow-glib/Arrow-1.0.gir',
+ ])
+endif
diff --git a/src/arrow/c_glib/gandiva-glib/native-function.cpp b/src/arrow/c_glib/gandiva-glib/native-function.cpp
new file mode 100644
index 000000000..0755ad1d6
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/native-function.cpp
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <gandiva-glib/native-function.hpp>
+
+#include <gandiva-glib/function-signature.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: native-function
+ * @short_description: NativeFunction class
+ * @title: NativeFunction class
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * Since: 0.14.0
+ */
+
+typedef struct GGandivaNativeFunctionPrivate_ {
+ const gandiva::NativeFunction *native_function;
+} GGandivaNativeFunctionPrivate;
+
+enum {
+ PROP_NATIVE_FUNCTION = 1
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaNativeFunction,
+ ggandiva_native_function,
+ G_TYPE_OBJECT)
+
+#define GGANDIVA_NATIVE_FUNCTION_GET_PRIVATE(obj) \
+ static_cast<GGandivaNativeFunctionPrivate *>( \
+ ggandiva_native_function_get_instance_private( \
+ GGANDIVA_NATIVE_FUNCTION(obj)))
+
+static void
+ggandiva_native_function_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_NATIVE_FUNCTION_GET_PRIVATE(object);
+ switch (prop_id) {
+ case PROP_NATIVE_FUNCTION:
+ priv->native_function =
+ static_cast<const gandiva::NativeFunction *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_native_function_init(GGandivaNativeFunction *object)
+{
+}
+
+static void
+ggandiva_native_function_class_init(GGandivaNativeFunctionClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->set_property = ggandiva_native_function_set_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_pointer("native-function",
+ "NativeFunction",
+ "The raw gandiva::NativeFunction *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_NATIVE_FUNCTION, spec);
+}
+
+/**
+ * ggandiva_native_function_get_signatures:
+ * @native_function: A #GGandivaNativeFunction.
+ *
+ * Returns: (element-type GGandivaFunctionSignature) (transfer full):
+ * A list of #GGandivaFunctionSignature supported by the native function.
+ *
+ * Since: 0.15.0
+ */
+GList *
+ggandiva_native_function_get_signatures(GGandivaNativeFunction *native_function)
+{
+ auto gandiva_native_function =
+ ggandiva_native_function_get_raw(native_function);
+ GList *signatures = nullptr;
+ for (auto &gandiva_signature : gandiva_native_function->signatures()) {
+ auto signature = ggandiva_function_signature_new_raw(&gandiva_signature);
+ signatures = g_list_prepend(signatures, signature);
+ }
+ return g_list_reverse(signatures);
+}
+
+/**
+ * ggandiva_native_function_equal:
+ * @native_function: A #GGandivaNativeFunction.
+ * @other_native_function: A #GGandivaNativeFunction to be compared.
+ *
+ * Returns: %TRUE if both of them have the same data, %FALSE otherwise.
+ *
+ * Since: 0.14.0
+ */
+gboolean
+ggandiva_native_function_equal(GGandivaNativeFunction *native_function,
+ GGandivaNativeFunction *other_native_function)
+{
+ auto gandiva_native_function =
+ ggandiva_native_function_get_raw(native_function);
+ auto gandiva_other_native_function =
+ ggandiva_native_function_get_raw(other_native_function);
+ return gandiva_native_function == gandiva_other_native_function;
+}
+
+/**
+ * ggandiva_native_function_to_string:
+ * @native_function: A #GGandivaNativeFunction.
+ *
+ * Returns: (transfer full):
+ * The string representation of the signatures of the native function.
+ * It should be freed with g_free() when no longer needed.
+ *
+ * Since: 0.14.0
+ */
+gchar *
+ggandiva_native_function_to_string(GGandivaNativeFunction *native_function)
+{
+ auto gandiva_native_function =
+ ggandiva_native_function_get_raw(native_function);
+ auto string = g_string_new(NULL);
+ for (auto &gandiva_signature : gandiva_native_function->signatures()) {
+ if (string->len > 0) {
+ g_string_append(string, ", ");
+ }
+ const auto &signature_string = gandiva_signature.ToString();
+ g_string_append_len(string,
+ signature_string.data(),
+ signature_string.length());
+ }
+ return g_string_free(string, FALSE);
+}
+
+/**
+ * ggandiva_native_function_get_result_nullable_type:
+ * @native_function: A #GGandivaNativeFunction.
+ *
+ * Returns:
+ * A value of #GGandivaResultNullableType.
+ *
+ * Since: 0.14.0
+ */
+GGandivaResultNullableType
+ggandiva_native_function_get_result_nullable_type(GGandivaNativeFunction *native_function)
+{
+ auto gandiva_native_function =
+ ggandiva_native_function_get_raw(native_function);
+ const auto gandiva_result_nullable_type =
+ gandiva_native_function->result_nullable_type();
+ return ggandiva_result_nullable_type_from_raw(gandiva_result_nullable_type);
+}
+
+/**
+ * ggandiva_native_function_need_context:
+ * @native_function: A #GGandivaNativeFunction.
+ *
+ * Returns:
+ * %TRUE if the native function needs a context for evaluation,
+ * %FALSE otherwise.
+ *
+ * Since: 0.14.0
+ */
+gboolean
+ggandiva_native_function_need_context(GGandivaNativeFunction *native_function)
+{
+ auto gandiva_native_function =
+ ggandiva_native_function_get_raw(native_function);
+ return gandiva_native_function->NeedsContext();
+}
+
+/**
+ * ggandiva_native_function_need_function_holder:
+ * @native_function: A #GGandivaNativeFunction.
+ *
+ * Returns:
+ * %TRUE if the native function needs a function holder for evaluation,
+ * %FALSE otherwise.
+ *
+ * Since: 0.14.0
+ */
+gboolean
+ggandiva_native_function_need_function_holder(GGandivaNativeFunction *native_function)
+{
+ auto gandiva_native_function =
+ ggandiva_native_function_get_raw(native_function);
+ return gandiva_native_function->NeedsFunctionHolder();
+}
+
+/**
+ * ggandiva_native_function_can_return_errors:
+ * @native_function: A #GGandivaNativeFunction.
+ *
+ * Returns:
+ * %TRUE if the native function has the possibility of returning errors,
+ * %FALSE otherwise.
+ *
+ * Since: 0.14.0
+ */
+gboolean
+ggandiva_native_function_can_return_errors(GGandivaNativeFunction *native_function)
+{
+ auto gandiva_native_function =
+ ggandiva_native_function_get_raw(native_function);
+ return gandiva_native_function->CanReturnErrors();
+}
+
+G_END_DECLS
+
+GGandivaResultNullableType
+ggandiva_result_nullable_type_from_raw(gandiva::ResultNullableType gandiva_type)
+{
+ switch (gandiva_type) {
+ case gandiva::kResultNullIfNull:
+ return GGANDIVA_RESULT_NULL_IF_NULL;
+ case gandiva::kResultNullNever:
+ return GGANDIVA_RESULT_NULL_NEVER;
+ case gandiva::kResultNullInternal:
+ return GGANDIVA_RESULT_NULL_INTERNAL;
+ default:
+ return GGANDIVA_RESULT_NULL_IF_NULL;
+ }
+}
+
+gandiva::ResultNullableType
+ggandiva_result_nullable_type_to_raw(GGandivaResultNullableType type)
+{
+ switch (type) {
+ case GGANDIVA_RESULT_NULL_IF_NULL:
+ return gandiva::kResultNullIfNull;
+ case GGANDIVA_RESULT_NULL_NEVER:
+ return gandiva::kResultNullNever;
+ case GGANDIVA_RESULT_NULL_INTERNAL:
+ return gandiva::kResultNullInternal;
+ default:
+ return gandiva::kResultNullIfNull;
+ }
+}
+
+GGandivaNativeFunction *
+ggandiva_native_function_new_raw(const gandiva::NativeFunction *gandiva_native_function)
+{
+ auto native_function =
+ GGANDIVA_NATIVE_FUNCTION(g_object_new(GGANDIVA_TYPE_NATIVE_FUNCTION,
+ "native-function",
+ gandiva_native_function,
+ NULL));
+ return native_function;
+}
+
+const gandiva::NativeFunction *
+ggandiva_native_function_get_raw(GGandivaNativeFunction *native_function)
+{
+ auto priv = GGANDIVA_NATIVE_FUNCTION_GET_PRIVATE(native_function);
+ return priv->native_function;
+}
diff --git a/src/arrow/c_glib/gandiva-glib/native-function.h b/src/arrow/c_glib/gandiva-glib/native-function.h
new file mode 100644
index 000000000..8b4d6a44c
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/native-function.h
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva-glib/function-signature.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GGandivaResultNullableType:
+ * @GGANDIVA_RESULT_NULL_IF_NULL: This means the result validity is an intersection of
+ * the validity of the children.
+ * @GGANDIVA_RESULT_NULL_NEVER: This means that the result is always valid.
+ * @GGANDIVA_RESULT_NULL_INTERNAL: This means that the result validity depends on some
+ * internal logic.
+ *
+ * They are corresponding to `gandiva::ResultNullableType` values.
+ */
+typedef enum {
+ GGANDIVA_RESULT_NULL_IF_NULL,
+ GGANDIVA_RESULT_NULL_NEVER,
+ GGANDIVA_RESULT_NULL_INTERNAL
+} GGandivaResultNullableType;
+
+#define GGANDIVA_TYPE_NATIVE_FUNCTION (ggandiva_native_function_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaNativeFunction,
+ ggandiva_native_function,
+ GGANDIVA,
+ NATIVE_FUNCTION,
+ GObject)
+
+struct _GGandivaNativeFunctionClass
+{
+ GObjectClass parent_class;
+};
+
+GList *
+ggandiva_native_function_get_signatures(GGandivaNativeFunction *native_function);
+gboolean
+ggandiva_native_function_equal(GGandivaNativeFunction *native_function,
+ GGandivaNativeFunction *other_native_function);
+gchar *ggandiva_native_function_to_string(GGandivaNativeFunction *native_function);
+GGandivaResultNullableType ggandiva_native_function_get_result_nullable_type(GGandivaNativeFunction *native_function);
+gboolean ggandiva_native_function_need_context(GGandivaNativeFunction *native_function);
+gboolean ggandiva_native_function_need_function_holder(GGandivaNativeFunction *native_function);
+gboolean ggandiva_native_function_can_return_errors(GGandivaNativeFunction *native_function);
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/native-function.hpp b/src/arrow/c_glib/gandiva-glib/native-function.hpp
new file mode 100644
index 000000000..76119ca40
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/native-function.hpp
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva/native_function.h>
+
+#include <gandiva-glib/native-function.h>
+
+G_BEGIN_DECLS
+
+GGandivaResultNullableType
+ggandiva_result_nullable_type_from_raw(gandiva::ResultNullableType gandiva_type);
+gandiva::ResultNullableType
+ggandiva_result_nullable_type_to_raw(GGandivaResultNullableType type);
+
+GGandivaNativeFunction *ggandiva_native_function_new_raw(const gandiva::NativeFunction *gandiva_native_function);
+const gandiva::NativeFunction *ggandiva_native_function_get_raw(GGandivaNativeFunction *native_function);
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/node.cpp b/src/arrow/c_glib/gandiva-glib/node.cpp
new file mode 100644
index 000000000..d42d4801b
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/node.cpp
@@ -0,0 +1,1688 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <arrow-glib/data-type.hpp>
+#include <arrow-glib/error.hpp>
+#include <arrow-glib/field.hpp>
+
+#include <gandiva-glib/node.hpp>
+
+template <typename Type>
+const Type &
+ggandiva_literal_node_get(GGandivaLiteralNode *node)
+{
+ auto gandiva_literal_node =
+ std::static_pointer_cast<gandiva::LiteralNode>(ggandiva_node_get_raw(GGANDIVA_NODE(node)));
+ return arrow::util::get<Type>(gandiva_literal_node->holder());
+}
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: node
+ * @section_id: node-classes
+ * @title: Node classes
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * #GGandivaNode is a base class for a node in the expression tree.
+ *
+ * #GGandivaFieldNode is a class for a node in the expression tree, representing an Arrow field.
+ *
+ * #GGandivaFunctionNode is a class for a node in the expression tree, representing a function.
+ *
+ * #GGandivaLiteralNode is a base class for a node in the expression tree,
+ * representing a literal.
+ *
+ * #GGandivaNullLiteralNode is a class for a node in the expression tree,
+ * representing a null literal.
+ *
+ * #GGandivaBooleanLiteralNode is a class for a node in the expression tree,
+ * representing a boolean literal.
+ *
+ * #GGandivaInt8LiteralNode is a class for a node in the expression tree,
+ * representing a 8-bit integer literal.
+ *
+ * #GGandivaUInt8LiteralNode is a class for a node in the expression tree,
+ * representing a 8-bit unsigned integer literal.
+ *
+ * #GGandivaInt16LiteralNode is a class for a node in the expression tree,
+ * representing a 16-bit integer literal.
+ *
+ * #GGandivaUInt16LiteralNode is a class for a node in the expression tree,
+ * representing a 16-bit unsigned integer literal.
+ *
+ * #GGandivaInt32LiteralNode is a class for a node in the expression tree,
+ * representing a 32-bit integer literal.
+ *
+ * #GGandivaUInt32LiteralNode is a class for a node in the expression tree,
+ * representing a 32-bit unsigned integer literal.
+ *
+ * #GGandivaInt64LiteralNode is a class for a node in the expression tree,
+ * representing a 64-bit integer literal.
+ *
+ * #GGandivaUInt64LiteralNode is a class for a node in the expression tree,
+ * representing a 64-bit unsigned integer literal.
+ *
+ * #GGandivaFloatLiteralNode is a class for a node in the expression tree,
+ * representing a 32-bit floating point literal.
+ *
+ * #GGandivaDoubleLiteralNode is a class for a node in the expression tree,
+ * representing a 64-bit floating point literal.
+ *
+ * #GGandivaBinaryLiteralNode is a class for a node in the expression tree,
+ * representing a binary literal.
+ *
+ * #GGandivaStringLiteralNode is a class for a node in the expression tree,
+ * representing an UTF-8 encoded string literal.
+ *
+ * #GGandivaIfNode is a class for a node in the expression tree, representing an if-else.
+ *
+ * #GGandivaBooleanNode is a class for a node in the expression tree, representing a boolean.
+ *
+ * #GGandivaAndNode is a class for a node in the expression tree, representing an AND.
+ *
+ * #GGandivaOrNode is a class for a node in the expression tree, representing an OR.
+ *
+ * Since: 0.12.0
+ */
+
+typedef struct GGandivaNodePrivate_ {
+ std::shared_ptr<gandiva::Node> node;
+ GArrowDataType *return_type;
+} GGandivaNodePrivate;
+
+enum {
+ PROP_NODE = 1,
+ PROP_RETURN_TYPE
+};
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(GGandivaNode,
+ ggandiva_node,
+ G_TYPE_OBJECT)
+
+#define GGANDIVA_NODE_GET_PRIVATE(object) \
+ static_cast<GGandivaNodePrivate *>( \
+ ggandiva_node_get_instance_private( \
+ GGANDIVA_NODE(object)))
+
+static void
+ggandiva_node_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_NODE_GET_PRIVATE(object);
+
+ if (priv->return_type) {
+ g_object_unref(priv->return_type);
+ priv->return_type = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_node_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_node_finalize(GObject *object)
+{
+ auto priv = GGANDIVA_NODE_GET_PRIVATE(object);
+
+ priv->node.~shared_ptr();
+
+ G_OBJECT_CLASS(ggandiva_node_parent_class)->finalize(object);
+}
+
+static void
+ggandiva_node_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_NODE:
+ priv->node =
+ *static_cast<std::shared_ptr<gandiva::Node> *>(g_value_get_pointer(value));
+ break;
+ case PROP_RETURN_TYPE:
+ priv->return_type = GARROW_DATA_TYPE(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_node_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_RETURN_TYPE:
+ g_value_set_object(value, priv->return_type);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_node_init(GGandivaNode *object)
+{
+ auto priv = GGANDIVA_NODE_GET_PRIVATE(object);
+ new(&priv->node) std::shared_ptr<gandiva::Node>;
+}
+
+static void
+ggandiva_node_class_init(GGandivaNodeClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_node_dispose;
+ gobject_class->finalize = ggandiva_node_finalize;
+ gobject_class->set_property = ggandiva_node_set_property;
+ gobject_class->get_property = ggandiva_node_get_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_pointer("node",
+ "Node",
+ "The raw std::shared<gandiva::Node> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_NODE, spec);
+
+ spec = g_param_spec_object("return-type",
+ "Return type",
+ "The return type",
+ GARROW_TYPE_DATA_TYPE,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_RETURN_TYPE, spec);
+}
+
+/**
+ * ggandiva_node_to_string:
+ * @node: A #GGandivaNode.
+ *
+ * Returns: (transfer full): The string representation of the node.
+ *
+ * It should be freed with g_free() when no longer needed.
+ *
+ * Since: 1.0.0
+ */
+gchar *
+ggandiva_node_to_string(GGandivaNode *node)
+{
+ auto gandiva_node = ggandiva_node_get_raw(node);
+ auto string = gandiva_node->ToString();
+ return g_strndup(string.data(), string.size());
+}
+
+typedef struct GGandivaFieldNodePrivate_ {
+ GArrowField *field;
+} GGandivaFieldNodePrivate;
+
+enum {
+ PROP_FIELD = 1
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaFieldNode,
+ ggandiva_field_node,
+ GGANDIVA_TYPE_NODE)
+
+#define GGANDIVA_FIELD_NODE_GET_PRIVATE(object) \
+ static_cast<GGandivaFieldNodePrivate *>( \
+ ggandiva_field_node_get_instance_private( \
+ GGANDIVA_FIELD_NODE(object)))
+
+static void
+ggandiva_field_node_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_FIELD_NODE_GET_PRIVATE(object);
+
+ if (priv->field) {
+ g_object_unref(priv->field);
+ priv->field = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_field_node_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_field_node_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_FIELD_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_FIELD:
+ priv->field = GARROW_FIELD(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_field_node_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_FIELD_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_FIELD:
+ g_value_set_object(value, priv->field);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_field_node_init(GGandivaFieldNode *field_node)
+{
+}
+
+static void
+ggandiva_field_node_class_init(GGandivaFieldNodeClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_field_node_dispose;
+ gobject_class->set_property = ggandiva_field_node_set_property;
+ gobject_class->get_property = ggandiva_field_node_get_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_object("field",
+ "Field",
+ "The field",
+ GARROW_TYPE_FIELD,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_FIELD, spec);
+}
+
+/**
+ * ggandiva_field_node_new:
+ * @field: A #GArrowField.
+ *
+ * Returns: A newly created #GGandivaFieldNode for the given field.
+ *
+ * Since: 0.12.0
+ */
+GGandivaFieldNode *
+ggandiva_field_node_new(GArrowField *field)
+{
+ auto arrow_field = garrow_field_get_raw(field);
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeField(arrow_field);
+ return ggandiva_field_node_new_raw(&gandiva_node, field);
+}
+
+
+typedef struct GGandivaFunctionNodePrivate_ {
+ gchar *name;
+ GList *parameters;
+} GGandivaFunctionNodePrivate;
+
+enum {
+ PROP_NAME = 1
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaFunctionNode,
+ ggandiva_function_node,
+ GGANDIVA_TYPE_NODE)
+
+#define GGANDIVA_FUNCTION_NODE_GET_PRIVATE(object) \
+ static_cast<GGandivaFunctionNodePrivate *>( \
+ ggandiva_function_node_get_instance_private( \
+ GGANDIVA_FUNCTION_NODE(object))) \
+
+static void
+ggandiva_function_node_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_FUNCTION_NODE_GET_PRIVATE(object);
+
+ if (priv->parameters) {
+ for (auto node = priv->parameters; node; node = g_list_next(node)) {
+ auto parameter = GGANDIVA_NODE(node->data);
+ g_object_unref(parameter);
+ }
+ g_list_free(priv->parameters);
+ priv->parameters = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_function_node_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_function_node_finalize(GObject *object)
+{
+ auto priv = GGANDIVA_FUNCTION_NODE_GET_PRIVATE(object);
+
+ g_free(priv->name);
+
+ G_OBJECT_CLASS(ggandiva_function_node_parent_class)->finalize(object);
+}
+
+static void
+ggandiva_function_node_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_FUNCTION_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ priv->name = g_value_dup_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_function_node_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_FUNCTION_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_NAME:
+ g_value_set_string(value, priv->name);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_function_node_init(GGandivaFunctionNode *function_node)
+{
+ auto priv = GGANDIVA_FUNCTION_NODE_GET_PRIVATE(function_node);
+ priv->parameters = nullptr;
+}
+
+static void
+ggandiva_function_node_class_init(GGandivaFunctionNodeClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_function_node_dispose;
+ gobject_class->finalize = ggandiva_function_node_finalize;
+ gobject_class->set_property = ggandiva_function_node_set_property;
+ gobject_class->get_property = ggandiva_function_node_get_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_string("name",
+ "Name",
+ "The name of the function",
+ nullptr,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_NAME, spec);
+}
+
+/**
+ * ggandiva_function_node_new:
+ * @name: The name of the function to be called.
+ * @parameters: (element-type GGandivaNode): The parameters of the function call.
+ * @return_type: The return type of the function call.
+ *
+ * Returns: A newly created #GGandivaFunctionNode for the function call.
+ *
+ * Since: 0.12.0
+ */
+GGandivaFunctionNode *
+ggandiva_function_node_new(const gchar *name,
+ GList *parameters,
+ GArrowDataType *return_type)
+{
+ std::vector<std::shared_ptr<gandiva::Node>> gandiva_nodes;
+ for (auto node = parameters; node; node = g_list_next(node)) {
+ auto gandiva_node = ggandiva_node_get_raw(GGANDIVA_NODE(node->data));
+ gandiva_nodes.push_back(gandiva_node);
+ }
+ auto arrow_return_type = garrow_data_type_get_raw(return_type);
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeFunction(name,
+ gandiva_nodes,
+ arrow_return_type);
+ return ggandiva_function_node_new_raw(&gandiva_node,
+ name,
+ parameters,
+ return_type);
+}
+
+/**
+ * ggandiva_function_node_get_parameters:
+ * @node: A #GGandivaFunctionNode.
+ *
+ * Returns: (transfer none) (element-type GGandivaNode):
+ * The parameters of the function node.
+ *
+ * Since: 0.12.0
+ */
+GList *
+ggandiva_function_node_get_parameters(GGandivaFunctionNode *node)
+{
+ auto priv = GGANDIVA_FUNCTION_NODE_GET_PRIVATE(node);
+ return priv->parameters;
+}
+
+
+G_DEFINE_TYPE(GGandivaLiteralNode,
+ ggandiva_literal_node,
+ GGANDIVA_TYPE_NODE)
+
+static void
+ggandiva_literal_node_init(GGandivaLiteralNode *literal_node)
+{
+}
+
+static void
+ggandiva_literal_node_class_init(GGandivaLiteralNodeClass *klass)
+{
+}
+
+
+G_DEFINE_TYPE(GGandivaNullLiteralNode,
+ ggandiva_null_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_null_literal_node_init(GGandivaNullLiteralNode *null_literal_node)
+{
+}
+
+static void
+ggandiva_null_literal_node_class_init(GGandivaNullLiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_null_literal_node_new:
+ * @return_type: A #GArrowDataType.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GGandivaNullLiteralNode for
+ * the type or %NULL on error.
+ *
+ * Since: 0.12.0
+ */
+GGandivaNullLiteralNode *
+ggandiva_null_literal_node_new(GArrowDataType *return_type,
+ GError **error)
+{
+ auto arrow_return_type = garrow_data_type_get_raw(return_type);
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeNull(arrow_return_type);
+ if (!gandiva_node) {
+ g_set_error(error,
+ GARROW_ERROR,
+ GARROW_ERROR_INVALID,
+ "[gandiva][null-literal-node][new] "
+ "failed to create: <%s>",
+ arrow_return_type->ToString().c_str());
+ return NULL;
+ }
+ return GGANDIVA_NULL_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ return_type));
+}
+
+
+G_DEFINE_TYPE(GGandivaBooleanLiteralNode,
+ ggandiva_boolean_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_boolean_literal_node_init(GGandivaBooleanLiteralNode *boolean_literal_node)
+{
+}
+
+static void
+ggandiva_boolean_literal_node_class_init(GGandivaBooleanLiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_boolean_literal_node_new:
+ * @value: The value of the boolean literal.
+ *
+ * Returns: A newly created #GGandivaBooleanLiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaBooleanLiteralNode *
+ggandiva_boolean_literal_node_new(gboolean value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(static_cast<bool>(value));
+ return GGANDIVA_BOOLEAN_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_boolean_literal_node_get_value:
+ * @node: A #GGandivaBooleanLiteralNode.
+ *
+ * Returns: The value of the boolean literal.
+ *
+ * Since: 0.12.0
+ */
+gboolean
+ggandiva_boolean_literal_node_get_value(GGandivaBooleanLiteralNode *node)
+{
+ auto value = ggandiva_literal_node_get<bool>(GGANDIVA_LITERAL_NODE(node));
+ return static_cast<gboolean>(value);
+}
+
+
+G_DEFINE_TYPE(GGandivaInt8LiteralNode,
+ ggandiva_int8_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_int8_literal_node_init(GGandivaInt8LiteralNode *int8_literal_node)
+{
+}
+
+static void
+ggandiva_int8_literal_node_class_init(GGandivaInt8LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_int8_literal_node_new:
+ * @value: The value of the 8-bit integer literal.
+ *
+ * Returns: A newly created #GGandivaInt8LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaInt8LiteralNode *
+ggandiva_int8_literal_node_new(gint8 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_INT8_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_int8_literal_node_get_value:
+ * @node: A #GGandivaInt8LiteralNode.
+ *
+ * Returns: The value of the 8-bit integer literal.
+ *
+ * Since: 0.12.0
+ */
+gint8
+ggandiva_int8_literal_node_get_value(GGandivaInt8LiteralNode *node)
+{
+ return ggandiva_literal_node_get<int8_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaUInt8LiteralNode,
+ ggandiva_uint8_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_uint8_literal_node_init(GGandivaUInt8LiteralNode *uint8_literal_node)
+{
+}
+
+static void
+ggandiva_uint8_literal_node_class_init(GGandivaUInt8LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_uint8_literal_node_new:
+ * @value: The value of the 8-bit unsigned integer literal.
+ *
+ * Returns: A newly created #GGandivaUInt8LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaUInt8LiteralNode *
+ggandiva_uint8_literal_node_new(guint8 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_UINT8_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_uint8_literal_node_get_value:
+ * @node: A #GGandivaUInt8LiteralNode.
+ *
+ * Returns: The value of the 8-bit unsigned integer literal.
+ *
+ * Since: 0.12.0
+ */
+guint8
+ggandiva_uint8_literal_node_get_value(GGandivaUInt8LiteralNode *node)
+{
+ return ggandiva_literal_node_get<uint8_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaInt16LiteralNode,
+ ggandiva_int16_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_int16_literal_node_init(GGandivaInt16LiteralNode *int16_literal_node)
+{
+}
+
+static void
+ggandiva_int16_literal_node_class_init(GGandivaInt16LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_int16_literal_node_new:
+ * @value: The value of the 16-bit integer literal.
+ *
+ * Returns: A newly created #GGandivaInt16LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaInt16LiteralNode *
+ggandiva_int16_literal_node_new(gint16 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_INT16_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_int16_literal_node_get_value:
+ * @node: A #GGandivaInt16LiteralNode.
+ *
+ * Returns: The value of the 16-bit integer literal.
+ *
+ * Since: 0.12.0
+ */
+gint16
+ggandiva_int16_literal_node_get_value(GGandivaInt16LiteralNode *node)
+{
+ return ggandiva_literal_node_get<int16_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaUInt16LiteralNode,
+ ggandiva_uint16_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_uint16_literal_node_init(GGandivaUInt16LiteralNode *uint16_literal_node)
+{
+}
+
+static void
+ggandiva_uint16_literal_node_class_init(GGandivaUInt16LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_uint16_literal_node_new:
+ * @value: The value of the 16-bit unsigned integer literal.
+ *
+ * Returns: A newly created #GGandivaUInt16LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaUInt16LiteralNode *
+ggandiva_uint16_literal_node_new(guint16 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_UINT16_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_uint16_literal_node_get_value:
+ * @node: A #GGandivaUInt16LiteralNode.
+ *
+ * Returns: The value of the 16-bit unsigned integer literal.
+ *
+ * Since: 0.12.0
+ */
+guint16
+ggandiva_uint16_literal_node_get_value(GGandivaUInt16LiteralNode *node)
+{
+ return ggandiva_literal_node_get<uint16_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaInt32LiteralNode,
+ ggandiva_int32_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_int32_literal_node_init(GGandivaInt32LiteralNode *int32_literal_node)
+{
+}
+
+static void
+ggandiva_int32_literal_node_class_init(GGandivaInt32LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_int32_literal_node_new:
+ * @value: The value of the 32-bit integer literal.
+ *
+ * Returns: A newly created #GGandivaInt32LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaInt32LiteralNode *
+ggandiva_int32_literal_node_new(gint32 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_INT32_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_int32_literal_node_get_value:
+ * @node: A #GGandivaInt32LiteralNode.
+ *
+ * Returns: The value of the 32-bit integer literal.
+ *
+ * Since: 0.12.0
+ */
+gint32
+ggandiva_int32_literal_node_get_value(GGandivaInt32LiteralNode *node)
+{
+ return ggandiva_literal_node_get<int32_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaUInt32LiteralNode,
+ ggandiva_uint32_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_uint32_literal_node_init(GGandivaUInt32LiteralNode *uint32_literal_node)
+{
+}
+
+static void
+ggandiva_uint32_literal_node_class_init(GGandivaUInt32LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_uint32_literal_node_new:
+ * @value: The value of the 32-bit unsigned integer literal.
+ *
+ * Returns: A newly created #GGandivaUInt32LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaUInt32LiteralNode *
+ggandiva_uint32_literal_node_new(guint32 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_UINT32_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_uint32_literal_node_get_value:
+ * @node: A #GGandivaUInt32LiteralNode.
+ *
+ * Returns: The value of the 32-bit unsigned integer literal.
+ *
+ * Since: 0.12.0
+ */
+guint32
+ggandiva_uint32_literal_node_get_value(GGandivaUInt32LiteralNode *node)
+{
+ return ggandiva_literal_node_get<uint32_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaInt64LiteralNode,
+ ggandiva_int64_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_int64_literal_node_init(GGandivaInt64LiteralNode *int64_literal_node)
+{
+}
+
+static void
+ggandiva_int64_literal_node_class_init(GGandivaInt64LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_int64_literal_node_new:
+ * @value: The value of the 64-bit integer literal.
+ *
+ * Returns: A newly created #GGandivaInt64LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaInt64LiteralNode *
+ggandiva_int64_literal_node_new(gint64 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_INT64_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_int64_literal_node_get_value:
+ * @node: A #GGandivaInt64LiteralNode.
+ *
+ * Returns: The value of the 64-bit integer literal.
+ *
+ * Since: 0.12.0
+ */
+gint64
+ggandiva_int64_literal_node_get_value(GGandivaInt64LiteralNode *node)
+{
+ return ggandiva_literal_node_get<int64_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaUInt64LiteralNode,
+ ggandiva_uint64_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_uint64_literal_node_init(GGandivaUInt64LiteralNode *uint64_literal_node)
+{
+}
+
+static void
+ggandiva_uint64_literal_node_class_init(GGandivaUInt64LiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_uint64_literal_node_new:
+ * @value: The value of the 64-bit unsigned integer literal.
+ *
+ * Returns: A newly created #GGandivaUInt64LiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaUInt64LiteralNode *
+ggandiva_uint64_literal_node_new(guint64 value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_UINT64_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_uint64_literal_node_get_value:
+ * @node: A #GGandivaUInt64LiteralNode.
+ *
+ * Returns: The value of the 64-bit unsigned integer literal.
+ *
+ * Since: 0.12.0
+ */
+guint64
+ggandiva_uint64_literal_node_get_value(GGandivaUInt64LiteralNode *node)
+{
+ return ggandiva_literal_node_get<uint64_t>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaFloatLiteralNode,
+ ggandiva_float_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_float_literal_node_init(GGandivaFloatLiteralNode *float_literal_node)
+{
+}
+
+static void
+ggandiva_float_literal_node_class_init(GGandivaFloatLiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_float_literal_node_new:
+ * @value: The value of the 32-bit floating point literal.
+ *
+ * Returns: A newly created #GGandivaFloatLiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaFloatLiteralNode *
+ggandiva_float_literal_node_new(gfloat value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_FLOAT_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_float_literal_node_get_value:
+ * @node: A #GGandivaFloatLiteralNode.
+ *
+ * Returns: The value of the 32-bit floating point literal.
+ *
+ * Since: 0.12.0
+ */
+gfloat
+ggandiva_float_literal_node_get_value(GGandivaFloatLiteralNode *node)
+{
+ return ggandiva_literal_node_get<float>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+G_DEFINE_TYPE(GGandivaDoubleLiteralNode,
+ ggandiva_double_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_double_literal_node_init(GGandivaDoubleLiteralNode *double_literal_node)
+{
+}
+
+static void
+ggandiva_double_literal_node_class_init(GGandivaDoubleLiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_double_literal_node_new:
+ * @value: The value of the 64-bit floating point literal.
+ *
+ * Returns: A newly created #GGandivaDoubleLiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaDoubleLiteralNode *
+ggandiva_double_literal_node_new(gdouble value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeLiteral(value);
+ return GGANDIVA_DOUBLE_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_double_literal_node_get_value:
+ * @node: A #GGandivaDoubleLiteralNode.
+ *
+ * Returns: The value of the 64-bit floating point literal.
+ *
+ * Since: 0.12.0
+ */
+gdouble
+ggandiva_double_literal_node_get_value(GGandivaDoubleLiteralNode *node)
+{
+ return ggandiva_literal_node_get<double>(GGANDIVA_LITERAL_NODE(node));
+}
+
+
+typedef struct GGandivaBinaryLiteralNodePrivate_ {
+ GBytes *value;
+} GGandivaBinaryLiteralNodePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaBinaryLiteralNode,
+ ggandiva_binary_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+#define GGANDIVA_BINARY_LITERAL_NODE_GET_PRIVATE(object) \
+ static_cast<GGandivaBinaryLiteralNodePrivate *>( \
+ ggandiva_binary_literal_node_get_instance_private( \
+ GGANDIVA_BINARY_LITERAL_NODE(object)))
+
+static void
+ggandiva_binary_literal_node_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_BINARY_LITERAL_NODE_GET_PRIVATE(object);
+
+ if (priv->value) {
+ g_bytes_unref(priv->value);
+ priv->value = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_binary_literal_node_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_binary_literal_node_init(GGandivaBinaryLiteralNode *binary_literal_node)
+{
+}
+
+static void
+ggandiva_binary_literal_node_class_init(GGandivaBinaryLiteralNodeClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_binary_literal_node_dispose;
+}
+
+/**
+ * ggandiva_binary_literal_node_new:
+ * @value: (array length=size): The value of the binary literal.
+ * @size: The number of bytes of the value.
+ *
+ * Returns: A newly created #GGandivaBinaryLiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaBinaryLiteralNode *
+ggandiva_binary_literal_node_new(const guint8 *value,
+ gsize size)
+{
+ auto gandiva_node =
+ gandiva::TreeExprBuilder::MakeBinaryLiteral(std::string(reinterpret_cast<const char *>(value),
+ size));
+ return GGANDIVA_BINARY_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_binary_literal_node_new_bytes:
+ * @value: The value of the binary literal.
+ *
+ * Returns: A newly created #GGandivaBinaryLiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaBinaryLiteralNode *
+ggandiva_binary_literal_node_new_bytes(GBytes *value)
+{
+ size_t value_size;
+ auto raw_value = g_bytes_get_data(value, &value_size);
+ auto gandiva_node =
+ gandiva::TreeExprBuilder::MakeBinaryLiteral(
+ std::string(reinterpret_cast<const char *>(raw_value),
+ value_size));
+ auto literal_node = ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL);
+ auto priv = GGANDIVA_BINARY_LITERAL_NODE_GET_PRIVATE(literal_node);
+ priv->value = value;
+ g_bytes_ref(priv->value);
+ return GGANDIVA_BINARY_LITERAL_NODE(literal_node);
+}
+
+/**
+ * ggandiva_binary_literal_node_get_value:
+ * @node: A #GGandivaBinaryLiteralNode.
+ *
+ * Returns: (transfer none): The value of the binary literal.
+ *
+ * Since: 0.12.0
+ */
+GBytes *
+ggandiva_binary_literal_node_get_value(GGandivaBinaryLiteralNode *node)
+{
+ auto priv = GGANDIVA_BINARY_LITERAL_NODE_GET_PRIVATE(node);
+ if (!priv->value) {
+ auto value = ggandiva_literal_node_get<std::string>(GGANDIVA_LITERAL_NODE(node));
+ priv->value = g_bytes_new(value.data(), value.size());
+ }
+
+ return priv->value;
+}
+
+
+G_DEFINE_TYPE(GGandivaStringLiteralNode,
+ ggandiva_string_literal_node,
+ GGANDIVA_TYPE_LITERAL_NODE)
+
+static void
+ggandiva_string_literal_node_init(GGandivaStringLiteralNode *string_literal_node)
+{
+}
+
+static void
+ggandiva_string_literal_node_class_init(GGandivaStringLiteralNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_string_literal_node_new:
+ * @value: The value of the UTF-8 encoded string literal.
+ *
+ * Returns: A newly created #GGandivaStringLiteralNode.
+ *
+ * Since: 0.12.0
+ */
+GGandivaStringLiteralNode *
+ggandiva_string_literal_node_new(const gchar *value)
+{
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeStringLiteral(value);
+ return GGANDIVA_STRING_LITERAL_NODE(ggandiva_literal_node_new_raw(&gandiva_node,
+ NULL));
+}
+
+/**
+ * ggandiva_string_literal_node_get_value:
+ * @node: A #GGandivaStringLiteralNode.
+ *
+ * Returns: The value of the UTF-8 encoded string literal.
+ *
+ * Since: 0.12.0
+ */
+const gchar *
+ggandiva_string_literal_node_get_value(GGandivaStringLiteralNode *node)
+{
+ auto &value = ggandiva_literal_node_get<std::string>(GGANDIVA_LITERAL_NODE(node));
+ return value.c_str();
+}
+
+
+typedef struct GGandivaIfNodePrivate_ {
+ GGandivaNode *condition_node;
+ GGandivaNode *then_node;
+ GGandivaNode *else_node;
+} GGandivaIfNodePrivate;
+
+enum {
+ PROP_CONDITION_NODE = 1,
+ PROP_THEN_NODE,
+ PROP_ELSE_NODE,
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaIfNode,
+ ggandiva_if_node,
+ GGANDIVA_TYPE_NODE)
+
+#define GGANDIVA_IF_NODE_GET_PRIVATE(object) \
+ static_cast<GGandivaIfNodePrivate *>( \
+ ggandiva_if_node_get_instance_private( \
+ GGANDIVA_IF_NODE(object)))
+
+static void
+ggandiva_if_node_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_IF_NODE_GET_PRIVATE(object);
+
+ if (priv->condition_node) {
+ g_object_unref(priv->condition_node);
+ priv->condition_node = nullptr;
+ }
+
+ if (priv->then_node) {
+ g_object_unref(priv->then_node);
+ priv->then_node = nullptr;
+ }
+
+ if (priv->else_node) {
+ g_object_unref(priv->else_node);
+ priv->else_node = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_if_node_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_if_node_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_IF_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_CONDITION_NODE:
+ priv->condition_node = GGANDIVA_NODE(g_value_dup_object(value));
+ break;
+ case PROP_THEN_NODE:
+ priv->then_node = GGANDIVA_NODE(g_value_dup_object(value));
+ break;
+ case PROP_ELSE_NODE:
+ priv->else_node = GGANDIVA_NODE(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_if_node_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_IF_NODE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_CONDITION_NODE:
+ g_value_set_object(value, priv->condition_node);
+ break;
+ case PROP_THEN_NODE:
+ g_value_set_object(value, priv->then_node);
+ break;
+ case PROP_ELSE_NODE:
+ g_value_set_object(value, priv->else_node);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_if_node_init(GGandivaIfNode *if_node)
+{
+}
+
+static void
+ggandiva_if_node_class_init(GGandivaIfNodeClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_if_node_dispose;
+ gobject_class->set_property = ggandiva_if_node_set_property;
+ gobject_class->get_property = ggandiva_if_node_get_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_object("condition-node",
+ "Condition node",
+ "The condition node",
+ GGANDIVA_TYPE_NODE,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_CONDITION_NODE, spec);
+
+ spec = g_param_spec_object("then-node",
+ "Then node",
+ "The then node",
+ GGANDIVA_TYPE_NODE,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_THEN_NODE, spec);
+
+ spec = g_param_spec_object("else-node",
+ "Else node",
+ "The else node",
+ GGANDIVA_TYPE_NODE,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_ELSE_NODE, spec);
+}
+
+/**
+ * ggandiva_if_node_new:
+ * @condition_node: the node with the condition for if-else expression.
+ * @then_node: the node in case the condition node is true.
+ * @else_node: the node in case the condition node is false.
+ * @return_type: A #GArrowDataType.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GGandivaIfNode or %NULL on error.
+ *
+ * Since: 0.12.0
+ */
+GGandivaIfNode *
+ggandiva_if_node_new(GGandivaNode *condition_node,
+ GGandivaNode *then_node,
+ GGandivaNode *else_node,
+ GArrowDataType *return_type,
+ GError **error)
+{
+ if (!condition_node || !then_node || !else_node || !return_type) {
+ /* TODO: Improve error message to show which arguments are invalid. */
+ g_set_error(error,
+ GARROW_ERROR,
+ GARROW_ERROR_INVALID,
+ "[gandiva][if-literal-node][new] "
+ "all arguments must not NULL");
+ return NULL;
+ }
+ auto gandiva_condition_node = ggandiva_node_get_raw(condition_node);
+ auto gandiva_then_node = ggandiva_node_get_raw(then_node);
+ auto gandiva_else_node = ggandiva_node_get_raw(else_node);
+ auto arrow_return_type = garrow_data_type_get_raw(return_type);
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeIf(gandiva_condition_node,
+ gandiva_then_node,
+ gandiva_else_node,
+ arrow_return_type);
+ if (!gandiva_node) {
+ g_set_error(error,
+ GARROW_ERROR,
+ GARROW_ERROR_INVALID,
+ "[gandiva][if-literal-node][new] "
+ "failed to create: if (<%s>) {<%s>} else {<%s>} -> <%s>",
+ gandiva_condition_node->ToString().c_str(),
+ gandiva_then_node->ToString().c_str(),
+ gandiva_else_node->ToString().c_str(),
+ arrow_return_type->ToString().c_str());
+ return NULL;
+ }
+ return ggandiva_if_node_new_raw(&gandiva_node,
+ condition_node,
+ then_node,
+ else_node,
+ return_type);
+}
+
+
+typedef struct GGandivaBooleanNodePrivate_ {
+ GList *children;
+} GGandivaBooleanNodePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaBooleanNode,
+ ggandiva_boolean_node,
+ GGANDIVA_TYPE_NODE)
+
+#define GGANDIVA_BOOLEAN_NODE_GET_PRIVATE(object) \
+ static_cast<GGandivaBooleanNodePrivate *>( \
+ ggandiva_boolean_node_get_instance_private( \
+ GGANDIVA_BOOLEAN_NODE(object))) \
+
+static void
+ggandiva_boolean_node_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_BOOLEAN_NODE_GET_PRIVATE(object);
+
+ if (priv->children) {
+ g_list_free_full(priv->children, g_object_unref);
+ priv->children = nullptr;
+ }
+
+ G_OBJECT_CLASS(ggandiva_boolean_node_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_boolean_node_init(GGandivaBooleanNode *boolean_node)
+{
+ auto priv = GGANDIVA_BOOLEAN_NODE_GET_PRIVATE(boolean_node);
+ priv->children = nullptr;
+}
+
+static void
+ggandiva_boolean_node_class_init(GGandivaBooleanNodeClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_boolean_node_dispose;
+}
+
+/**
+ * ggandiva_boolean_node_get_children:
+ * @node: A #GGandivaBooleanNode.
+ *
+ * Returns: (transfer none) (element-type GGandivaNode):
+ * The children of the boolean node.
+ *
+ * Since: 0.17.0
+ */
+GList *
+ggandiva_boolean_node_get_children(GGandivaBooleanNode *node)
+{
+ auto priv = GGANDIVA_BOOLEAN_NODE_GET_PRIVATE(node);
+ return priv->children;
+}
+
+
+G_DEFINE_TYPE(GGandivaAndNode,
+ ggandiva_and_node,
+ GGANDIVA_TYPE_BOOLEAN_NODE)
+
+static void
+ggandiva_and_node_init(GGandivaAndNode *and_node)
+{
+}
+
+static void
+ggandiva_and_node_class_init(GGandivaAndNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_and_node_new:
+ * @children: (element-type GGandivaNode): The children of the AND node.
+ *
+ * Returns: A newly created #GGandivaAndNode for the AND expression.
+ *
+ * Since: 0.17.0
+ */
+GGandivaAndNode *
+ggandiva_and_node_new(GList *children)
+{
+ std::vector<std::shared_ptr<gandiva::Node>> gandiva_nodes;
+ for (auto node = children; node; node = g_list_next(node)) {
+ auto gandiva_node = ggandiva_node_get_raw(GGANDIVA_NODE(node->data));
+ gandiva_nodes.push_back(gandiva_node);
+ }
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeAnd(gandiva_nodes);
+ return GGANDIVA_AND_NODE(ggandiva_boolean_node_new_raw(&gandiva_node,
+ children));
+}
+
+
+G_DEFINE_TYPE(GGandivaOrNode,
+ ggandiva_or_node,
+ GGANDIVA_TYPE_BOOLEAN_NODE)
+
+static void
+ggandiva_or_node_init(GGandivaOrNode *or_node)
+{
+}
+
+static void
+ggandiva_or_node_class_init(GGandivaOrNodeClass *klass)
+{
+}
+
+/**
+ * ggandiva_or_node_new:
+ * @children: (element-type GGandivaNode): The children of the OR node.
+ *
+ * Returns: A newly created #GGandivaOrNode for the OR expression.
+ *
+ * Since: 0.17.0
+ */
+GGandivaOrNode *
+ggandiva_or_node_new(GList *children)
+{
+ std::vector<std::shared_ptr<gandiva::Node>> gandiva_nodes;
+ for (auto node = children; node; node = g_list_next(node)) {
+ auto gandiva_node = ggandiva_node_get_raw(GGANDIVA_NODE(node->data));
+ gandiva_nodes.push_back(gandiva_node);
+ }
+ auto gandiva_node = gandiva::TreeExprBuilder::MakeOr(gandiva_nodes);
+ return GGANDIVA_OR_NODE(ggandiva_boolean_node_new_raw(&gandiva_node,
+ children));
+}
+
+G_END_DECLS
+
+std::shared_ptr<gandiva::Node>
+ggandiva_node_get_raw(GGandivaNode *node)
+{
+ auto priv = GGANDIVA_NODE_GET_PRIVATE(node);
+ return priv->node;
+}
+
+GGandivaFieldNode *
+ggandiva_field_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GArrowField *field)
+{
+ auto arrow_return_type = (*gandiva_node)->return_type();
+ auto return_type = garrow_field_get_data_type(field);
+ auto field_node = g_object_new(GGANDIVA_TYPE_FIELD_NODE,
+ "node", gandiva_node,
+ "field", field,
+ "return-type", return_type,
+ NULL);
+ return GGANDIVA_FIELD_NODE(field_node);
+}
+
+GGandivaFunctionNode *
+ggandiva_function_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ const gchar *name,
+ GList *parameters,
+ GArrowDataType *return_type)
+{
+ auto function_node = g_object_new(GGANDIVA_TYPE_FUNCTION_NODE,
+ "node", gandiva_node,
+ "name", name,
+ "return-type", return_type,
+ NULL);
+ auto priv = GGANDIVA_FUNCTION_NODE_GET_PRIVATE(function_node);
+ for (auto node = parameters; node; node = g_list_next(node)) {
+ auto parameter = GGANDIVA_NODE(node->data);
+ priv->parameters = g_list_prepend(priv->parameters, g_object_ref(parameter));
+ }
+ priv->parameters = g_list_reverse(priv->parameters);
+ return GGANDIVA_FUNCTION_NODE(function_node);
+}
+
+GGandivaLiteralNode *
+ggandiva_literal_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GArrowDataType *return_type)
+{
+ auto gandiva_literal_node =
+ std::static_pointer_cast<gandiva::LiteralNode>(*gandiva_node);
+
+ GGandivaLiteralNode *literal_node;
+ if (gandiva_literal_node->is_null()) {
+ literal_node =
+ GGANDIVA_LITERAL_NODE(g_object_new(GGANDIVA_TYPE_NULL_LITERAL_NODE,
+ "node", gandiva_node,
+ "return-type", return_type,
+ NULL));
+ } else {
+ GType type;
+
+ auto arrow_return_type = gandiva_literal_node->return_type();
+ switch (arrow_return_type->id()) {
+ case arrow::Type::BOOL:
+ type = GGANDIVA_TYPE_BOOLEAN_LITERAL_NODE;
+ break;
+ case arrow::Type::type::UINT8:
+ type = GGANDIVA_TYPE_UINT8_LITERAL_NODE;
+ break;
+ case arrow::Type::type::UINT16:
+ type = GGANDIVA_TYPE_UINT16_LITERAL_NODE;
+ break;
+ case arrow::Type::type::UINT32:
+ type = GGANDIVA_TYPE_UINT32_LITERAL_NODE;
+ break;
+ case arrow::Type::type::UINT64:
+ type = GGANDIVA_TYPE_UINT64_LITERAL_NODE;
+ break;
+ case arrow::Type::type::INT8:
+ type = GGANDIVA_TYPE_INT8_LITERAL_NODE;
+ break;
+ case arrow::Type::type::INT16:
+ type = GGANDIVA_TYPE_INT16_LITERAL_NODE;
+ break;
+ case arrow::Type::type::INT32:
+ type = GGANDIVA_TYPE_INT32_LITERAL_NODE;
+ break;
+ case arrow::Type::type::INT64:
+ type = GGANDIVA_TYPE_INT64_LITERAL_NODE;
+ break;
+ case arrow::Type::type::FLOAT:
+ type = GGANDIVA_TYPE_FLOAT_LITERAL_NODE;
+ break;
+ case arrow::Type::type::DOUBLE:
+ type = GGANDIVA_TYPE_DOUBLE_LITERAL_NODE;
+ break;
+ case arrow::Type::type::STRING:
+ type = GGANDIVA_TYPE_STRING_LITERAL_NODE;
+ break;
+ case arrow::Type::type::BINARY:
+ type = GGANDIVA_TYPE_BINARY_LITERAL_NODE;
+ break;
+ default:
+ type = GGANDIVA_TYPE_LITERAL_NODE;
+ break;
+ }
+
+ if (return_type) {
+ literal_node =
+ GGANDIVA_LITERAL_NODE(g_object_new(type,
+ "node", gandiva_node,
+ "return-type", return_type,
+ NULL));
+ } else {
+ return_type = garrow_data_type_new_raw(&arrow_return_type);
+ literal_node =
+ GGANDIVA_LITERAL_NODE(g_object_new(type,
+ "node", gandiva_node,
+ "return-type", return_type,
+ NULL));
+ g_object_unref(return_type);
+ }
+ }
+
+ return literal_node;
+}
+
+GGandivaIfNode *
+ggandiva_if_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GGandivaNode *condition_node,
+ GGandivaNode *then_node,
+ GGandivaNode *else_node,
+ GArrowDataType *return_type)
+{
+ auto if_node = g_object_new(GGANDIVA_TYPE_IF_NODE,
+ "node", gandiva_node,
+ "condition-node", condition_node,
+ "then-node", then_node,
+ "else-node", else_node,
+ "return-type", return_type,
+ NULL);
+ return GGANDIVA_IF_NODE(if_node);
+}
+
+GGandivaBooleanNode *
+ggandiva_boolean_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GList *children)
+{
+ auto gandiva_boolean_node =
+ std::static_pointer_cast<gandiva::BooleanNode>(*gandiva_node);
+
+ GType type;
+ if (gandiva_boolean_node->expr_type() == gandiva::BooleanNode::AND) {
+ type = GGANDIVA_TYPE_AND_NODE;
+ } else {
+ type = GGANDIVA_TYPE_OR_NODE;
+ }
+ auto boolean_node = g_object_new(type,
+ "node", gandiva_node,
+ NULL);
+ auto priv = GGANDIVA_BOOLEAN_NODE_GET_PRIVATE(boolean_node);
+ priv->children = g_list_copy_deep(children,
+ reinterpret_cast<GCopyFunc>(g_object_ref),
+ NULL);
+ return GGANDIVA_BOOLEAN_NODE(boolean_node);
+}
diff --git a/src/arrow/c_glib/gandiva-glib/node.h b/src/arrow/c_glib/gandiva-glib/node.h
new file mode 100644
index 000000000..a16f26c65
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/node.h
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <arrow-glib/arrow-glib.h>
+
+#include <gandiva-glib/version.h>
+
+G_BEGIN_DECLS
+
+#define GGANDIVA_TYPE_NODE (ggandiva_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaNode,
+ ggandiva_node,
+ GGANDIVA,
+ NODE,
+ GObject)
+
+struct _GGandivaNodeClass
+{
+ GObjectClass parent_class;
+};
+
+gchar *ggandiva_node_to_string(GGandivaNode *node);
+
+
+#define GGANDIVA_TYPE_FIELD_NODE (ggandiva_field_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaFieldNode,
+ ggandiva_field_node,
+ GGANDIVA,
+ FIELD_NODE,
+ GGandivaNode)
+struct _GGandivaFieldNodeClass
+{
+ GGandivaNodeClass parent_class;
+};
+
+GGandivaFieldNode *ggandiva_field_node_new(GArrowField *field);
+
+
+#define GGANDIVA_TYPE_FUNCTION_NODE (ggandiva_function_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaFunctionNode,
+ ggandiva_function_node,
+ GGANDIVA,
+ FUNCTION_NODE,
+ GGandivaNode)
+struct _GGandivaFunctionNodeClass
+{
+ GGandivaNodeClass parent_class;
+};
+
+GGandivaFunctionNode *
+ggandiva_function_node_new(const gchar *name,
+ GList *parameters,
+ GArrowDataType *return_type);
+GList *
+ggandiva_function_node_get_parameters(GGandivaFunctionNode *node);
+
+
+#define GGANDIVA_TYPE_LITERAL_NODE (ggandiva_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaLiteralNode,
+ ggandiva_literal_node,
+ GGANDIVA,
+ LITERAL_NODE,
+ GGandivaNode)
+struct _GGandivaLiteralNodeClass
+{
+ GGandivaNodeClass parent_class;
+};
+
+
+#define GGANDIVA_TYPE_NULL_LITERAL_NODE (ggandiva_null_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaNullLiteralNode,
+ ggandiva_null_literal_node,
+ GGANDIVA,
+ NULL_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaNullLiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaNullLiteralNode *
+ggandiva_null_literal_node_new(GArrowDataType *return_type,
+ GError **error);
+
+
+#define GGANDIVA_TYPE_BOOLEAN_LITERAL_NODE (ggandiva_boolean_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaBooleanLiteralNode,
+ ggandiva_boolean_literal_node,
+ GGANDIVA,
+ BOOLEAN_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaBooleanLiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaBooleanLiteralNode *
+ggandiva_boolean_literal_node_new(gboolean value);
+gboolean
+ggandiva_boolean_literal_node_get_value(GGandivaBooleanLiteralNode *node);
+
+
+#define GGANDIVA_TYPE_INT8_LITERAL_NODE (ggandiva_int8_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaInt8LiteralNode,
+ ggandiva_int8_literal_node,
+ GGANDIVA,
+ INT8_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaInt8LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaInt8LiteralNode *
+ggandiva_int8_literal_node_new(gint8 value);
+gint8
+ggandiva_int8_literal_node_get_value(GGandivaInt8LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_UINT8_LITERAL_NODE (ggandiva_uint8_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaUInt8LiteralNode,
+ ggandiva_uint8_literal_node,
+ GGANDIVA,
+ UINT8_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaUInt8LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaUInt8LiteralNode *
+ggandiva_uint8_literal_node_new(guint8 value);
+guint8
+ggandiva_uint8_literal_node_get_value(GGandivaUInt8LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_INT16_LITERAL_NODE (ggandiva_int16_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaInt16LiteralNode,
+ ggandiva_int16_literal_node,
+ GGANDIVA,
+ INT16_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaInt16LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaInt16LiteralNode *
+ggandiva_int16_literal_node_new(gint16 value);
+gint16
+ggandiva_int16_literal_node_get_value(GGandivaInt16LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_UINT16_LITERAL_NODE (ggandiva_uint16_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaUInt16LiteralNode,
+ ggandiva_uint16_literal_node,
+ GGANDIVA,
+ UINT16_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaUInt16LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaUInt16LiteralNode *
+ggandiva_uint16_literal_node_new(guint16 value);
+guint16
+ggandiva_uint16_literal_node_get_value(GGandivaUInt16LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_INT32_LITERAL_NODE (ggandiva_int32_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaInt32LiteralNode,
+ ggandiva_int32_literal_node,
+ GGANDIVA,
+ INT32_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaInt32LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaInt32LiteralNode *
+ggandiva_int32_literal_node_new(gint32 value);
+gint32
+ggandiva_int32_literal_node_get_value(GGandivaInt32LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_UINT32_LITERAL_NODE (ggandiva_uint32_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaUInt32LiteralNode,
+ ggandiva_uint32_literal_node,
+ GGANDIVA,
+ UINT32_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaUInt32LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaUInt32LiteralNode *
+ggandiva_uint32_literal_node_new(guint32 value);
+guint32
+ggandiva_uint32_literal_node_get_value(GGandivaUInt32LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_INT64_LITERAL_NODE (ggandiva_int64_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaInt64LiteralNode,
+ ggandiva_int64_literal_node,
+ GGANDIVA,
+ INT64_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaInt64LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaInt64LiteralNode *
+ggandiva_int64_literal_node_new(gint64 value);
+gint64
+ggandiva_int64_literal_node_get_value(GGandivaInt64LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_UINT64_LITERAL_NODE (ggandiva_uint64_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaUInt64LiteralNode,
+ ggandiva_uint64_literal_node,
+ GGANDIVA,
+ UINT64_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaUInt64LiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaUInt64LiteralNode *
+ggandiva_uint64_literal_node_new(guint64 value);
+guint64
+ggandiva_uint64_literal_node_get_value(GGandivaUInt64LiteralNode *node);
+
+
+#define GGANDIVA_TYPE_FLOAT_LITERAL_NODE (ggandiva_float_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaFloatLiteralNode,
+ ggandiva_float_literal_node,
+ GGANDIVA,
+ FLOAT_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaFloatLiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaFloatLiteralNode *
+ggandiva_float_literal_node_new(gfloat value);
+gfloat
+ggandiva_float_literal_node_get_value(GGandivaFloatLiteralNode *node);
+
+
+#define GGANDIVA_TYPE_DOUBLE_LITERAL_NODE (ggandiva_double_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaDoubleLiteralNode,
+ ggandiva_double_literal_node,
+ GGANDIVA,
+ DOUBLE_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaDoubleLiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaDoubleLiteralNode *
+ggandiva_double_literal_node_new(gdouble value);
+gdouble
+ggandiva_double_literal_node_get_value(GGandivaDoubleLiteralNode *node);
+
+
+#define GGANDIVA_TYPE_BINARY_LITERAL_NODE (ggandiva_binary_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaBinaryLiteralNode,
+ ggandiva_binary_literal_node,
+ GGANDIVA,
+ BINARY_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaBinaryLiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaBinaryLiteralNode *
+ggandiva_binary_literal_node_new(const guint8 *value,
+ gsize size);
+GGandivaBinaryLiteralNode *
+ggandiva_binary_literal_node_new_bytes(GBytes *value);
+GBytes *
+ggandiva_binary_literal_node_get_value(GGandivaBinaryLiteralNode *node);
+
+
+#define GGANDIVA_TYPE_STRING_LITERAL_NODE (ggandiva_string_literal_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaStringLiteralNode,
+ ggandiva_string_literal_node,
+ GGANDIVA,
+ STRING_LITERAL_NODE,
+ GGandivaLiteralNode)
+struct _GGandivaStringLiteralNodeClass
+{
+ GGandivaLiteralNodeClass parent_class;
+};
+
+GGandivaStringLiteralNode *
+ggandiva_string_literal_node_new(const gchar *value);
+const gchar *
+ggandiva_string_literal_node_get_value(GGandivaStringLiteralNode *node);
+
+
+#define GGANDIVA_TYPE_IF_NODE (ggandiva_if_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaIfNode,
+ ggandiva_if_node,
+ GGANDIVA,
+ IF_NODE,
+ GGandivaNode)
+struct _GGandivaIfNodeClass
+{
+ GGandivaNodeClass parent_class;
+};
+
+GGandivaIfNode *
+ggandiva_if_node_new(GGandivaNode *condition_node,
+ GGandivaNode *then_node,
+ GGandivaNode *else_node,
+ GArrowDataType *return_type,
+ GError **error);
+
+
+#define GGANDIVA_TYPE_BOOLEAN_NODE (ggandiva_boolean_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaBooleanNode,
+ ggandiva_boolean_node,
+ GGANDIVA,
+ BOOLEAN_NODE,
+ GGandivaNode)
+
+struct _GGandivaBooleanNodeClass
+{
+ GGandivaNodeClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_0_17
+GList *
+ggandiva_boolean_node_get_children(GGandivaBooleanNode *node);
+
+
+#define GGANDIVA_TYPE_AND_NODE (ggandiva_and_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaAndNode,
+ ggandiva_and_node,
+ GGANDIVA,
+ AND_NODE,
+ GGandivaBooleanNode)
+struct _GGandivaAndNodeClass
+{
+ GGandivaBooleanNodeClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_0_17
+GGandivaAndNode *
+ggandiva_and_node_new(GList *children);
+
+
+#define GGANDIVA_TYPE_OR_NODE (ggandiva_or_node_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaOrNode,
+ ggandiva_or_node,
+ GGANDIVA,
+ OR_NODE,
+ GGandivaBooleanNode)
+struct _GGandivaOrNodeClass
+{
+ GGandivaBooleanNodeClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_0_17
+GGandivaOrNode *
+ggandiva_or_node_new(GList *children);
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/node.hpp b/src/arrow/c_glib/gandiva-glib/node.hpp
new file mode 100644
index 000000000..51dc2cbbf
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/node.hpp
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <gandiva/node.h>
+#include <gandiva/tree_expr_builder.h>
+
+#include <gandiva-glib/node.h>
+
+std::shared_ptr<gandiva::Node> ggandiva_node_get_raw(GGandivaNode *node);
+GGandivaFieldNode *
+ggandiva_field_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GArrowField *field);
+GGandivaFunctionNode *
+ggandiva_function_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ const gchar *name,
+ GList *parameters,
+ GArrowDataType *return_type);
+GGandivaLiteralNode *
+ggandiva_literal_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GArrowDataType *return_type);
+GGandivaIfNode *
+ggandiva_if_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GGandivaNode *condition_node,
+ GGandivaNode *then_node,
+ GGandivaNode *else_node,
+ GArrowDataType *return_type);
+GGandivaBooleanNode *
+ggandiva_boolean_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
+ GList *children);
diff --git a/src/arrow/c_glib/gandiva-glib/projector.cpp b/src/arrow/c_glib/gandiva-glib/projector.cpp
new file mode 100644
index 000000000..c91cde84c
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/projector.cpp
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <arrow-glib/basic-array.hpp>
+#include <arrow-glib/error.hpp>
+#include <arrow-glib/record-batch.hpp>
+#include <arrow-glib/schema.hpp>
+
+#include <gandiva-glib/expression.hpp>
+#include <gandiva-glib/projector.hpp>
+#include <gandiva-glib/selection-vector.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: projector
+ * @title: Projector classes
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * #GGandivaProjector is a class that evaluates given expressions
+ * against the given record batches.
+ *
+ * #GGandivaSelectableProjector is a class that evaluates given expressions
+ * against the given selected records in the given record batches.
+ *
+ * Since: 0.12.0
+ */
+
+typedef struct GGandivaProjectorPrivate_ {
+ std::shared_ptr<gandiva::Projector> projector;
+ GArrowSchema *schema;
+ GList *expressions;
+} GGandivaProjectorPrivate;
+
+enum {
+ PROP_PROJECTOR = 1,
+ PROP_SCHEMA,
+ PROP_EXPRESSIONS,
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GGandivaProjector,
+ ggandiva_projector,
+ G_TYPE_OBJECT)
+
+#define GGANDIVA_PROJECTOR_GET_PRIVATE(obj) \
+ static_cast<GGandivaProjectorPrivate *>( \
+ ggandiva_projector_get_instance_private( \
+ GGANDIVA_PROJECTOR(obj)))
+
+static void
+ggandiva_projector_dispose(GObject *object)
+{
+ auto priv = GGANDIVA_PROJECTOR_GET_PRIVATE(object);
+
+ if (priv->schema) {
+ g_object_unref(G_OBJECT(priv->schema));
+ priv->schema = nullptr;
+ }
+
+ g_list_free_full(priv->expressions, g_object_unref);
+ priv->expressions = nullptr;
+
+ G_OBJECT_CLASS(ggandiva_projector_parent_class)->dispose(object);
+}
+
+static void
+ggandiva_projector_finalize(GObject *object)
+{
+ auto priv = GGANDIVA_PROJECTOR_GET_PRIVATE(object);
+
+ priv->projector.~shared_ptr();
+
+ G_OBJECT_CLASS(ggandiva_projector_parent_class)->finalize(object);
+}
+
+static void
+ggandiva_projector_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_PROJECTOR_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_PROJECTOR:
+ priv->projector =
+ *static_cast<std::shared_ptr<gandiva::Projector> *>(g_value_get_pointer(value));
+ break;
+ case PROP_SCHEMA:
+ priv->schema = GARROW_SCHEMA(g_value_dup_object(value));
+ break;
+ case PROP_EXPRESSIONS:
+ priv->expressions =
+ g_list_copy_deep(static_cast<GList *>(g_value_get_pointer(value)),
+ reinterpret_cast<GCopyFunc>(g_object_ref),
+ nullptr);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_projector_get_property(GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_PROJECTOR_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_SCHEMA:
+ g_value_set_object(value, priv->schema);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_projector_init(GGandivaProjector *object)
+{
+ auto priv = GGANDIVA_PROJECTOR_GET_PRIVATE(object);
+ new(&priv->projector) std::shared_ptr<gandiva::Projector>;
+}
+
+static void
+ggandiva_projector_class_init(GGandivaProjectorClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = ggandiva_projector_dispose;
+ gobject_class->finalize = ggandiva_projector_finalize;
+ gobject_class->set_property = ggandiva_projector_set_property;
+ gobject_class->get_property = ggandiva_projector_get_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_pointer("projector",
+ "Projector",
+ "The raw std::shared<gandiva::Projector> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_PROJECTOR, spec);
+
+ spec = g_param_spec_object("schema",
+ "Schema",
+ "The schema of the projector",
+ GARROW_TYPE_SCHEMA,
+ static_cast<GParamFlags>(G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_SCHEMA, spec);
+
+ spec = g_param_spec_pointer("expressions",
+ "Expressions",
+ "The expressions for the projector",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_EXPRESSIONS, spec);
+}
+
+/**
+ * ggandiva_projector_new:
+ * @schema: A #GArrowSchema.
+ * @expressions: (element-type GGandivaExpression): The built expressions.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GGandivaProjector on success,
+ * %NULL on error.
+ *
+ * Since: 0.12.0
+ */
+GGandivaProjector *
+ggandiva_projector_new(GArrowSchema *schema,
+ GList *expressions,
+ GError **error)
+{
+ auto arrow_schema = garrow_schema_get_raw(schema);
+ std::vector<std::shared_ptr<gandiva::Expression>> gandiva_expressions;
+ for (auto node = expressions; node; node = g_list_next(node)) {
+ auto expression = GGANDIVA_EXPRESSION(node->data);
+ auto gandiva_expression = ggandiva_expression_get_raw(expression);
+ gandiva_expressions.push_back(gandiva_expression);
+ }
+ std::shared_ptr<gandiva::Projector> gandiva_projector;
+ auto status =
+ gandiva_projector->Make(arrow_schema,
+ gandiva_expressions,
+ &gandiva_projector);
+ if (garrow_error_check(error, status, "[gandiva][projector][new]")) {
+ return ggandiva_projector_new_raw(&gandiva_projector,
+ schema,
+ expressions);
+ } else {
+ return NULL;
+ }
+}
+
+/**
+ * ggandiva_projector_evaluate:
+ * @projector: A #GGandivaProjector.
+ * @record_batch: A #GArrowRecordBatch.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (element-type GArrowArray) (nullable) (transfer full):
+ * The #GArrowArray as the result evaluated on success, %NULL on error.
+ *
+ * Since: 0.12.0
+ */
+GList *
+ggandiva_projector_evaluate(GGandivaProjector *projector,
+ GArrowRecordBatch *record_batch,
+ GError **error)
+{
+ auto gandiva_projector = ggandiva_projector_get_raw(projector);
+ auto arrow_record_batch = garrow_record_batch_get_raw(record_batch);
+ auto memory_pool = arrow::default_memory_pool();
+ arrow::ArrayVector arrow_arrays;
+ auto status =
+ gandiva_projector->Evaluate(*arrow_record_batch,
+ memory_pool,
+ &arrow_arrays);
+ if (garrow_error_check(error, status, "[gandiva][projector][evaluate]")) {
+ GList *arrays = NULL;
+ for (auto arrow_array : arrow_arrays) {
+ auto array = garrow_array_new_raw(&arrow_array);
+ arrays = g_list_prepend(arrays, array);
+ }
+ return g_list_reverse(arrays);
+ } else {
+ return NULL;
+ }
+}
+
+
+G_DEFINE_TYPE(GGandivaSelectableProjector,
+ ggandiva_selectable_projector,
+ GGANDIVA_TYPE_PROJECTOR)
+
+static void
+ggandiva_selectable_projector_init(GGandivaSelectableProjector *object)
+{
+}
+
+static void
+ggandiva_selectable_projector_class_init(GGandivaSelectableProjectorClass *klass)
+{
+}
+
+/**
+ * ggandiva_selectable_projector_new:
+ * @schema: A #GArrowSchema.
+ * @expressions: (element-type GGandivaExpression): The built expressions.
+ * @mode: A #GGandivaSelectionVectorMode to be used.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GGandivaProjector on success,
+ * %NULL on error.
+ *
+ * Since: 4.0.0
+ */
+GGandivaSelectableProjector *
+ggandiva_selectable_projector_new(GArrowSchema *schema,
+ GList *expressions,
+ GGandivaSelectionVectorMode mode,
+ GError **error)
+{
+ auto arrow_schema = garrow_schema_get_raw(schema);
+ std::vector<std::shared_ptr<gandiva::Expression>> gandiva_expressions;
+ for (auto node = expressions; node; node = g_list_next(node)) {
+ auto expression = GGANDIVA_EXPRESSION(node->data);
+ auto gandiva_expression = ggandiva_expression_get_raw(expression);
+ gandiva_expressions.push_back(gandiva_expression);
+ }
+ auto gandiva_mode = static_cast<gandiva::SelectionVector::Mode>(mode);
+ auto gandiva_configuration =
+ gandiva::ConfigurationBuilder::DefaultConfiguration();
+ std::shared_ptr<gandiva::Projector> gandiva_projector;
+ auto status = gandiva_projector->Make(arrow_schema,
+ gandiva_expressions,
+ gandiva_mode,
+ gandiva_configuration,
+ &gandiva_projector);
+ if (garrow_error_check(error,
+ status,
+ "[gandiva][selectable-projector][new]")) {
+ return ggandiva_selectable_projector_new_raw(&gandiva_projector,
+ schema,
+ expressions);
+ } else {
+ return NULL;
+ }
+}
+
+/**
+ * ggandiva_selectable_projector_evaluate:
+ * @projector: A #GGandivaSelectableProjector.
+ * @record_batch: A #GArrowRecordBatch.
+ * @selection_vector: A #GGandivaSelectionVector that specifies
+ * the filtered row positions.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (element-type GArrowArray) (nullable) (transfer full):
+ * The #GArrowArray as the result evaluated on success, %NULL on error.
+ *
+ * Since: 4.0.0
+ */
+GList *
+ggandiva_selectable_projector_evaluate(
+ GGandivaSelectableProjector *projector,
+ GArrowRecordBatch *record_batch,
+ GGandivaSelectionVector *selection_vector,
+ GError **error)
+{
+ auto gandiva_projector =
+ ggandiva_projector_get_raw(GGANDIVA_PROJECTOR(projector));
+ auto arrow_record_batch = garrow_record_batch_get_raw(record_batch);
+ auto gandiva_selection_vector =
+ ggandiva_selection_vector_get_raw(selection_vector).get();
+ auto memory_pool = arrow::default_memory_pool();
+ arrow::ArrayVector arrow_arrays;
+ auto status =
+ gandiva_projector->Evaluate(*arrow_record_batch,
+ gandiva_selection_vector,
+ memory_pool,
+ &arrow_arrays);
+ if (garrow_error_check(error,
+ status,
+ "[gandiva][selectable-projector][evaluate]")) {
+ GList *arrays = NULL;
+ for (auto arrow_array : arrow_arrays) {
+ auto array = garrow_array_new_raw(&arrow_array);
+ arrays = g_list_prepend(arrays, array);
+ }
+ return g_list_reverse(arrays);
+ } else {
+ return NULL;
+ }
+}
+
+G_END_DECLS
+
+GGandivaProjector *
+ggandiva_projector_new_raw(
+ std::shared_ptr<gandiva::Projector> *gandiva_projector,
+ GArrowSchema *schema,
+ GList *expressions)
+{
+ auto projector = g_object_new(GGANDIVA_TYPE_PROJECTOR,
+ "projector", gandiva_projector,
+ "schema", schema,
+ "expressions", expressions,
+ NULL);
+ return GGANDIVA_PROJECTOR(projector);
+}
+
+GGandivaSelectableProjector *
+ggandiva_selectable_projector_new_raw(
+ std::shared_ptr<gandiva::Projector> *gandiva_projector,
+ GArrowSchema *schema,
+ GList *expressions)
+{
+ auto projector = g_object_new(GGANDIVA_TYPE_SELECTABLE_PROJECTOR,
+ "projector", gandiva_projector,
+ NULL);
+ return GGANDIVA_SELECTABLE_PROJECTOR(projector);
+}
+
+std::shared_ptr<gandiva::Projector>
+ggandiva_projector_get_raw(GGandivaProjector *projector)
+{
+ auto priv = GGANDIVA_PROJECTOR_GET_PRIVATE(projector);
+ return priv->projector;
+}
diff --git a/src/arrow/c_glib/gandiva-glib/projector.h b/src/arrow/c_glib/gandiva-glib/projector.h
new file mode 100644
index 000000000..5dd218b80
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/projector.h
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <gandiva-glib/selection-vector.h>
+
+G_BEGIN_DECLS
+
+#define GGANDIVA_TYPE_PROJECTOR (ggandiva_projector_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaProjector,
+ ggandiva_projector,
+ GGANDIVA,
+ PROJECTOR,
+ GObject)
+
+struct _GGandivaProjectorClass
+{
+ GObjectClass parent_class;
+};
+
+GGandivaProjector *
+ggandiva_projector_new(GArrowSchema *schema,
+ GList *expressions,
+ GError **error);
+GList *
+ggandiva_projector_evaluate(GGandivaProjector *projector,
+ GArrowRecordBatch *record_batch,
+ GError **error);
+
+
+#define GGANDIVA_TYPE_SELECTABLE_PROJECTOR \
+ (ggandiva_selectable_projector_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaSelectableProjector,
+ ggandiva_selectable_projector,
+ GGANDIVA,
+ SELECTABLE_PROJECTOR,
+ GGandivaProjector)
+
+struct _GGandivaSelectableProjectorClass
+{
+ GGandivaProjectorClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_4_0
+GGandivaSelectableProjector *
+ggandiva_selectable_projector_new(GArrowSchema *schema,
+ GList *expressions,
+ GGandivaSelectionVectorMode mode,
+ GError **error);
+GGANDIVA_AVAILABLE_IN_4_0
+GList *
+ggandiva_selectable_projector_evaluate(GGandivaSelectableProjector *projector,
+ GArrowRecordBatch *record_batch,
+ GGandivaSelectionVector *selection_vector,
+ GError **error);
+
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/projector.hpp b/src/arrow/c_glib/gandiva-glib/projector.hpp
new file mode 100644
index 000000000..b372f32f5
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/projector.hpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <gandiva/projector.h>
+
+#include <gandiva-glib/projector.h>
+
+GGandivaProjector *
+ggandiva_projector_new_raw(
+ std::shared_ptr<gandiva::Projector> *gandiva_projector,
+ GArrowSchema *schema,
+ GList *expressions);
+GGandivaSelectableProjector *
+ggandiva_selectable_projector_new_raw(
+ std::shared_ptr<gandiva::Projector> *gandiva_projector,
+ GArrowSchema *schema,
+ GList *expressions);
+std::shared_ptr<gandiva::Projector>
+ggandiva_projector_get_raw(GGandivaProjector *projector);
diff --git a/src/arrow/c_glib/gandiva-glib/selection-vector.cpp b/src/arrow/c_glib/gandiva-glib/selection-vector.cpp
new file mode 100644
index 000000000..77c3cf2aa
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/selection-vector.cpp
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <arrow-glib/basic-array.hpp>
+#include <arrow-glib/error.hpp>
+
+#include <gandiva-glib/selection-vector.hpp>
+
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: selection-vector
+ * @section_id: selection-vector-classes
+ * @title: Selection vector classes
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * #GGandivaSelectionVector is a base class for a selection vector.
+ *
+ * #GGandivaUInt16SelectionVector is a class for a selection vector
+ * that uses 16-bit unsigned integer for each index.
+ *
+ * #GGandivaUInt32SelectionVector is a class for a selection vector
+ * that uses 32-bit unsigned integer for each index.
+ *
+ * #GGandivaUInt64SelectionVector is a class for a selection vector
+ * that uses 64-bit unsigned integer for each index.
+ *
+ * Since: 4.0.0
+ */
+
+typedef struct GGandivaSelectionVectorPrivate_ {
+ std::shared_ptr<gandiva::SelectionVector> selection_vector;
+} GGandivaSelectionVectorPrivate;
+
+enum {
+ PROP_SELECTION_VECTOR = 1,
+};
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(GGandivaSelectionVector,
+ ggandiva_selection_vector,
+ G_TYPE_OBJECT)
+
+#define GGANDIVA_SELECTION_VECTOR_GET_PRIVATE(object) \
+ static_cast<GGandivaSelectionVectorPrivate *>( \
+ ggandiva_selection_vector_get_instance_private( \
+ GGANDIVA_SELECTION_VECTOR(object)))
+
+static void
+ggandiva_selection_vector_finalize(GObject *object)
+{
+ auto priv = GGANDIVA_SELECTION_VECTOR_GET_PRIVATE(object);
+
+ priv->selection_vector.~shared_ptr();
+
+ G_OBJECT_CLASS(ggandiva_selection_vector_parent_class)->finalize(object);
+}
+
+static void
+ggandiva_selection_vector_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ auto priv = GGANDIVA_SELECTION_VECTOR_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_SELECTION_VECTOR:
+ priv->selection_vector =
+ *static_cast<std::shared_ptr<gandiva::SelectionVector> *>(
+ g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggandiva_selection_vector_init(GGandivaSelectionVector *object)
+{
+ auto priv = GGANDIVA_SELECTION_VECTOR_GET_PRIVATE(object);
+ new(&priv->selection_vector) std::shared_ptr<gandiva::SelectionVector>;
+}
+
+static void
+ggandiva_selection_vector_class_init(GGandivaSelectionVectorClass *klass)
+{
+ auto gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = ggandiva_selection_vector_finalize;
+ gobject_class->set_property = ggandiva_selection_vector_set_property;
+
+ GParamSpec *spec;
+ spec = g_param_spec_pointer("selection-vector",
+ "Selection vector",
+ "The raw std::shared<gandiva::SelectionVector> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_SELECTION_VECTOR, spec);
+}
+
+/**
+ * ggandiva_selection_vector_get_mode:
+ * @selection_vector: A #GGandivaSelectionVector.
+ *
+ * Returns: A #GGandivaSelectionVectorMode for the selection vector.
+ *
+ * Since: 4.0.0
+ */
+GGandivaSelectionVectorMode
+ggandiva_selection_vector_get_mode(GGandivaSelectionVector *selection_vector)
+{
+ auto gandiva_selection_vector =
+ ggandiva_selection_vector_get_raw(selection_vector);
+ auto gandiva_mode = gandiva_selection_vector->GetMode();
+ return static_cast<GGandivaSelectionVectorMode>(gandiva_mode);
+}
+
+/**
+ * ggandiva_selection_vector_to_array:
+ * @selection_vector: A #GGandivaSelectionVector.
+ *
+ * Returns: (transfer full): A #GArrowArray that has the same content
+ * of the selection vector.
+ *
+ * Since: 4.0.0
+ */
+GArrowArray *
+ggandiva_selection_vector_to_array(GGandivaSelectionVector *selection_vector)
+{
+ auto gandiva_selection_vector =
+ ggandiva_selection_vector_get_raw(selection_vector);
+ auto arrow_array = gandiva_selection_vector->ToArray();
+ return garrow_array_new_raw(&arrow_array);
+}
+
+
+G_DEFINE_TYPE(GGandivaUInt16SelectionVector,
+ ggandiva_uint16_selection_vector,
+ GGANDIVA_TYPE_SELECTION_VECTOR)
+
+static void
+ggandiva_uint16_selection_vector_init(
+ GGandivaUInt16SelectionVector *selection_vector)
+{
+}
+
+static void
+ggandiva_uint16_selection_vector_class_init(
+ GGandivaUInt16SelectionVectorClass *klass)
+{
+}
+
+/**
+ * ggandiva_uint16_selection_vector_new:
+ * @max_slots: The max number of slots.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: A newly created #GGandivaUInt16SelectionVector.
+ *
+ * Since: 4.0.0
+ */
+GGandivaUInt16SelectionVector *
+ggandiva_uint16_selection_vector_new(gint64 max_slots,
+ GError **error)
+{
+ auto memory_pool = arrow::default_memory_pool();
+ std::shared_ptr<gandiva::SelectionVector> gandiva_selection_vector;
+ auto status = gandiva::SelectionVector::MakeInt16(max_slots,
+ memory_pool,
+ &gandiva_selection_vector);
+ if (garrow_error_check(error,
+ status,
+ "[gandiva][uint16-selection-vector][new]")) {
+ return GGANDIVA_UINT16_SELECTION_VECTOR(
+ ggandiva_selection_vector_new_raw(&gandiva_selection_vector));
+ } else {
+ return NULL;
+ }
+}
+
+
+G_DEFINE_TYPE(GGandivaUInt32SelectionVector,
+ ggandiva_uint32_selection_vector,
+ GGANDIVA_TYPE_SELECTION_VECTOR)
+
+static void
+ggandiva_uint32_selection_vector_init(
+ GGandivaUInt32SelectionVector *selection_vector)
+{
+}
+
+static void
+ggandiva_uint32_selection_vector_class_init(
+ GGandivaUInt32SelectionVectorClass *klass)
+{
+}
+
+/**
+ * ggandiva_uint32_selection_vector_new:
+ * @max_slots: The max number of slots.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: A newly created #GGandivaUInt32SelectionVector.
+ *
+ * Since: 4.0.0
+ */
+GGandivaUInt32SelectionVector *
+ggandiva_uint32_selection_vector_new(gint64 max_slots,
+ GError **error)
+{
+ auto memory_pool = arrow::default_memory_pool();
+ std::shared_ptr<gandiva::SelectionVector> gandiva_selection_vector;
+ auto status = gandiva::SelectionVector::MakeInt32(max_slots,
+ memory_pool,
+ &gandiva_selection_vector);
+ if (garrow_error_check(error,
+ status,
+ "[gandiva][uint32-selection-vector][new]")) {
+ return GGANDIVA_UINT32_SELECTION_VECTOR(
+ ggandiva_selection_vector_new_raw(&gandiva_selection_vector));
+ } else {
+ return NULL;
+ }
+}
+
+
+G_DEFINE_TYPE(GGandivaUInt64SelectionVector,
+ ggandiva_uint64_selection_vector,
+ GGANDIVA_TYPE_SELECTION_VECTOR)
+
+static void
+ggandiva_uint64_selection_vector_init(
+ GGandivaUInt64SelectionVector *selection_vector)
+{
+}
+
+static void
+ggandiva_uint64_selection_vector_class_init(
+ GGandivaUInt64SelectionVectorClass *klass)
+{
+}
+
+/**
+ * ggandiva_uint64_selection_vector_new:
+ * @max_slots: The max number of slots.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: A newly created #GGandivaUInt64SelectionVector.
+ *
+ * Since: 4.0.0
+ */
+GGandivaUInt64SelectionVector *
+ggandiva_uint64_selection_vector_new(gint64 max_slots,
+ GError **error)
+{
+ auto memory_pool = arrow::default_memory_pool();
+ std::shared_ptr<gandiva::SelectionVector> gandiva_selection_vector;
+ auto status = gandiva::SelectionVector::MakeInt64(max_slots,
+ memory_pool,
+ &gandiva_selection_vector);
+ if (garrow_error_check(error,
+ status,
+ "[gandiva][uint64-selection-vector][new]")) {
+ return GGANDIVA_UINT64_SELECTION_VECTOR(
+ ggandiva_selection_vector_new_raw(&gandiva_selection_vector));
+ } else {
+ return NULL;
+ }
+}
+
+
+G_END_DECLS
+
+
+GGandivaSelectionVector *
+ggandiva_selection_vector_new_raw(
+ std::shared_ptr<gandiva::SelectionVector> *gandiva_selection_vector)
+{
+ GType type = GGANDIVA_TYPE_SELECTION_VECTOR;
+ switch ((*gandiva_selection_vector)->GetMode()) {
+ case gandiva::SelectionVector::Mode::MODE_UINT16:
+ type = GGANDIVA_TYPE_UINT16_SELECTION_VECTOR;
+ break;
+ case gandiva::SelectionVector::Mode::MODE_UINT32:
+ type = GGANDIVA_TYPE_UINT32_SELECTION_VECTOR;
+ break;
+ case gandiva::SelectionVector::Mode::MODE_UINT64:
+ type = GGANDIVA_TYPE_UINT64_SELECTION_VECTOR;
+ break;
+ default:
+ break;
+ }
+ auto selection_vector =
+ g_object_new(type,
+ "selection-vector", gandiva_selection_vector,
+ NULL);
+ return GGANDIVA_SELECTION_VECTOR(selection_vector);
+}
+
+std::shared_ptr<gandiva::SelectionVector>
+ggandiva_selection_vector_get_raw(GGandivaSelectionVector *selection_vector)
+{
+ auto priv = GGANDIVA_SELECTION_VECTOR_GET_PRIVATE(selection_vector);
+ return priv->selection_vector;
+}
diff --git a/src/arrow/c_glib/gandiva-glib/selection-vector.h b/src/arrow/c_glib/gandiva-glib/selection-vector.h
new file mode 100644
index 000000000..029c4cde5
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/selection-vector.h
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <arrow-glib/arrow-glib.h>
+
+#include <gandiva-glib/version.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GGandivaSelectionVectorMode:
+ * @GGANDIVA_SELECTION_VECTOR_MODE_NONE: Selection vector isn't used.
+ * @GGANDIVA_SELECTION_VECTOR_MODE_UINT16:
+ * #GGandivaUInt16SelectionVector is used.
+ * @GGANDIVA_SELECTION_VECTOR_MODE_UINT32:
+ * #GGandivaUInt32SelectionVector is used.
+ * @GGANDIVA_SELECTION_VECTOR_MODE_UINT64:
+ * #GGandivaUInt64SelectionVector is used.
+ *
+ * They are corresponding to `gandiva::SelectionVector::Mode` values.
+ *
+ * Since: 4.0.0
+ */
+typedef enum {
+ GGANDIVA_SELECTION_VECTOR_MODE_NONE,
+ GGANDIVA_SELECTION_VECTOR_MODE_UINT16,
+ GGANDIVA_SELECTION_VECTOR_MODE_UINT32,
+ GGANDIVA_SELECTION_VECTOR_MODE_UINT64,
+} GGandivaSelectionVectorMode;
+
+
+#define GGANDIVA_TYPE_SELECTION_VECTOR (ggandiva_selection_vector_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaSelectionVector,
+ ggandiva_selection_vector,
+ GGANDIVA,
+ SELECTION_VECTOR,
+ GObject)
+
+struct _GGandivaSelectionVectorClass
+{
+ GObjectClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_4_0
+GGandivaSelectionVectorMode
+ggandiva_selection_vector_get_mode(GGandivaSelectionVector *selection_vector);
+
+GGANDIVA_AVAILABLE_IN_4_0
+GArrowArray *
+ggandiva_selection_vector_to_array(GGandivaSelectionVector *selection_vector);
+
+
+#define GGANDIVA_TYPE_UINT16_SELECTION_VECTOR \
+ (ggandiva_uint16_selection_vector_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaUInt16SelectionVector,
+ ggandiva_uint16_selection_vector,
+ GGANDIVA,
+ UINT16_SELECTION_VECTOR,
+ GGandivaSelectionVector)
+
+struct _GGandivaUInt16SelectionVectorClass
+{
+ GGandivaSelectionVectorClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_4_0
+GGandivaUInt16SelectionVector *
+ggandiva_uint16_selection_vector_new(gint64 max_slots,
+ GError **error);
+
+
+#define GGANDIVA_TYPE_UINT32_SELECTION_VECTOR \
+ (ggandiva_uint32_selection_vector_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaUInt32SelectionVector,
+ ggandiva_uint32_selection_vector,
+ GGANDIVA,
+ UINT32_SELECTION_VECTOR,
+ GGandivaSelectionVector)
+
+struct _GGandivaUInt32SelectionVectorClass
+{
+ GGandivaSelectionVectorClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_4_0
+GGandivaUInt32SelectionVector *
+ggandiva_uint32_selection_vector_new(gint64 max_slots,
+ GError **error);
+
+
+#define GGANDIVA_TYPE_UINT64_SELECTION_VECTOR \
+ (ggandiva_uint64_selection_vector_get_type())
+G_DECLARE_DERIVABLE_TYPE(GGandivaUInt64SelectionVector,
+ ggandiva_uint64_selection_vector,
+ GGANDIVA,
+ UINT64_SELECTION_VECTOR,
+ GGandivaSelectionVector)
+
+struct _GGandivaUInt64SelectionVectorClass
+{
+ GGandivaSelectionVectorClass parent_class;
+};
+
+GGANDIVA_AVAILABLE_IN_4_0
+GGandivaUInt64SelectionVector *
+ggandiva_uint64_selection_vector_new(gint64 max_slots,
+ GError **error);
+
+
+G_END_DECLS
diff --git a/src/arrow/c_glib/gandiva-glib/selection-vector.hpp b/src/arrow/c_glib/gandiva-glib/selection-vector.hpp
new file mode 100644
index 000000000..aec583141
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/selection-vector.hpp
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include <gandiva/selection_vector.h>
+
+#include <gandiva-glib/selection-vector.h>
+
+GGandivaSelectionVector *
+ggandiva_selection_vector_new_raw(
+ std::shared_ptr<gandiva::SelectionVector> *gandiva_selection_vector);
+std::shared_ptr<gandiva::SelectionVector>
+ggandiva_selection_vector_get_raw(GGandivaSelectionVector *selection_vector);
diff --git a/src/arrow/c_glib/gandiva-glib/version.h.in b/src/arrow/c_glib/gandiva-glib/version.h.in
new file mode 100644
index 000000000..3c9e87c9d
--- /dev/null
+++ b/src/arrow/c_glib/gandiva-glib/version.h.in
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <glib.h>
+
+/**
+ * SECTION: version
+ * @section_id: version-macros
+ * @title: Version related macros
+ * @include: gandiva-glib/gandiva-glib.h
+ *
+ * Gandiva GLib provides macros that can be used by C pre-processor.
+ * They are useful to check version related things at compile time.
+ */
+
+/**
+ * GGANDIVA_VERSION_MAJOR:
+ *
+ * The major version.
+ *
+ * Since: 1.0.0
+ */
+#define GGANDIVA_VERSION_MAJOR (@GGANDIVA_VERSION_MAJOR@)
+
+/**
+ * GGANDIVA_VERSION_MINOR:
+ *
+ * The minor version.
+ *
+ * Since: 1.0.0
+ */
+#define GGANDIVA_VERSION_MINOR (@GGANDIVA_VERSION_MINOR@)
+
+/**
+ * GGANDIVA_VERSION_MICRO:
+ *
+ * The micro version.
+ *
+ * Since: 1.0.0
+ */
+#define GGANDIVA_VERSION_MICRO (@GGANDIVA_VERSION_MICRO@)
+
+/**
+ * GGANDIVA_VERSION_TAG:
+ *
+ * The version tag. Normally, it's an empty string. It's "SNAPSHOT"
+ * for snapshot version.
+ *
+ * Since: 1.0.0
+ */
+#define GGANDIVA_VERSION_TAG "@GGANDIVA_VERSION_TAG@"
+
+/**
+ * GGANDIVA_VERSION_CHECK:
+ * @major: A major version to check for.
+ * @minor: A minor version to check for.
+ * @micro: A micro version to check for.
+ *
+ * You can use this macro in C pre-processor.
+ *
+ * Returns: %TRUE if the compile time Gandiva GLib version is the
+ * same as or newer than the passed version, %FALSE otherwise.
+ *
+ * Since: 1.0.0
+ */
+#define GGANDIVA_VERSION_CHECK(major, minor, micro) \
+ (GGANDIVA_MAJOR_VERSION > (major) || \
+ (GGANDIVA_MAJOR_VERSION == (major) && \
+ GGANDIVA_MINOR_VERSION > (minor)) || \
+ (GGANDIVA_MAJOR_VERSION == (major) && \
+ GGANDIVA_MINOR_VERSION == (minor) && \
+ GGANDIVA_MICRO_VERSION >= (micro)))
+
+/**
+ * GGANDIVA_DISABLE_DEPRECATION_WARNINGS:
+ *
+ * If this macro is defined, no deprecated warnings are produced.
+ *
+ * You must define this macro before including the
+ * gandiva-glib/gandiva-glib.h header.
+ *
+ * Since: 1.0.0
+ */
+
+#ifdef GGANDIVA_DISABLE_DEPRECATION_WARNINGS
+# define GGANDIVA_DEPRECATED
+# define GGANDIVA_DEPRECATED_FOR(function)
+# define GGANDIVA_UNAVAILABLE(major, minor)
+#else
+# define GGANDIVA_DEPRECATED G_DEPRECATED
+# define GGANDIVA_DEPRECATED_FOR(function) G_DEPRECATED_FOR(function)
+# define GGANDIVA_UNAVAILABLE(major, minor) G_UNAVAILABLE(major, minor)
+#endif
+
+/**
+ * GGANDIVA_VERSION_1_0:
+ *
+ * You can use this macro value for compile time API version check.
+ *
+ * Since: 1.0.0
+ */
+#define GGANDIVA_VERSION_1_0 G_ENCODE_VERSION(1, 0)
+
+/**
+ * GGANDIVA_VERSION_4_0:
+ *
+ * You can use this macro value for compile time API version check.
+ *
+ * Since: 4.0.0
+ */
+#define GGANDIVA_VERSION_4_0 G_ENCODE_VERSION(4, 0)
+
+/**
+ * GGANDIVA_VERSION_MIN_REQUIRED:
+ *
+ * You can use this macro for compile time API version check.
+ *
+ * This macro value must be one of the predefined version macros such
+ * as %GGANDIVA_VERSION_1_0.
+ *
+ * If you use any functions that is defined by newer version than
+ * %GGANDIVA_VERSION_MIN_REQUIRED, deprecated warnings are produced at
+ * compile time.
+ *
+ * You must define this macro before including the
+ * gandiva-glib/gandiva-glib.h header.
+ *
+ * Since: 1.0.0
+ */
+#ifndef GGANDIVA_VERSION_MIN_REQUIRED
+# define GGANDIVA_VERSION_MIN_REQUIRED \
+ G_ENCODE_VERSION(GGANDIVA_VERSION_MAJOR, GGANDIVA_VERSION_MINOR)
+#endif
+
+/**
+ * GGANDIVA_VERSION_MAX_ALLOWED:
+ *
+ * You can use this macro for compile time API version check.
+ *
+ * This macro value must be one of the predefined version macros such
+ * as %GGANDIVA_VERSION_1_0.
+ *
+ * If you use any functions that is defined by newer version than
+ * %GGANDIVA_VERSION_MAX_ALLOWED, deprecated warnings are produced at
+ * compile time.
+ *
+ * You must define this macro before including the
+ * gandiva-glib/gandiva-glib.h header.
+ *
+ * Since: 1.0.0
+ */
+#ifndef GGANDIVA_VERSION_MAX_ALLOWED
+# define GGANDIVA_VERSION_MAX_ALLOWED \
+ G_ENCODE_VERSION(GGANDIVA_VERSION_MAJOR, GGANDIVA_VERSION_MINOR)
+#endif
+
+
+#define GGANDIVA_AVAILABLE_IN_ALL
+
+#if GGANDIVA_VERSION_MIN_REQUIRED >= GGANDIVA_VERSION_4_0
+# define GGANDIVA_DEPRECATED_IN_4_0 GGANDIVA_DEPRECATED
+# define GGANDIVA_DEPRECATED_IN_4_0_FOR(function) GGANDIVA_DEPRECATED_FOR(function)
+#else
+# define GGANDIVA_DEPRECATED_IN_4_0
+# define GGANDIVA_DEPRECATED_IN_4_0_FOR(function)
+#endif
+
+#if GGANDIVA_VERSION_MAX_ALLOWED < GGANDIVA_VERSION_4_0
+# define GGANDIVA_AVAILABLE_IN_4_0 GGANDIVA_UNAVAILABLE(4, 0)
+#else
+# define GGANDIVA_AVAILABLE_IN_4_0
+#endif
+
+#if GGANDIVA_VERSION_MIN_REQUIRED >= GGANDIVA_VERSION_1_0
+# define GGANDIVA_DEPRECATED_IN_1_0 GGANDIVA_DEPRECATED
+# define GGANDIVA_DEPRECATED_IN_1_0_FOR(function) GGANDIVA_DEPRECATED_FOR(function)
+#else
+# define GGANDIVA_DEPRECATED_IN_1_0
+# define GGANDIVA_DEPRECATED_IN_1_0_FOR(function)
+#endif
+
+#if GGANDIVA_VERSION_MAX_ALLOWED < GGANDIVA_VERSION_1_0
+# define GGANDIVA_AVAILABLE_IN_1_0 GGANDIVA_UNAVAILABLE(1, 0)
+#else
+# define GGANDIVA_AVAILABLE_IN_1_0
+#endif
+
+#if GGANDIVA_VERSION_MIN_REQUIRED >= GGANDIVA_VERSION_0_17
+# define GGANDIVA_DEPRECATED_IN_0_17 GGANDIVA_DEPRECATED
+# define GGANDIVA_DEPRECATED_IN_0_17_FOR(function) GGANDIVA_DEPRECATED_FOR(function)
+#else
+# define GGANDIVA_DEPRECATED_IN_0_17
+# define GGANDIVA_DEPRECATED_IN_0_17_FOR(function)
+#endif
+
+#if GGANDIVA_VERSION_MAX_ALLOWED < GGANDIVA_VERSION_0_17
+# define GGANDIVA_AVAILABLE_IN_0_17 GGANDIVA_UNAVAILABLE(0, 17)
+#else
+# define GGANDIVA_AVAILABLE_IN_0_17
+#endif