You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2019/01/07 02:32:48 UTC
[arrow] branch master updated: ARROW-4168: [GLib] Use property to
keep GArrowDataType passed in garrow_field_new()
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 1eec9e8 ARROW-4168: [GLib] Use property to keep GArrowDataType passed in garrow_field_new()
1eec9e8 is described below
commit 1eec9e8195716573b04bbe9416d0be2ed3430261
Author: Yosuke Shiro <yo...@gmail.com>
AuthorDate: Mon Jan 7 11:32:35 2019 +0900
ARROW-4168: [GLib] Use property to keep GArrowDataType passed in garrow_field_new()
This is follow-up of https://github.com/apache/arrow/pull/3197#pullrequestreview-186349753
Author: Yosuke Shiro <yo...@gmail.com>
Author: Kouhei Sutou <ko...@clear-code.com>
Closes #3322 from shiro615/glib-use-property-to-keep-data-type and squashes the following commits:
2135b583 <Kouhei Sutou> Remove needless new lines
cc85b1ef <Kouhei Sutou> Fix indent
46844bc1 <Yosuke Shiro> Use {class_name}_data_type to unify argument names
a6af562a <Yosuke Shiro> Reuse GARROW_DATA_TYPE(list_data_type)
77117f08 <Yosuke Shiro> Call g_object_unref() for GArrowDataType
cae21658 <Yosuke Shiro> Use property to keep GArrowDataType in garrow_field_new()
---
c_glib/arrow-glib/column.cpp | 5 +-
c_glib/arrow-glib/composite-data-type.cpp | 99 ++++++++++++++++---------------
c_glib/arrow-glib/composite-data-type.h | 24 ++++----
c_glib/arrow-glib/field.cpp | 67 ++++++++++++---------
c_glib/arrow-glib/field.hpp | 3 +-
c_glib/arrow-glib/schema.cpp | 18 +++++-
c_glib/gandiva-glib/node.cpp | 1 -
7 files changed, 123 insertions(+), 94 deletions(-)
diff --git a/c_glib/arrow-glib/column.cpp b/c_glib/arrow-glib/column.cpp
index e3e964f..68694b3 100644
--- a/c_glib/arrow-glib/column.cpp
+++ b/c_glib/arrow-glib/column.cpp
@@ -322,7 +322,10 @@ garrow_column_get_field(GArrowColumn *column)
} else {
const auto arrow_column = garrow_column_get_raw(column);
auto arrow_field = arrow_column->field();
- return garrow_field_new_raw(&arrow_field);
+ auto data_type = garrow_column_get_data_type(column);
+ auto field = garrow_field_new_raw(&arrow_field, data_type);
+ g_object_unref(data_type);
+ return field;
}
}
diff --git a/c_glib/arrow-glib/composite-data-type.cpp b/c_glib/arrow-glib/composite-data-type.cpp
index 599506f..8046d2e 100644
--- a/c_glib/arrow-glib/composite-data-type.cpp
+++ b/c_glib/arrow-glib/composite-data-type.cpp
@@ -92,15 +92,13 @@ garrow_list_data_type_new(GArrowField *field)
GArrowField *
garrow_list_data_type_get_value_field(GArrowListDataType *list_data_type)
{
- auto arrow_data_type =
- garrow_data_type_get_raw(GARROW_DATA_TYPE(list_data_type));
+ auto data_type = GARROW_DATA_TYPE(list_data_type);
+ auto arrow_data_type = garrow_data_type_get_raw(data_type);
auto arrow_list_data_type =
static_cast<arrow::ListType *>(arrow_data_type.get());
auto arrow_field = arrow_list_data_type->value_field();
- auto field = garrow_field_new_raw(&arrow_field);
-
- return field;
+ return garrow_field_new_raw(&arrow_field, data_type);
}
@@ -143,22 +141,22 @@ garrow_struct_data_type_new(GList *fields)
/**
* garrow_struct_data_type_get_n_fields:
- * @data_type: A #GArrowStructDataType.
+ * @struct_data_type: A #GArrowStructDataType.
*
* Returns: The number of fields of the struct data type.
*
* Since: 0.12.0
*/
gint
-garrow_struct_data_type_get_n_fields(GArrowStructDataType *data_type)
+garrow_struct_data_type_get_n_fields(GArrowStructDataType *struct_data_type)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(struct_data_type));
return arrow_data_type->num_children();
}
/**
* garrow_struct_data_type_get_fields:
- * @data_type: A #GArrowStructDataType.
+ * @struct_data_type: A #GArrowStructDataType.
*
* Returns: (transfer full) (element-type GArrowField):
* The fields of the struct data type.
@@ -166,21 +164,23 @@ garrow_struct_data_type_get_n_fields(GArrowStructDataType *data_type)
* Since: 0.12.0
*/
GList *
-garrow_struct_data_type_get_fields(GArrowStructDataType *data_type)
+garrow_struct_data_type_get_fields(GArrowStructDataType *struct_data_type)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto data_type = GARROW_DATA_TYPE(struct_data_type);
+ auto arrow_data_type = garrow_data_type_get_raw(data_type);
auto arrow_fields = arrow_data_type->children();
GList *fields = NULL;
for (auto arrow_field : arrow_fields) {
- fields = g_list_prepend(fields, garrow_field_new_raw(&arrow_field));
+ fields = g_list_prepend(fields,
+ garrow_field_new_raw(&arrow_field, data_type));
}
return g_list_reverse(fields);
}
/**
* garrow_struct_data_type_get_field:
- * @data_type: A #GArrowStructDataType.
+ * @struct_data_type: A #GArrowStructDataType.
* @i: The index of the target field.
*
* Returns: (transfer full) (nullable):
@@ -189,10 +189,11 @@ garrow_struct_data_type_get_fields(GArrowStructDataType *data_type)
* Since: 0.12.0
*/
GArrowField *
-garrow_struct_data_type_get_field(GArrowStructDataType *data_type,
+garrow_struct_data_type_get_field(GArrowStructDataType *struct_data_type,
gint i)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto data_type = GARROW_DATA_TYPE(struct_data_type);
+ auto arrow_data_type = garrow_data_type_get_raw(data_type);
if (i < 0) {
i += arrow_data_type->num_children();
@@ -206,7 +207,7 @@ garrow_struct_data_type_get_field(GArrowStructDataType *data_type,
auto arrow_field = arrow_data_type->child(i);
if (arrow_field) {
- return garrow_field_new_raw(&arrow_field);
+ return garrow_field_new_raw(&arrow_field, data_type);
} else {
return NULL;
}
@@ -214,7 +215,7 @@ garrow_struct_data_type_get_field(GArrowStructDataType *data_type,
/**
* garrow_struct_data_type_get_field_by_name:
- * @data_type: A #GArrowStructDataType.
+ * @struct_data_type: A #GArrowStructDataType.
* @name: The name of the target field.
*
* Returns: (transfer full) (nullable):
@@ -223,16 +224,17 @@ garrow_struct_data_type_get_field(GArrowStructDataType *data_type,
* Since: 0.12.0
*/
GArrowField *
-garrow_struct_data_type_get_field_by_name(GArrowStructDataType *data_type,
+garrow_struct_data_type_get_field_by_name(GArrowStructDataType *struct_data_type,
const gchar *name)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto data_type = GARROW_DATA_TYPE(struct_data_type);
+ auto arrow_data_type = garrow_data_type_get_raw(data_type);
auto arrow_struct_data_type =
std::static_pointer_cast<arrow::StructType>(arrow_data_type);
auto arrow_field = arrow_struct_data_type->GetFieldByName(name);
if (arrow_field) {
- return garrow_field_new_raw(&arrow_field);
+ return garrow_field_new_raw(&arrow_field, data_type);
} else {
return NULL;
}
@@ -240,7 +242,7 @@ garrow_struct_data_type_get_field_by_name(GArrowStructDataType *data_type,
/**
* garrow_struct_data_type_get_field_index:
- * @data_type: A #GArrowStructDataType.
+ * @struct_data_type: A #GArrowStructDataType.
* @name: The name of the target field.
*
* Returns: The index of the target index in the struct data type
@@ -249,10 +251,10 @@ garrow_struct_data_type_get_field_by_name(GArrowStructDataType *data_type,
* Since: 0.12.0
*/
gint
-garrow_struct_data_type_get_field_index(GArrowStructDataType *data_type,
+garrow_struct_data_type_get_field_index(GArrowStructDataType *struct_data_type,
const gchar *name)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(struct_data_type));
auto arrow_struct_data_type =
std::static_pointer_cast<arrow::StructType>(arrow_data_type);
@@ -276,22 +278,22 @@ garrow_union_data_type_class_init(GArrowUnionDataTypeClass *klass)
/**
* garrow_union_data_type_get_n_fields:
- * @data_type: A #GArrowUnionDataType.
+ * @union_data_type: A #GArrowUnionDataType.
*
* Returns: The number of fields of the union data type.
*
* Since: 0.12.0
*/
gint
-garrow_union_data_type_get_n_fields(GArrowUnionDataType *data_type)
+garrow_union_data_type_get_n_fields(GArrowUnionDataType *union_data_type)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(union_data_type));
return arrow_data_type->num_children();
}
/**
* garrow_union_data_type_get_fields:
- * @data_type: A #GArrowUnionDataType.
+ * @union_data_type: A #GArrowUnionDataType.
*
* Returns: (transfer full) (element-type GArrowField):
* The fields of the union data type.
@@ -299,21 +301,23 @@ garrow_union_data_type_get_n_fields(GArrowUnionDataType *data_type)
* Since: 0.12.0
*/
GList *
-garrow_union_data_type_get_fields(GArrowUnionDataType *data_type)
+garrow_union_data_type_get_fields(GArrowUnionDataType *union_data_type)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto data_type = GARROW_DATA_TYPE(union_data_type);
+ auto arrow_data_type = garrow_data_type_get_raw(data_type);
auto arrow_fields = arrow_data_type->children();
GList *fields = NULL;
for (auto arrow_field : arrow_fields) {
- fields = g_list_prepend(fields, garrow_field_new_raw(&arrow_field));
+ fields = g_list_prepend(fields,
+ garrow_field_new_raw(&arrow_field, data_type));
}
return g_list_reverse(fields);
}
/**
* garrow_union_data_type_get_field:
- * @data_type: A #GArrowUnionDataType.
+ * @union_data_type: A #GArrowUnionDataType.
* @i: The index of the target field.
*
* Returns: (transfer full) (nullable):
@@ -322,10 +326,11 @@ garrow_union_data_type_get_fields(GArrowUnionDataType *data_type)
* Since: 0.12.0
*/
GArrowField *
-garrow_union_data_type_get_field(GArrowUnionDataType *data_type,
- gint i)
+garrow_union_data_type_get_field(GArrowUnionDataType *union_data_type,
+ gint i)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto data_type = GARROW_DATA_TYPE(union_data_type);
+ auto arrow_data_type = garrow_data_type_get_raw(data_type);
if (i < 0) {
i += arrow_data_type->num_children();
@@ -339,7 +344,7 @@ garrow_union_data_type_get_field(GArrowUnionDataType *data_type,
auto arrow_field = arrow_data_type->child(i);
if (arrow_field) {
- return garrow_field_new_raw(&arrow_field);
+ return garrow_field_new_raw(&arrow_field, data_type);
} else {
return NULL;
}
@@ -347,7 +352,7 @@ garrow_union_data_type_get_field(GArrowUnionDataType *data_type,
/**
* garrow_union_data_type_get_type_codes:
- * @data_type: A #GArrowUnionDataType.
+ * @union_data_type: A #GArrowUnionDataType.
* @n_type_codes: (out): The number of type codes.
*
* Returns: (transfer full) (array length=n_type_codes):
@@ -358,10 +363,10 @@ garrow_union_data_type_get_field(GArrowUnionDataType *data_type,
* Since: 0.12.0
*/
guint8 *
-garrow_union_data_type_get_type_codes(GArrowUnionDataType *data_type,
+garrow_union_data_type_get_type_codes(GArrowUnionDataType *union_data_type,
gsize *n_type_codes)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(union_data_type));
auto arrow_union_data_type =
std::static_pointer_cast<arrow::UnionType>(arrow_data_type);
@@ -515,16 +520,16 @@ garrow_dictionary_data_type_new(GArrowDataType *index_data_type,
/**
* garrow_dictionary_data_type_get_index_data_type:
- * @data_type: The #GArrowDictionaryDataType.
+ * @dictionary_data_type: The #GArrowDictionaryDataType.
*
* Returns: (transfer full): The #GArrowDataType of index.
*
* Since: 0.8.0
*/
GArrowDataType *
-garrow_dictionary_data_type_get_index_data_type(GArrowDictionaryDataType *data_type)
+garrow_dictionary_data_type_get_index_data_type(GArrowDictionaryDataType *dictionary_data_type)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(dictionary_data_type));
auto arrow_dictionary_data_type =
std::static_pointer_cast<arrow::DictionaryType>(arrow_data_type);
auto arrow_index_data_type = arrow_dictionary_data_type->index_type();
@@ -533,16 +538,16 @@ garrow_dictionary_data_type_get_index_data_type(GArrowDictionaryDataType *data_t
/**
* garrow_dictionary_data_type_get_dictionary:
- * @data_type: The #GArrowDictionaryDataType.
+ * @dictionary_data_type: The #GArrowDictionaryDataType.
*
* Returns: (transfer full): The dictionary as #GArrowArray.
*
* Since: 0.8.0
*/
GArrowArray *
-garrow_dictionary_data_type_get_dictionary(GArrowDictionaryDataType *data_type)
+garrow_dictionary_data_type_get_dictionary(GArrowDictionaryDataType *dictionary_data_type)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(dictionary_data_type));
auto arrow_dictionary_data_type =
std::static_pointer_cast<arrow::DictionaryType>(arrow_data_type);
auto arrow_dictionary = arrow_dictionary_data_type->dictionary();
@@ -551,16 +556,16 @@ garrow_dictionary_data_type_get_dictionary(GArrowDictionaryDataType *data_type)
/**
* garrow_dictionary_data_type_is_ordered:
- * @data_type: The #GArrowDictionaryDataType.
+ * @dictionary_data_type: The #GArrowDictionaryDataType.
*
* Returns: Whether dictionary contents are ordered or not.
*
* Since: 0.8.0
*/
gboolean
-garrow_dictionary_data_type_is_ordered(GArrowDictionaryDataType *data_type)
+garrow_dictionary_data_type_is_ordered(GArrowDictionaryDataType *dictionary_data_type)
{
- auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(data_type));
+ auto arrow_data_type = garrow_data_type_get_raw(GARROW_DATA_TYPE(dictionary_data_type));
auto arrow_dictionary_data_type =
std::static_pointer_cast<arrow::DictionaryType>(arrow_data_type);
return arrow_dictionary_data_type->ordered();
diff --git a/c_glib/arrow-glib/composite-data-type.h b/c_glib/arrow-glib/composite-data-type.h
index 25e1ac3..f60a9cd 100644
--- a/c_glib/arrow-glib/composite-data-type.h
+++ b/c_glib/arrow-glib/composite-data-type.h
@@ -83,17 +83,17 @@ struct _GArrowStructDataTypeClass
GArrowStructDataType *garrow_struct_data_type_new (GList *fields);
gint
-garrow_struct_data_type_get_n_fields(GArrowStructDataType *data_type);
+garrow_struct_data_type_get_n_fields(GArrowStructDataType *struct_data_type);
GList *
-garrow_struct_data_type_get_fields(GArrowStructDataType *data_type);
+garrow_struct_data_type_get_fields(GArrowStructDataType *struct_data_type);
GArrowField *
-garrow_struct_data_type_get_field(GArrowStructDataType *data_type,
+garrow_struct_data_type_get_field(GArrowStructDataType *struct_data_type,
gint i);
GArrowField *
-garrow_struct_data_type_get_field_by_name(GArrowStructDataType *data_type,
+garrow_struct_data_type_get_field_by_name(GArrowStructDataType *struct_data_type,
const gchar *name);
gint
-garrow_struct_data_type_get_field_index(GArrowStructDataType *data_type,
+garrow_struct_data_type_get_field_index(GArrowStructDataType *struct_data_type,
const gchar *name);
@@ -109,14 +109,14 @@ struct _GArrowUnionDataTypeClass
};
gint
-garrow_union_data_type_get_n_fields(GArrowUnionDataType *data_type);
+garrow_union_data_type_get_n_fields(GArrowUnionDataType *union_data_type);
GList *
-garrow_union_data_type_get_fields(GArrowUnionDataType *data_type);
+garrow_union_data_type_get_fields(GArrowUnionDataType *union_data_type);
GArrowField *
-garrow_union_data_type_get_field(GArrowUnionDataType *data_type,
+garrow_union_data_type_get_field(GArrowUnionDataType *union_data_type,
gint i);
guint8 *
-garrow_union_data_type_get_type_codes(GArrowUnionDataType *data_type,
+garrow_union_data_type_get_type_codes(GArrowUnionDataType *union_data_type,
gsize *n_type_codes);
@@ -172,11 +172,11 @@ garrow_dictionary_data_type_new(GArrowDataType *index_data_type,
GArrowArray *dictionary,
gboolean ordered);
GArrowDataType *
-garrow_dictionary_data_type_get_index_data_type(GArrowDictionaryDataType *data_type);
+garrow_dictionary_data_type_get_index_data_type(GArrowDictionaryDataType *dictionary_data_type);
GArrowArray *
-garrow_dictionary_data_type_get_dictionary(GArrowDictionaryDataType *data_type);
+garrow_dictionary_data_type_get_dictionary(GArrowDictionaryDataType *dictionary_data_type);
gboolean
-garrow_dictionary_data_type_is_ordered(GArrowDictionaryDataType *data_type);
+garrow_dictionary_data_type_is_ordered(GArrowDictionaryDataType *dictionary_data_type);
G_END_DECLS
diff --git a/c_glib/arrow-glib/field.cpp b/c_glib/arrow-glib/field.cpp
index b989d28..d74053a 100644
--- a/c_glib/arrow-glib/field.cpp
+++ b/c_glib/arrow-glib/field.cpp
@@ -37,11 +37,12 @@ G_BEGIN_DECLS
typedef struct GArrowFieldPrivate_ {
std::shared_ptr<arrow::Field> field;
+ GArrowDataType *data_type;
} GArrowFieldPrivate;
enum {
- PROP_0,
- PROP_FIELD
+ PROP_FIELD = 1,
+ PROP_DATA_TYPE
};
G_DEFINE_TYPE_WITH_PRIVATE(GArrowField,
@@ -54,11 +55,22 @@ G_DEFINE_TYPE_WITH_PRIVATE(GArrowField,
GARROW_FIELD(obj)))
static void
-garrow_field_finalize(GObject *object)
+garrow_field_dispose(GObject *object)
{
- GArrowFieldPrivate *priv;
+ auto priv = GARROW_FIELD_GET_PRIVATE(object);
- priv = GARROW_FIELD_GET_PRIVATE(object);
+ if (priv->data_type) {
+ g_object_unref(priv->data_type);
+ priv->data_type = nullptr;
+ }
+
+ G_OBJECT_CLASS(garrow_field_parent_class)->dispose(object);
+}
+
+static void
+garrow_field_finalize(GObject *object)
+{
+ auto priv = GARROW_FIELD_GET_PRIVATE(object);
priv->field = nullptr;
@@ -80,19 +92,9 @@ garrow_field_set_property(GObject *object,
priv->field =
*static_cast<std::shared_ptr<arrow::Field> *>(g_value_get_pointer(value));
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ case PROP_DATA_TYPE:
+ priv->data_type = GARROW_DATA_TYPE(g_value_dup_object(value));
break;
- }
-}
-
-static void
-garrow_field_get_property(GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -107,21 +109,27 @@ garrow_field_init(GArrowField *object)
static void
garrow_field_class_init(GArrowFieldClass *klass)
{
- GObjectClass *gobject_class;
- GParamSpec *spec;
-
- gobject_class = G_OBJECT_CLASS(klass);
+ auto gobject_class = G_OBJECT_CLASS(klass);
+ gobject_class->dispose = garrow_field_dispose;
gobject_class->finalize = garrow_field_finalize;
gobject_class->set_property = garrow_field_set_property;
- gobject_class->get_property = garrow_field_get_property;
+ GParamSpec *spec;
spec = g_param_spec_pointer("field",
"Field",
"The raw std::shared<arrow::Field> *",
static_cast<GParamFlags>(G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(gobject_class, PROP_FIELD, spec);
+
+ spec = g_param_spec_object("data-type",
+ "Data type",
+ "The data type",
+ GARROW_TYPE_DATA_TYPE,
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_DATA_TYPE, spec);
}
/**
@@ -137,7 +145,7 @@ garrow_field_new(const gchar *name,
{
auto arrow_data_type = garrow_data_type_get_raw(data_type);
auto arrow_field = std::make_shared<arrow::Field>(name, arrow_data_type);
- return garrow_field_new_raw(&arrow_field);
+ return garrow_field_new_raw(&arrow_field, data_type);
}
/**
@@ -157,7 +165,7 @@ garrow_field_new_full(const gchar *name,
std::make_shared<arrow::Field>(name,
garrow_data_type_get_raw(data_type),
nullable);
- return garrow_field_new_raw(&arrow_field);
+ return garrow_field_new_raw(&arrow_field, data_type);
}
/**
@@ -177,14 +185,13 @@ garrow_field_get_name(GArrowField *field)
* garrow_field_get_data_type:
* @field: A #GArrowField.
*
- * Returns: (transfer full): The data type of the field.
+ * Returns: (transfer none): The data type of the field.
*/
GArrowDataType *
garrow_field_get_data_type(GArrowField *field)
{
- const auto arrow_field = garrow_field_get_raw(field);
- auto type = arrow_field->type();
- return garrow_data_type_new_raw(&type);
+ auto priv = GARROW_FIELD_GET_PRIVATE(field);
+ return priv->data_type;
}
/**
@@ -233,10 +240,12 @@ garrow_field_to_string(GArrowField *field)
G_END_DECLS
GArrowField *
-garrow_field_new_raw(std::shared_ptr<arrow::Field> *arrow_field)
+garrow_field_new_raw(std::shared_ptr<arrow::Field> *arrow_field,
+ GArrowDataType *data_type)
{
auto field = GARROW_FIELD(g_object_new(GARROW_TYPE_FIELD,
"field", arrow_field,
+ "data-type", data_type,
NULL));
return field;
}
diff --git a/c_glib/arrow-glib/field.hpp b/c_glib/arrow-glib/field.hpp
index e130ad5..f8d0d46 100644
--- a/c_glib/arrow-glib/field.hpp
+++ b/c_glib/arrow-glib/field.hpp
@@ -23,5 +23,6 @@
#include <arrow-glib/field.h>
-GArrowField *garrow_field_new_raw(std::shared_ptr<arrow::Field> *arrow_field);
+GArrowField *garrow_field_new_raw(std::shared_ptr<arrow::Field> *arrow_field,
+ GArrowDataType *data_type);
std::shared_ptr<arrow::Field> garrow_field_get_raw(GArrowField *field);
diff --git a/c_glib/arrow-glib/schema.cpp b/c_glib/arrow-glib/schema.cpp
index 1affaae..6433241 100644
--- a/c_glib/arrow-glib/schema.cpp
+++ b/c_glib/arrow-glib/schema.cpp
@@ -21,6 +21,7 @@
# include <config.h>
#endif
+#include <arrow-glib/basic-data-type.hpp>
#include <arrow-glib/error.hpp>
#include <arrow-glib/field.hpp>
#include <arrow-glib/schema.hpp>
@@ -173,7 +174,11 @@ garrow_schema_get_field(GArrowSchema *schema, guint i)
{
const auto arrow_schema = garrow_schema_get_raw(schema);
auto arrow_field = arrow_schema->field(i);
- return garrow_field_new_raw(&arrow_field);
+ auto arrow_data_type = arrow_field->type();
+ auto data_type = garrow_data_type_new_raw(&arrow_data_type);
+ auto field = garrow_field_new_raw(&arrow_field, data_type);
+ g_object_unref(data_type);
+ return field;
}
/**
@@ -192,7 +197,11 @@ garrow_schema_get_field_by_name(GArrowSchema *schema,
if (arrow_field == nullptr) {
return NULL;
} else {
- return garrow_field_new_raw(&arrow_field);
+ auto arrow_data_type = arrow_field->type();
+ auto data_type = garrow_data_type_new_raw(&arrow_data_type);
+ auto field = garrow_field_new_raw(&arrow_field, data_type);
+ g_object_unref(data_type);
+ return field;
}
}
@@ -223,7 +232,10 @@ garrow_schema_get_fields(GArrowSchema *schema)
GList *fields = NULL;
for (auto arrow_field : arrow_schema->fields()) {
- GArrowField *field = garrow_field_new_raw(&arrow_field);
+ auto arrow_data_type = arrow_field->type();
+ auto data_type = garrow_data_type_new_raw(&arrow_data_type);
+ auto field = garrow_field_new_raw(&arrow_field, data_type);
+ g_object_unref(data_type);
fields = g_list_prepend(fields, field);
}
diff --git a/c_glib/gandiva-glib/node.cpp b/c_glib/gandiva-glib/node.cpp
index 7098365..2c68cbe 100644
--- a/c_glib/gandiva-glib/node.cpp
+++ b/c_glib/gandiva-glib/node.cpp
@@ -1200,7 +1200,6 @@ ggandiva_field_node_new_raw(std::shared_ptr<gandiva::Node> *gandiva_node,
"field", field,
"return-type", return_type,
NULL);
- g_object_unref(return_type);
return GGANDIVA_FIELD_NODE(field_node);
}