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
6 changes: 5 additions & 1 deletion c_glib/arrow-glib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ libarrow_glib_la_headers = \
array.h \
array-builder.h \
arrow-glib.h \
basic-data-type.h \
buffer.h \
chunked-array.h \
column.h \
composite-data-type.h \
data-type.h \
error.h \
field.h \
Expand Down Expand Up @@ -83,10 +85,11 @@ libarrow_glib_la_generated_sources = \
libarrow_glib_la_sources = \
array.cpp \
array-builder.cpp \
basic-data-type.cpp \
buffer.cpp \
chunked-array.cpp \
column.cpp \
data-type.cpp \
composite-data-type.cpp \
error.cpp \
field.cpp \
record-batch.cpp \
Expand Down Expand Up @@ -118,6 +121,7 @@ libarrow_glib_la_cpp_headers = \
array.hpp \
array-builder.hpp \
arrow-glib.hpp \
basic-data-type.hpp \
buffer.hpp \
chunked-array.hpp \
column.hpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
G_BEGIN_DECLS

/**
* SECTION: data-type
* @section_id: data-type-classes
* @title: Data type classes
* SECTION: basic-data-type
* @section_id: basic-data-type-classes
* @title: Basic data type classes
* @include: arrow-glib/arrow-glib.h
*
* #GArrowDataType is a base class for all data type classes such as
Expand Down Expand Up @@ -84,10 +84,6 @@ G_BEGIN_DECLS
*
* #GArrowTime64DataType is a class for the number of microseconds or
* nanoseconds since midnight in 64-bit signed integer data type.
*
* #GArrowListDataType is a class for list data type.
*
* #GArrowStructDataType is a class for struct data type.
*/

typedef struct GArrowDataTypePrivate_ {
Expand Down Expand Up @@ -947,100 +943,6 @@ garrow_time64_data_type_new(GArrowTimeUnit unit, GError **error)
return data_type;
}


G_DEFINE_TYPE(GArrowListDataType, \
garrow_list_data_type, \
GARROW_TYPE_DATA_TYPE)

static void
garrow_list_data_type_init(GArrowListDataType *object)
{
}

static void
garrow_list_data_type_class_init(GArrowListDataTypeClass *klass)
{
}

/**
* garrow_list_data_type_new:
* @field: The field of elements
*
* Returns: The newly created list data type.
*/
GArrowListDataType *
garrow_list_data_type_new(GArrowField *field)
{
auto arrow_field = garrow_field_get_raw(field);
auto arrow_data_type =
std::make_shared<arrow::ListType>(arrow_field);

GArrowListDataType *data_type =
GARROW_LIST_DATA_TYPE(g_object_new(GARROW_TYPE_LIST_DATA_TYPE,
"data-type", &arrow_data_type,
NULL));
return data_type;
}

/**
* garrow_list_data_type_get_value_field:
* @list_data_type: A #GArrowListDataType.
*
* Returns: (transfer full): The field of value.
*/
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 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;
}


G_DEFINE_TYPE(GArrowStructDataType, \
garrow_struct_data_type, \
GARROW_TYPE_DATA_TYPE)

static void
garrow_struct_data_type_init(GArrowStructDataType *object)
{
}

static void
garrow_struct_data_type_class_init(GArrowStructDataTypeClass *klass)
{
}

/**
* garrow_struct_data_type_new:
* @fields: (element-type GArrowField): The fields of the struct.
*
* Returns: The newly created struct data type.
*/
GArrowStructDataType *
garrow_struct_data_type_new(GList *fields)
{
std::vector<std::shared_ptr<arrow::Field>> arrow_fields;
for (GList *node = fields; node; node = g_list_next(node)) {
auto field = GARROW_FIELD(node->data);
auto arrow_field = garrow_field_get_raw(field);
arrow_fields.push_back(arrow_field);
}

auto arrow_data_type = std::make_shared<arrow::StructType>(arrow_fields);
GArrowStructDataType *data_type =
GARROW_STRUCT_DATA_TYPE(g_object_new(GARROW_TYPE_STRUCT_DATA_TYPE,
"data-type", &arrow_data_type,
NULL));
return data_type;
}

G_END_DECLS

GArrowDataType *
Expand Down
Loading