Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions c_glib/doc/gandiva-glib/gandiva-glib-docs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
<title>Expression</title>
<xi:include href="xml/expression.xml"/>
</chapter>
<chapter id="filter">
<title>Filter</title>
<xi:include href="xml/filter.xml"/>
</chapter>
<chapter id="selection-vector">
<title>Selection vector</title>
<xi:include href="xml/selection-vector.xml"/>
</chapter>
<chapter id="projector">
<title>Projector</title>
<xi:include href="xml/projector.xml"/>
Expand Down Expand Up @@ -92,6 +100,10 @@
<title>Index of deprecated API</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-4-0-0" role="4.0.0">
<title>Index of new symbols in 4.0.0</title>
<xi:include href="xml/api-index-4.0.0.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-1-0-0" role="1.0.0">
<title>Index of new symbols in 1.0.0</title>
<xi:include href="xml/api-index-1.0.0.xml"><xi:fallback /></xi:include>
Expand Down
58 changes: 58 additions & 0 deletions c_glib/gandiva-glib/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ G_BEGIN_DECLS
* #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
*/

Expand Down Expand Up @@ -217,6 +219,40 @@ ggandiva_expression_to_string(GGandivaExpression *expression)
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 *
Expand All @@ -238,3 +274,25 @@ 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)));
}
23 changes: 21 additions & 2 deletions c_glib/gandiva-glib/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,27 @@ struct _GGandivaExpressionClass
GObjectClass parent_class;
};

GGandivaExpression *ggandiva_expression_new(GGandivaNode *root_node,
GArrowField *result_field);
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
14 changes: 10 additions & 4 deletions c_glib/gandiva-glib/expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@

#include <gandiva-glib/expression.h>

GGandivaExpression
*ggandiva_expression_new_raw(std::shared_ptr<gandiva::Expression> *gandiva_expression,
GGandivaNode *root_node,
GArrowField *result_field);
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);
Loading