You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/03/17 01:09:55 UTC
[8/9] arrow git commit: ARROW-631: [GLib] Import
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/binary-data-type.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/binary-data-type.h b/c_glib/arrow-glib/binary-data-type.h
new file mode 100644
index 0000000..9654fe2
--- /dev/null
+++ b/c_glib/arrow-glib/binary-data-type.h
@@ -0,0 +1,69 @@
+/*
+ * 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/data-type.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_BINARY_DATA_TYPE \
+ (garrow_binary_data_type_get_type())
+#define GARROW_BINARY_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_BINARY_DATA_TYPE, \
+ GArrowBinaryDataType))
+#define GARROW_BINARY_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_BINARY_DATA_TYPE, \
+ GArrowBinaryDataTypeClass))
+#define GARROW_IS_BINARY_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_BINARY_DATA_TYPE))
+#define GARROW_IS_BINARY_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_BINARY_DATA_TYPE))
+#define GARROW_BINARY_DATA_TYPE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_BINARY_DATA_TYPE, \
+ GArrowBinaryDataTypeClass))
+
+typedef struct _GArrowBinaryDataType GArrowBinaryDataType;
+typedef struct _GArrowBinaryDataTypeClass GArrowBinaryDataTypeClass;
+
+/**
+ * GArrowBinaryDataType:
+ *
+ * It wraps `arrow::BinaryType`.
+ */
+struct _GArrowBinaryDataType
+{
+ /*< private >*/
+ GArrowDataType parent_instance;
+};
+
+struct _GArrowBinaryDataTypeClass
+{
+ GArrowDataTypeClass parent_class;
+};
+
+GType garrow_binary_data_type_get_type (void) G_GNUC_CONST;
+GArrowBinaryDataType *garrow_binary_data_type_new (void);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/boolean-array-builder.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/boolean-array-builder.cpp b/c_glib/arrow-glib/boolean-array-builder.cpp
new file mode 100644
index 0000000..1a4c1f9
--- /dev/null
+++ b/c_glib/arrow-glib/boolean-array-builder.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/array-builder.hpp>
+#include <arrow-glib/boolean-array-builder.h>
+#include <arrow-glib/error.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: boolean-array-builder
+ * @short_description: Boolean array builder class
+ *
+ * #GArrowBooleanArrayBuilder is the class to create a new
+ * #GArrowBooleanArray.
+ */
+
+G_DEFINE_TYPE(GArrowBooleanArrayBuilder,
+ garrow_boolean_array_builder,
+ GARROW_TYPE_ARRAY_BUILDER)
+
+static void
+garrow_boolean_array_builder_init(GArrowBooleanArrayBuilder *builder)
+{
+}
+
+static void
+garrow_boolean_array_builder_class_init(GArrowBooleanArrayBuilderClass *klass)
+{
+}
+
+/**
+ * garrow_boolean_array_builder_new:
+ *
+ * Returns: A newly created #GArrowBooleanArrayBuilder.
+ */
+GArrowBooleanArrayBuilder *
+garrow_boolean_array_builder_new(void)
+{
+ auto memory_pool = arrow::default_memory_pool();
+ auto arrow_builder =
+ std::make_shared<arrow::BooleanBuilder>(memory_pool);
+ auto builder =
+ GARROW_BOOLEAN_ARRAY_BUILDER(g_object_new(GARROW_TYPE_BOOLEAN_ARRAY_BUILDER,
+ "array-builder", &arrow_builder,
+ NULL));
+ return builder;
+}
+
+/**
+ * garrow_boolean_array_builder_append:
+ * @builder: A #GArrowBooleanArrayBuilder.
+ * @value: A boolean value.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_boolean_array_builder_append(GArrowBooleanArrayBuilder *builder,
+ gboolean value,
+ GError **error)
+{
+ auto arrow_builder =
+ static_cast<arrow::BooleanBuilder *>(
+ garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
+
+ auto status = arrow_builder->Append(value);
+ if (status.ok()) {
+ return TRUE;
+ } else {
+ garrow_error_set(error, status, "[boolean-array-builder][append]");
+ return FALSE;
+ }
+}
+
+/**
+ * garrow_boolean_array_builder_append_null:
+ * @builder: A #GArrowBooleanArrayBuilder.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_boolean_array_builder_append_null(GArrowBooleanArrayBuilder *builder,
+ GError **error)
+{
+ auto arrow_builder =
+ static_cast<arrow::BooleanBuilder *>(
+ garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
+
+ auto status = arrow_builder->AppendNull();
+ if (status.ok()) {
+ return TRUE;
+ } else {
+ garrow_error_set(error, status, "[boolean-array-builder][append-null]");
+ return FALSE;
+ }
+}
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/boolean-array-builder.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/boolean-array-builder.h b/c_glib/arrow-glib/boolean-array-builder.h
new file mode 100644
index 0000000..ca50e97
--- /dev/null
+++ b/c_glib/arrow-glib/boolean-array-builder.h
@@ -0,0 +1,76 @@
+/*
+ * 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/array-builder.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_BOOLEAN_ARRAY_BUILDER \
+ (garrow_boolean_array_builder_get_type())
+#define GARROW_BOOLEAN_ARRAY_BUILDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_BOOLEAN_ARRAY_BUILDER, \
+ GArrowBooleanArrayBuilder))
+#define GARROW_BOOLEAN_ARRAY_BUILDER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_BOOLEAN_ARRAY_BUILDER, \
+ GArrowBooleanArrayBuilderClass))
+#define GARROW_IS_BOOLEAN_ARRAY_BUILDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_BOOLEAN_ARRAY_BUILDER))
+#define GARROW_IS_BOOLEAN_ARRAY_BUILDER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_BOOLEAN_ARRAY_BUILDER))
+#define GARROW_BOOLEAN_ARRAY_BUILDER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_BOOLEAN_ARRAY_BUILDER, \
+ GArrowBooleanArrayBuilderClass))
+
+typedef struct _GArrowBooleanArrayBuilder GArrowBooleanArrayBuilder;
+typedef struct _GArrowBooleanArrayBuilderClass GArrowBooleanArrayBuilderClass;
+
+/**
+ * GArrowBooleanArrayBuilder:
+ *
+ * It wraps `arrow::BooleanBuilder`.
+ */
+struct _GArrowBooleanArrayBuilder
+{
+ /*< private >*/
+ GArrowArrayBuilder parent_instance;
+};
+
+struct _GArrowBooleanArrayBuilderClass
+{
+ GArrowArrayBuilderClass parent_class;
+};
+
+GType garrow_boolean_array_builder_get_type(void) G_GNUC_CONST;
+
+GArrowBooleanArrayBuilder *garrow_boolean_array_builder_new(void);
+
+gboolean garrow_boolean_array_builder_append(GArrowBooleanArrayBuilder *builder,
+ gboolean value,
+ GError **error);
+gboolean garrow_boolean_array_builder_append_null(GArrowBooleanArrayBuilder *builder,
+ GError **error);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/boolean-array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/boolean-array.cpp b/c_glib/arrow-glib/boolean-array.cpp
new file mode 100644
index 0000000..62fc40f
--- /dev/null
+++ b/c_glib/arrow-glib/boolean-array.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/array.hpp>
+#include <arrow-glib/boolean-array.h>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: boolean-array
+ * @short_description: Boolean array class
+ *
+ * #GArrowBooleanArray is a class for binary array. It can store zero
+ * or more boolean data.
+ *
+ * #GArrowBooleanArray is immutable. You need to use
+ * #GArrowBooleanArrayBuilder to create a new array.
+ */
+
+G_DEFINE_TYPE(GArrowBooleanArray, \
+ garrow_boolean_array, \
+ GARROW_TYPE_ARRAY)
+
+static void
+garrow_boolean_array_init(GArrowBooleanArray *object)
+{
+}
+
+static void
+garrow_boolean_array_class_init(GArrowBooleanArrayClass *klass)
+{
+}
+
+/**
+ * garrow_boolean_array_get_value:
+ * @array: A #GArrowBooleanArray.
+ * @i: The index of the target value.
+ *
+ * Returns: The i-th value.
+ */
+gboolean
+garrow_boolean_array_get_value(GArrowBooleanArray *array,
+ gint64 i)
+{
+ auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
+ return static_cast<arrow::BooleanArray *>(arrow_array.get())->Value(i);
+}
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/boolean-array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/boolean-array.h b/c_glib/arrow-glib/boolean-array.h
new file mode 100644
index 0000000..9899fdf
--- /dev/null
+++ b/c_glib/arrow-glib/boolean-array.h
@@ -0,0 +1,70 @@
+/*
+ * 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/array.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_BOOLEAN_ARRAY \
+ (garrow_boolean_array_get_type())
+#define GARROW_BOOLEAN_ARRAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_BOOLEAN_ARRAY, \
+ GArrowBooleanArray))
+#define GARROW_BOOLEAN_ARRAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_BOOLEAN_ARRAY, \
+ GArrowBooleanArrayClass))
+#define GARROW_IS_BOOLEAN_ARRAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_BOOLEAN_ARRAY))
+#define GARROW_IS_BOOLEAN_ARRAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_BOOLEAN_ARRAY))
+#define GARROW_BOOLEAN_ARRAY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_BOOLEAN_ARRAY, \
+ GArrowBooleanArrayClass))
+
+typedef struct _GArrowBooleanArray GArrowBooleanArray;
+typedef struct _GArrowBooleanArrayClass GArrowBooleanArrayClass;
+
+/**
+ * GArrowBooleanArray:
+ *
+ * It wraps `arrow::BooleanArray`.
+ */
+struct _GArrowBooleanArray
+{
+ /*< private >*/
+ GArrowArray parent_instance;
+};
+
+struct _GArrowBooleanArrayClass
+{
+ GArrowArrayClass parent_class;
+};
+
+GType garrow_boolean_array_get_type (void) G_GNUC_CONST;
+gboolean garrow_boolean_array_get_value (GArrowBooleanArray *array,
+ gint64 i);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/boolean-data-type.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/boolean-data-type.cpp b/c_glib/arrow-glib/boolean-data-type.cpp
new file mode 100644
index 0000000..99c73d9
--- /dev/null
+++ b/c_glib/arrow-glib/boolean-data-type.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/data-type.hpp>
+#include <arrow-glib/boolean-data-type.h>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: boolean-data-type
+ * @short_description: Boolean data type
+ *
+ * #GArrowBooleanDataType is a class for boolean data type.
+ */
+
+G_DEFINE_TYPE(GArrowBooleanDataType, \
+ garrow_boolean_data_type, \
+ GARROW_TYPE_DATA_TYPE)
+
+static void
+garrow_boolean_data_type_init(GArrowBooleanDataType *object)
+{
+}
+
+static void
+garrow_boolean_data_type_class_init(GArrowBooleanDataTypeClass *klass)
+{
+}
+
+/**
+ * garrow_boolean_data_type_new:
+ *
+ * Returns: The newly created boolean data type.
+ */
+GArrowBooleanDataType *
+garrow_boolean_data_type_new(void)
+{
+ auto arrow_data_type = arrow::boolean();
+
+ GArrowBooleanDataType *data_type =
+ GARROW_BOOLEAN_DATA_TYPE(g_object_new(GARROW_TYPE_BOOLEAN_DATA_TYPE,
+ "data-type", &arrow_data_type,
+ NULL));
+ return data_type;
+}
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/boolean-data-type.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/boolean-data-type.h b/c_glib/arrow-glib/boolean-data-type.h
new file mode 100644
index 0000000..ad30c99
--- /dev/null
+++ b/c_glib/arrow-glib/boolean-data-type.h
@@ -0,0 +1,69 @@
+/*
+ * 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/data-type.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_BOOLEAN_DATA_TYPE \
+ (garrow_boolean_data_type_get_type())
+#define GARROW_BOOLEAN_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_BOOLEAN_DATA_TYPE, \
+ GArrowBooleanDataType))
+#define GARROW_BOOLEAN_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_BOOLEAN_DATA_TYPE, \
+ GArrowBooleanDataTypeClass))
+#define GARROW_IS_BOOLEAN_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_BOOLEAN_DATA_TYPE))
+#define GARROW_IS_BOOLEAN_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_BOOLEAN_DATA_TYPE))
+#define GARROW_BOOLEAN_DATA_TYPE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_BOOLEAN_DATA_TYPE, \
+ GArrowBooleanDataTypeClass))
+
+typedef struct _GArrowBooleanDataType GArrowBooleanDataType;
+typedef struct _GArrowBooleanDataTypeClass GArrowBooleanDataTypeClass;
+
+/**
+ * GArrowBooleanDataType:
+ *
+ * It wraps `arrow::BooleanType`.
+ */
+struct _GArrowBooleanDataType
+{
+ /*< private >*/
+ GArrowDataType parent_instance;
+};
+
+struct _GArrowBooleanDataTypeClass
+{
+ GArrowDataTypeClass parent_class;
+};
+
+GType garrow_boolean_data_type_get_type (void) G_GNUC_CONST;
+GArrowBooleanDataType *garrow_boolean_data_type_new (void);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/chunked-array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/chunked-array.cpp b/c_glib/arrow-glib/chunked-array.cpp
new file mode 100644
index 0000000..e732ece
--- /dev/null
+++ b/c_glib/arrow-glib/chunked-array.cpp
@@ -0,0 +1,241 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/array.hpp>
+#include <arrow-glib/chunked-array.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: chunked-array
+ * @short_description: Chunked array class
+ *
+ * #GArrowChunkedArray is a class for chunked array. Chunked array
+ * makes a list of #GArrowArrays one logical large array.
+ */
+
+typedef struct GArrowChunkedArrayPrivate_ {
+ std::shared_ptr<arrow::ChunkedArray> chunked_array;
+} GArrowChunkedArrayPrivate;
+
+enum {
+ PROP_0,
+ PROP_CHUNKED_ARRAY
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowChunkedArray,
+ garrow_chunked_array,
+ G_TYPE_OBJECT)
+
+#define GARROW_CHUNKED_ARRAY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GARROW_TYPE_CHUNKED_ARRAY, \
+ GArrowChunkedArrayPrivate))
+
+static void
+garrow_chunked_array_finalize(GObject *object)
+{
+ GArrowChunkedArrayPrivate *priv;
+
+ priv = GARROW_CHUNKED_ARRAY_GET_PRIVATE(object);
+
+ priv->chunked_array = nullptr;
+
+ G_OBJECT_CLASS(garrow_chunked_array_parent_class)->finalize(object);
+}
+
+static void
+garrow_chunked_array_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GArrowChunkedArrayPrivate *priv;
+
+ priv = GARROW_CHUNKED_ARRAY_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_CHUNKED_ARRAY:
+ priv->chunked_array =
+ *static_cast<std::shared_ptr<arrow::ChunkedArray> *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_chunked_array_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;
+ }
+}
+
+static void
+garrow_chunked_array_init(GArrowChunkedArray *object)
+{
+}
+
+static void
+garrow_chunked_array_class_init(GArrowChunkedArrayClass *klass)
+{
+ GObjectClass *gobject_class;
+ GParamSpec *spec;
+
+ gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = garrow_chunked_array_finalize;
+ gobject_class->set_property = garrow_chunked_array_set_property;
+ gobject_class->get_property = garrow_chunked_array_get_property;
+
+ spec = g_param_spec_pointer("chunked-array",
+ "Chunked array",
+ "The raw std::shared<arrow::ChunkedArray> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_CHUNKED_ARRAY, spec);
+}
+
+/**
+ * garrow_chunked_array_new:
+ * @chunks: (element-type GArrowArray): The array chunks.
+ *
+ * Returns: A newly created #GArrowChunkedArray.
+ */
+GArrowChunkedArray *
+garrow_chunked_array_new(GList *chunks)
+{
+ std::vector<std::shared_ptr<arrow::Array>> arrow_chunks;
+ for (GList *node = chunks; node; node = node->next) {
+ GArrowArray *chunk = GARROW_ARRAY(node->data);
+ arrow_chunks.push_back(garrow_array_get_raw(chunk));
+ }
+
+ auto arrow_chunked_array =
+ std::make_shared<arrow::ChunkedArray>(arrow_chunks);
+ return garrow_chunked_array_new_raw(&arrow_chunked_array);
+}
+
+/**
+ * garrow_chunked_array_get_length:
+ * @chunked_array: A #GArrowChunkedArray.
+ *
+ * Returns: The total number of rows in the chunked array.
+ */
+guint64
+garrow_chunked_array_get_length(GArrowChunkedArray *chunked_array)
+{
+ const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
+ return arrow_chunked_array->length();
+}
+
+/**
+ * garrow_chunked_array_get_n_nulls:
+ * @chunked_array: A #GArrowChunkedArray.
+ *
+ * Returns: The total number of NULL in the chunked array.
+ */
+guint64
+garrow_chunked_array_get_n_nulls(GArrowChunkedArray *chunked_array)
+{
+ const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
+ return arrow_chunked_array->null_count();
+}
+
+/**
+ * garrow_chunked_array_get_n_chunks:
+ * @chunked_array: A #GArrowChunkedArray.
+ *
+ * Returns: The total number of chunks in the chunked array.
+ */
+guint
+garrow_chunked_array_get_n_chunks(GArrowChunkedArray *chunked_array)
+{
+ const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
+ return arrow_chunked_array->num_chunks();
+}
+
+/**
+ * garrow_chunked_array_get_chunk:
+ * @chunked_array: A #GArrowChunkedArray.
+ * @i: The index of the target chunk.
+ *
+ * Returns: (transfer full): The i-th chunk of the chunked array.
+ */
+GArrowArray *
+garrow_chunked_array_get_chunk(GArrowChunkedArray *chunked_array,
+ guint i)
+{
+ const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
+ auto arrow_chunk = arrow_chunked_array->chunk(i);
+ return garrow_array_new_raw(&arrow_chunk);
+}
+
+/**
+ * garrow_chunked_array_get_chunks:
+ * @chunked_array: A #GArrowChunkedArray.
+ *
+ * Returns: (element-type GArrowArray) (transfer full):
+ * The chunks in the chunked array.
+ */
+GList *
+garrow_chunked_array_get_chunks(GArrowChunkedArray *chunked_array)
+{
+ const auto arrow_chunked_array = garrow_chunked_array_get_raw(chunked_array);
+
+ GList *chunks = NULL;
+ for (auto arrow_chunk : arrow_chunked_array->chunks()) {
+ GArrowArray *chunk = garrow_array_new_raw(&arrow_chunk);
+ chunks = g_list_prepend(chunks, chunk);
+ }
+
+ return g_list_reverse(chunks);
+}
+
+G_END_DECLS
+
+GArrowChunkedArray *
+garrow_chunked_array_new_raw(std::shared_ptr<arrow::ChunkedArray> *arrow_chunked_array)
+{
+ auto chunked_array =
+ GARROW_CHUNKED_ARRAY(g_object_new(GARROW_TYPE_CHUNKED_ARRAY,
+ "chunked-array", arrow_chunked_array,
+ NULL));
+ return chunked_array;
+}
+
+std::shared_ptr<arrow::ChunkedArray>
+garrow_chunked_array_get_raw(GArrowChunkedArray *chunked_array)
+{
+ GArrowChunkedArrayPrivate *priv;
+
+ priv = GARROW_CHUNKED_ARRAY_GET_PRIVATE(chunked_array);
+ return priv->chunked_array;
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/chunked-array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/chunked-array.h b/c_glib/arrow-glib/chunked-array.h
new file mode 100644
index 0000000..338930b
--- /dev/null
+++ b/c_glib/arrow-glib/chunked-array.h
@@ -0,0 +1,78 @@
+/*
+ * 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/array.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_CHUNKED_ARRAY \
+ (garrow_chunked_array_get_type())
+#define GARROW_CHUNKED_ARRAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_CHUNKED_ARRAY, \
+ GArrowChunkedArray))
+#define GARROW_CHUNKED_ARRAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_CHUNKED_ARRAY, \
+ GArrowChunkedArrayClass))
+#define GARROW_IS_CHUNKED_ARRAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_CHUNKED_ARRAY))
+#define GARROW_IS_CHUNKED_ARRAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_CHUNKED_ARRAY))
+#define GARROW_CHUNKED_ARRAY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_CHUNKED_ARRAY, \
+ GArrowChunkedArrayClass))
+
+typedef struct _GArrowChunkedArray GArrowChunkedArray;
+typedef struct _GArrowChunkedArrayClass GArrowChunkedArrayClass;
+
+/**
+ * GArrowChunkedArray:
+ *
+ * It wraps `arrow::ChunkedArray`.
+ */
+struct _GArrowChunkedArray
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+struct _GArrowChunkedArrayClass
+{
+ GObjectClass parent_class;
+};
+
+GType garrow_chunked_array_get_type(void) G_GNUC_CONST;
+
+GArrowChunkedArray *garrow_chunked_array_new(GList *chunks);
+
+guint64 garrow_chunked_array_get_length (GArrowChunkedArray *chunked_array);
+guint64 garrow_chunked_array_get_n_nulls(GArrowChunkedArray *chunked_array);
+guint garrow_chunked_array_get_n_chunks (GArrowChunkedArray *chunked_array);
+
+GArrowArray *garrow_chunked_array_get_chunk(GArrowChunkedArray *chunked_array,
+ guint i);
+GList *garrow_chunked_array_get_chunks(GArrowChunkedArray *chunked_array);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/chunked-array.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/chunked-array.hpp b/c_glib/arrow-glib/chunked-array.hpp
new file mode 100644
index 0000000..ec5068a
--- /dev/null
+++ b/c_glib/arrow-glib/chunked-array.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 <arrow/api.h>
+
+#include <arrow-glib/chunked-array.h>
+
+GArrowChunkedArray *garrow_chunked_array_new_raw(std::shared_ptr<arrow::ChunkedArray> *arrow_chunked_array);
+std::shared_ptr<arrow::ChunkedArray> garrow_chunked_array_get_raw(GArrowChunkedArray *chunked_array);
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/column.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/column.cpp b/c_glib/arrow-glib/column.cpp
new file mode 100644
index 0000000..94df640
--- /dev/null
+++ b/c_glib/arrow-glib/column.cpp
@@ -0,0 +1,262 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/array.hpp>
+#include <arrow-glib/chunked-array.hpp>
+#include <arrow-glib/column.hpp>
+#include <arrow-glib/data-type.hpp>
+#include <arrow-glib/field.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: column
+ * @short_description: Column class
+ *
+ * #GArrowColumn is a class for column. Column has a #GArrowField and
+ * zero or more values. Values are #GArrowChunkedArray.
+ */
+
+typedef struct GArrowColumnPrivate_ {
+ std::shared_ptr<arrow::Column> column;
+} GArrowColumnPrivate;
+
+enum {
+ PROP_0,
+ PROP_COLUMN
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowColumn,
+ garrow_column,
+ G_TYPE_OBJECT)
+
+#define GARROW_COLUMN_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GARROW_TYPE_COLUMN, \
+ GArrowColumnPrivate))
+
+static void
+garrow_column_dispose(GObject *object)
+{
+ GArrowColumnPrivate *priv;
+
+ priv = GARROW_COLUMN_GET_PRIVATE(object);
+
+ priv->column = nullptr;
+
+ G_OBJECT_CLASS(garrow_column_parent_class)->dispose(object);
+}
+
+static void
+garrow_column_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GArrowColumnPrivate *priv;
+
+ priv = GARROW_COLUMN_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_COLUMN:
+ priv->column =
+ *static_cast<std::shared_ptr<arrow::Column> *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_column_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;
+ }
+}
+
+static void
+garrow_column_init(GArrowColumn *object)
+{
+}
+
+static void
+garrow_column_class_init(GArrowColumnClass *klass)
+{
+ GObjectClass *gobject_class;
+ GParamSpec *spec;
+
+ gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = garrow_column_dispose;
+ gobject_class->set_property = garrow_column_set_property;
+ gobject_class->get_property = garrow_column_get_property;
+
+ spec = g_param_spec_pointer("column",
+ "Column",
+ "The raw std::shared<arrow::Column> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_COLUMN, spec);
+}
+
+/**
+ * garrow_column_new_array:
+ * @field: The metadata of the column.
+ * @array: The data of the column.
+ *
+ * Returns: A newly created #GArrowColumn.
+ */
+GArrowColumn *
+garrow_column_new_array(GArrowField *field,
+ GArrowArray *array)
+{
+ auto arrow_column =
+ std::make_shared<arrow::Column>(garrow_field_get_raw(field),
+ garrow_array_get_raw(array));
+ return garrow_column_new_raw(&arrow_column);
+}
+
+/**
+ * garrow_column_new_chunked_array:
+ * @field: The metadata of the column.
+ * @chunked_array: The data of the column.
+ *
+ * Returns: A newly created #GArrowColumn.
+ */
+GArrowColumn *
+garrow_column_new_chunked_array(GArrowField *field,
+ GArrowChunkedArray *chunked_array)
+{
+ auto arrow_column =
+ std::make_shared<arrow::Column>(garrow_field_get_raw(field),
+ garrow_chunked_array_get_raw(chunked_array));
+ return garrow_column_new_raw(&arrow_column);
+}
+
+/**
+ * garrow_column_get_length:
+ * @column: A #GArrowColumn.
+ *
+ * Returns: The number of data of the column.
+ */
+guint64
+garrow_column_get_length(GArrowColumn *column)
+{
+ const auto arrow_column = garrow_column_get_raw(column);
+ return arrow_column->length();
+}
+
+/**
+ * garrow_column_get_n_nulls:
+ * @column: A #GArrowColumn.
+ *
+ * Returns: The number of nulls of the column.
+ */
+guint64
+garrow_column_get_n_nulls(GArrowColumn *column)
+{
+ const auto arrow_column = garrow_column_get_raw(column);
+ return arrow_column->null_count();
+}
+
+/**
+ * garrow_column_get_field:
+ * @column: A #GArrowColumn.
+ *
+ * Returns: (transfer full): The metadata of the column.
+ */
+GArrowField *
+garrow_column_get_field(GArrowColumn *column)
+{
+ const auto arrow_column = garrow_column_get_raw(column);
+ auto arrow_field = arrow_column->field();
+ return garrow_field_new_raw(&arrow_field);
+}
+
+/**
+ * garrow_column_get_name:
+ * @column: A #GArrowColumn.
+ *
+ * Returns: The name of the column.
+ */
+const gchar *
+garrow_column_get_name(GArrowColumn *column)
+{
+ const auto arrow_column = garrow_column_get_raw(column);
+ return arrow_column->name().c_str();
+}
+
+/**
+ * garrow_column_get_data_type:
+ * @column: A #GArrowColumn.
+ *
+ * Returns: (transfer full): The data type of the column.
+ */
+GArrowDataType *
+garrow_column_get_data_type(GArrowColumn *column)
+{
+ const auto arrow_column = garrow_column_get_raw(column);
+ auto arrow_data_type = arrow_column->type();
+ return garrow_data_type_new_raw(&arrow_data_type);
+}
+
+/**
+ * garrow_column_get_data:
+ * @column: A #GArrowColumn.
+ *
+ * Returns: (transfer full): The data of the column.
+ */
+GArrowChunkedArray *
+garrow_column_get_data(GArrowColumn *column)
+{
+ const auto arrow_column = garrow_column_get_raw(column);
+ auto arrow_chunked_array = arrow_column->data();
+ return garrow_chunked_array_new_raw(&arrow_chunked_array);
+}
+
+G_END_DECLS
+
+GArrowColumn *
+garrow_column_new_raw(std::shared_ptr<arrow::Column> *arrow_column)
+{
+ auto column = GARROW_COLUMN(g_object_new(GARROW_TYPE_COLUMN,
+ "column", arrow_column,
+ NULL));
+ return column;
+}
+
+std::shared_ptr<arrow::Column>
+garrow_column_get_raw(GArrowColumn *column)
+{
+ GArrowColumnPrivate *priv;
+
+ priv = GARROW_COLUMN_GET_PRIVATE(column);
+ return priv->column;
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/column.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/column.h b/c_glib/arrow-glib/column.h
new file mode 100644
index 0000000..fba3c26
--- /dev/null
+++ b/c_glib/arrow-glib/column.h
@@ -0,0 +1,82 @@
+/*
+ * 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/array.h>
+#include <arrow-glib/chunked-array.h>
+#include <arrow-glib/field.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_COLUMN \
+ (garrow_column_get_type())
+#define GARROW_COLUMN(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_COLUMN, \
+ GArrowColumn))
+#define GARROW_COLUMN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_COLUMN, \
+ GArrowColumnClass))
+#define GARROW_IS_COLUMN(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_COLUMN))
+#define GARROW_IS_COLUMN_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_COLUMN))
+#define GARROW_COLUMN_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_COLUMN, \
+ GArrowColumnClass))
+
+typedef struct _GArrowColumn GArrowColumn;
+typedef struct _GArrowColumnClass GArrowColumnClass;
+
+/**
+ * GArrowColumn:
+ *
+ * It wraps `arrow::Column`.
+ */
+struct _GArrowColumn
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+struct _GArrowColumnClass
+{
+ GObjectClass parent_class;
+};
+
+GType garrow_column_get_type (void) G_GNUC_CONST;
+
+GArrowColumn *garrow_column_new_array(GArrowField *field,
+ GArrowArray *array);
+GArrowColumn *garrow_column_new_chunked_array(GArrowField *field,
+ GArrowChunkedArray *chunked_array);
+
+guint64 garrow_column_get_length (GArrowColumn *column);
+guint64 garrow_column_get_n_nulls (GArrowColumn *column);
+GArrowField *garrow_column_get_field (GArrowColumn *column);
+const gchar *garrow_column_get_name (GArrowColumn *column);
+GArrowDataType *garrow_column_get_data_type (GArrowColumn *column);
+GArrowChunkedArray *garrow_column_get_data (GArrowColumn *column);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/column.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/column.hpp b/c_glib/arrow-glib/column.hpp
new file mode 100644
index 0000000..4ebb742
--- /dev/null
+++ b/c_glib/arrow-glib/column.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 <arrow/api.h>
+
+#include <arrow-glib/column.h>
+
+GArrowColumn *garrow_column_new_raw(std::shared_ptr<arrow::Column> *arrow_column);
+std::shared_ptr<arrow::Column> garrow_column_get_raw(GArrowColumn *column);
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/data-type.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/data-type.cpp b/c_glib/arrow-glib/data-type.cpp
new file mode 100644
index 0000000..2df9e7a
--- /dev/null
+++ b/c_glib/arrow-glib/data-type.cpp
@@ -0,0 +1,260 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/boolean-data-type.h>
+#include <arrow-glib/binary-data-type.h>
+#include <arrow-glib/boolean-data-type.h>
+#include <arrow-glib/data-type.hpp>
+#include <arrow-glib/double-data-type.h>
+#include <arrow-glib/float-data-type.h>
+#include <arrow-glib/int8-data-type.h>
+#include <arrow-glib/int16-data-type.h>
+#include <arrow-glib/int32-data-type.h>
+#include <arrow-glib/int64-data-type.h>
+#include <arrow-glib/list-data-type.h>
+#include <arrow-glib/null-data-type.h>
+#include <arrow-glib/string-data-type.h>
+#include <arrow-glib/struct-data-type.h>
+#include <arrow-glib/type.hpp>
+#include <arrow-glib/uint8-data-type.h>
+#include <arrow-glib/uint16-data-type.h>
+#include <arrow-glib/uint32-data-type.h>
+#include <arrow-glib/uint64-data-type.h>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: data-type
+ * @short_description: Base class for all data type classes
+ *
+ * #GArrowDataType is a base class for all data type classes such as
+ * #GArrowBooleanDataType.
+ */
+
+typedef struct GArrowDataTypePrivate_ {
+ std::shared_ptr<arrow::DataType> data_type;
+} GArrowDataTypePrivate;
+
+enum {
+ PROP_0,
+ PROP_DATA_TYPE
+};
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(GArrowDataType,
+ garrow_data_type,
+ G_TYPE_OBJECT)
+
+#define GARROW_DATA_TYPE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GARROW_TYPE_DATA_TYPE, \
+ GArrowDataTypePrivate))
+
+static void
+garrow_data_type_finalize(GObject *object)
+{
+ GArrowDataTypePrivate *priv;
+
+ priv = GARROW_DATA_TYPE_GET_PRIVATE(object);
+
+ priv->data_type = nullptr;
+
+ G_OBJECT_CLASS(garrow_data_type_parent_class)->finalize(object);
+}
+
+static void
+garrow_data_type_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GArrowDataTypePrivate *priv;
+
+ priv = GARROW_DATA_TYPE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_DATA_TYPE:
+ priv->data_type =
+ *static_cast<std::shared_ptr<arrow::DataType> *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_data_type_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;
+ }
+}
+
+static void
+garrow_data_type_init(GArrowDataType *object)
+{
+}
+
+static void
+garrow_data_type_class_init(GArrowDataTypeClass *klass)
+{
+ GObjectClass *gobject_class;
+ GParamSpec *spec;
+
+ gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = garrow_data_type_finalize;
+ gobject_class->set_property = garrow_data_type_set_property;
+ gobject_class->get_property = garrow_data_type_get_property;
+
+ spec = g_param_spec_pointer("data-type",
+ "DataType",
+ "The raw std::shared<arrow::DataType> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_DATA_TYPE, spec);
+}
+
+/**
+ * garrow_data_type_equal:
+ * @data_type: A #GArrowDataType.
+ * @other_data_type: A #GArrowDataType.
+ *
+ * Returns: Whether they are equal or not.
+ */
+gboolean
+garrow_data_type_equal(GArrowDataType *data_type,
+ GArrowDataType *other_data_type)
+{
+ const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ const auto arrow_other_data_type = garrow_data_type_get_raw(other_data_type);
+ return arrow_data_type->Equals(arrow_other_data_type);
+}
+
+/**
+ * garrow_data_type_to_string:
+ * @data_type: A #GArrowDataType.
+ *
+ * Returns: The string representation of the data type. The caller
+ * must free it by g_free() when the caller doesn't need it anymore.
+ */
+gchar *
+garrow_data_type_to_string(GArrowDataType *data_type)
+{
+ const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ return g_strdup(arrow_data_type->ToString().c_str());
+}
+
+/**
+ * garrow_data_type_type:
+ * @data_type: A #GArrowDataType.
+ *
+ * Returns: The type of the data type.
+ */
+GArrowType
+garrow_data_type_type(GArrowDataType *data_type)
+{
+ const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ return garrow_type_from_raw(arrow_data_type->type);
+}
+
+G_END_DECLS
+
+GArrowDataType *
+garrow_data_type_new_raw(std::shared_ptr<arrow::DataType> *arrow_data_type)
+{
+ GType type;
+ GArrowDataType *data_type;
+
+ switch ((*arrow_data_type)->type) {
+ case arrow::Type::type::NA:
+ type = GARROW_TYPE_NULL_DATA_TYPE;
+ break;
+ case arrow::Type::type::BOOL:
+ type = GARROW_TYPE_BOOLEAN_DATA_TYPE;
+ break;
+ case arrow::Type::type::UINT8:
+ type = GARROW_TYPE_UINT8_DATA_TYPE;
+ break;
+ case arrow::Type::type::INT8:
+ type = GARROW_TYPE_INT8_DATA_TYPE;
+ break;
+ case arrow::Type::type::UINT16:
+ type = GARROW_TYPE_UINT16_DATA_TYPE;
+ break;
+ case arrow::Type::type::INT16:
+ type = GARROW_TYPE_INT16_DATA_TYPE;
+ break;
+ case arrow::Type::type::UINT32:
+ type = GARROW_TYPE_UINT32_DATA_TYPE;
+ break;
+ case arrow::Type::type::INT32:
+ type = GARROW_TYPE_INT32_DATA_TYPE;
+ break;
+ case arrow::Type::type::UINT64:
+ type = GARROW_TYPE_UINT64_DATA_TYPE;
+ break;
+ case arrow::Type::type::INT64:
+ type = GARROW_TYPE_INT64_DATA_TYPE;
+ break;
+ case arrow::Type::type::FLOAT:
+ type = GARROW_TYPE_FLOAT_DATA_TYPE;
+ break;
+ case arrow::Type::type::DOUBLE:
+ type = GARROW_TYPE_DOUBLE_DATA_TYPE;
+ break;
+ case arrow::Type::type::BINARY:
+ type = GARROW_TYPE_BINARY_DATA_TYPE;
+ break;
+ case arrow::Type::type::STRING:
+ type = GARROW_TYPE_STRING_DATA_TYPE;
+ break;
+ case arrow::Type::type::LIST:
+ type = GARROW_TYPE_LIST_DATA_TYPE;
+ break;
+ case arrow::Type::type::STRUCT:
+ type = GARROW_TYPE_STRUCT_DATA_TYPE;
+ break;
+ default:
+ type = GARROW_TYPE_DATA_TYPE;
+ break;
+ }
+ data_type = GARROW_DATA_TYPE(g_object_new(type,
+ "data_type", arrow_data_type,
+ NULL));
+ return data_type;
+}
+
+std::shared_ptr<arrow::DataType>
+garrow_data_type_get_raw(GArrowDataType *data_type)
+{
+ GArrowDataTypePrivate *priv;
+
+ priv = GARROW_DATA_TYPE_GET_PRIVATE(data_type);
+ return priv->data_type;
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/data-type.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/data-type.h b/c_glib/arrow-glib/data-type.h
new file mode 100644
index 0000000..3203d09
--- /dev/null
+++ b/c_glib/arrow-glib/data-type.h
@@ -0,0 +1,72 @@
+/*
+ * 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/type.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_DATA_TYPE \
+ (garrow_data_type_get_type())
+#define GARROW_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_DATA_TYPE, \
+ GArrowDataType))
+#define GARROW_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_DATA_TYPE, \
+ GArrowDataTypeClass))
+#define GARROW_IS_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_DATA_TYPE))
+#define GARROW_IS_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_DATA_TYPE))
+#define GARROW_DATA_TYPE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_DATA_TYPE, \
+ GArrowDataTypeClass))
+
+typedef struct _GArrowDataType GArrowDataType;
+typedef struct _GArrowDataTypeClass GArrowDataTypeClass;
+
+/**
+ * GArrowDataType:
+ *
+ * It wraps `arrow::DataType`.
+ */
+struct _GArrowDataType
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+struct _GArrowDataTypeClass
+{
+ GObjectClass parent_class;
+};
+
+GType garrow_data_type_get_type (void) G_GNUC_CONST;
+gboolean garrow_data_type_equal (GArrowDataType *data_type,
+ GArrowDataType *other_data_type);
+gchar *garrow_data_type_to_string (GArrowDataType *data_type);
+GArrowType garrow_data_type_type (GArrowDataType *data_type);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/data-type.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/data-type.hpp b/c_glib/arrow-glib/data-type.hpp
new file mode 100644
index 0000000..fddcb2e
--- /dev/null
+++ b/c_glib/arrow-glib/data-type.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 <arrow/api.h>
+
+#include <arrow-glib/data-type.h>
+
+GArrowDataType *garrow_data_type_new_raw(std::shared_ptr<arrow::DataType> *arrow_data_type);
+std::shared_ptr<arrow::DataType> garrow_data_type_get_raw(GArrowDataType *data_type);
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/double-array-builder.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/double-array-builder.cpp b/c_glib/arrow-glib/double-array-builder.cpp
new file mode 100644
index 0000000..cc44eea
--- /dev/null
+++ b/c_glib/arrow-glib/double-array-builder.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/array-builder.hpp>
+#include <arrow-glib/double-array-builder.h>
+#include <arrow-glib/error.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: double-array-builder
+ * @short_description: 64-bit floating point array builder class
+ *
+ * #GArrowDoubleArrayBuilder is the class to create a new
+ * #GArrowDoubleArray.
+ */
+
+G_DEFINE_TYPE(GArrowDoubleArrayBuilder,
+ garrow_double_array_builder,
+ GARROW_TYPE_ARRAY_BUILDER)
+
+static void
+garrow_double_array_builder_init(GArrowDoubleArrayBuilder *builder)
+{
+}
+
+static void
+garrow_double_array_builder_class_init(GArrowDoubleArrayBuilderClass *klass)
+{
+}
+
+/**
+ * garrow_double_array_builder_new:
+ *
+ * Returns: A newly created #GArrowDoubleArrayBuilder.
+ */
+GArrowDoubleArrayBuilder *
+garrow_double_array_builder_new(void)
+{
+ auto memory_pool = arrow::default_memory_pool();
+ auto arrow_builder =
+ std::make_shared<arrow::DoubleBuilder>(memory_pool, arrow::float64());
+ auto builder =
+ GARROW_DOUBLE_ARRAY_BUILDER(g_object_new(GARROW_TYPE_DOUBLE_ARRAY_BUILDER,
+ "array-builder", &arrow_builder,
+ NULL));
+ return builder;
+}
+
+/**
+ * garrow_double_array_builder_append:
+ * @builder: A #GArrowDoubleArrayBuilder.
+ * @value: A double value.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_double_array_builder_append(GArrowDoubleArrayBuilder *builder,
+ gdouble value,
+ GError **error)
+{
+ auto arrow_builder =
+ static_cast<arrow::DoubleBuilder *>(
+ garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
+
+ auto status = arrow_builder->Append(value);
+ if (status.ok()) {
+ return TRUE;
+ } else {
+ garrow_error_set(error, status, "[double-array-builder][append]");
+ return FALSE;
+ }
+}
+
+/**
+ * garrow_double_array_builder_append_null:
+ * @builder: A #GArrowDoubleArrayBuilder.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_double_array_builder_append_null(GArrowDoubleArrayBuilder *builder,
+ GError **error)
+{
+ auto arrow_builder =
+ static_cast<arrow::DoubleBuilder *>(
+ garrow_array_builder_get_raw(GARROW_ARRAY_BUILDER(builder)).get());
+
+ auto status = arrow_builder->AppendNull();
+ if (status.ok()) {
+ return TRUE;
+ } else {
+ garrow_error_set(error, status, "[double-array-builder][append-null]");
+ return FALSE;
+ }
+}
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/double-array-builder.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/double-array-builder.h b/c_glib/arrow-glib/double-array-builder.h
new file mode 100644
index 0000000..5d95c89
--- /dev/null
+++ b/c_glib/arrow-glib/double-array-builder.h
@@ -0,0 +1,76 @@
+/*
+ * 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/array-builder.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_DOUBLE_ARRAY_BUILDER \
+ (garrow_double_array_builder_get_type())
+#define GARROW_DOUBLE_ARRAY_BUILDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_DOUBLE_ARRAY_BUILDER, \
+ GArrowDoubleArrayBuilder))
+#define GARROW_DOUBLE_ARRAY_BUILDER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_DOUBLE_ARRAY_BUILDER, \
+ GArrowDoubleArrayBuilderClass))
+#define GARROW_IS_DOUBLE_ARRAY_BUILDER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_DOUBLE_ARRAY_BUILDER))
+#define GARROW_IS_DOUBLE_ARRAY_BUILDER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_DOUBLE_ARRAY_BUILDER))
+#define GARROW_DOUBLE_ARRAY_BUILDER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_DOUBLE_ARRAY_BUILDER, \
+ GArrowDoubleArrayBuilderClass))
+
+typedef struct _GArrowDoubleArrayBuilder GArrowDoubleArrayBuilder;
+typedef struct _GArrowDoubleArrayBuilderClass GArrowDoubleArrayBuilderClass;
+
+/**
+ * GArrowDoubleArrayBuilder:
+ *
+ * It wraps `arrow::DoubleBuilder`.
+ */
+struct _GArrowDoubleArrayBuilder
+{
+ /*< private >*/
+ GArrowArrayBuilder parent_instance;
+};
+
+struct _GArrowDoubleArrayBuilderClass
+{
+ GArrowArrayBuilderClass parent_class;
+};
+
+GType garrow_double_array_builder_get_type(void) G_GNUC_CONST;
+
+GArrowDoubleArrayBuilder *garrow_double_array_builder_new(void);
+
+gboolean garrow_double_array_builder_append(GArrowDoubleArrayBuilder *builder,
+ gdouble value,
+ GError **error);
+gboolean garrow_double_array_builder_append_null(GArrowDoubleArrayBuilder *builder,
+ GError **error);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/double-array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/double-array.cpp b/c_glib/arrow-glib/double-array.cpp
new file mode 100644
index 0000000..ecc55d7
--- /dev/null
+++ b/c_glib/arrow-glib/double-array.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/array.hpp>
+#include <arrow-glib/double-array.h>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: double-array
+ * @short_description: 64-bit floating point array class
+ *
+ * #GArrowDoubleArray is a class for 64-bit floating point array. It
+ * can store zero or more 64-bit floating data.
+ *
+ * #GArrowDoubleArray is immutable. You need to use
+ * #GArrowDoubleArrayBuilder to create a new array.
+ */
+
+G_DEFINE_TYPE(GArrowDoubleArray, \
+ garrow_double_array, \
+ GARROW_TYPE_ARRAY)
+
+static void
+garrow_double_array_init(GArrowDoubleArray *object)
+{
+}
+
+static void
+garrow_double_array_class_init(GArrowDoubleArrayClass *klass)
+{
+}
+
+/**
+ * garrow_double_array_get_value:
+ * @array: A #GArrowDoubleArray.
+ * @i: The index of the target value.
+ *
+ * Returns: The i-th value.
+ */
+gdouble
+garrow_double_array_get_value(GArrowDoubleArray *array,
+ gint64 i)
+{
+ auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
+ return static_cast<arrow::DoubleArray *>(arrow_array.get())->Value(i);
+}
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/double-array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/double-array.h b/c_glib/arrow-glib/double-array.h
new file mode 100644
index 0000000..b9a2365
--- /dev/null
+++ b/c_glib/arrow-glib/double-array.h
@@ -0,0 +1,71 @@
+/*
+ * 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/array.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_DOUBLE_ARRAY \
+ (garrow_double_array_get_type())
+#define GARROW_DOUBLE_ARRAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_DOUBLE_ARRAY, \
+ GArrowDoubleArray))
+#define GARROW_DOUBLE_ARRAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_DOUBLE_ARRAY, \
+ GArrowDoubleArrayClass))
+#define GARROW_IS_DOUBLE_ARRAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_DOUBLE_ARRAY))
+#define GARROW_IS_DOUBLE_ARRAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_DOUBLE_ARRAY))
+#define GARROW_DOUBLE_ARRAY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_DOUBLE_ARRAY, \
+ GArrowDoubleArrayClass))
+
+typedef struct _GArrowDoubleArray GArrowDoubleArray;
+typedef struct _GArrowDoubleArrayClass GArrowDoubleArrayClass;
+
+/**
+ * GArrowDoubleArray:
+ *
+ * It wraps `arrow::DoubleArray`.
+ */
+struct _GArrowDoubleArray
+{
+ /*< private >*/
+ GArrowArray parent_instance;
+};
+
+struct _GArrowDoubleArrayClass
+{
+ GArrowArrayClass parent_class;
+};
+
+GType garrow_double_array_get_type(void) G_GNUC_CONST;
+
+gdouble garrow_double_array_get_value(GArrowDoubleArray *array,
+ gint64 i);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/double-data-type.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/double-data-type.cpp b/c_glib/arrow-glib/double-data-type.cpp
new file mode 100644
index 0000000..c132f97
--- /dev/null
+++ b/c_glib/arrow-glib/double-data-type.cpp
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/data-type.hpp>
+#include <arrow-glib/double-data-type.h>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: double-data-type
+ * @short_description: 64-bit floating point data type
+ *
+ * #GArrowDoubleDataType is a class for 64-bit floating point data
+ * type.
+ */
+
+G_DEFINE_TYPE(GArrowDoubleDataType, \
+ garrow_double_data_type, \
+ GARROW_TYPE_DATA_TYPE)
+
+static void
+garrow_double_data_type_init(GArrowDoubleDataType *object)
+{
+}
+
+static void
+garrow_double_data_type_class_init(GArrowDoubleDataTypeClass *klass)
+{
+}
+
+/**
+ * garrow_double_data_type_new:
+ *
+ * Returns: The newly created 64-bit floating point data type.
+ */
+GArrowDoubleDataType *
+garrow_double_data_type_new(void)
+{
+ auto arrow_data_type = arrow::float64();
+
+ GArrowDoubleDataType *data_type =
+ GARROW_DOUBLE_DATA_TYPE(g_object_new(GARROW_TYPE_DOUBLE_DATA_TYPE,
+ "data-type", &arrow_data_type,
+ NULL));
+ return data_type;
+}
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/double-data-type.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/double-data-type.h b/c_glib/arrow-glib/double-data-type.h
new file mode 100644
index 0000000..ec725cb
--- /dev/null
+++ b/c_glib/arrow-glib/double-data-type.h
@@ -0,0 +1,70 @@
+/*
+ * 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/data-type.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_DOUBLE_DATA_TYPE \
+ (garrow_double_data_type_get_type())
+#define GARROW_DOUBLE_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_DOUBLE_DATA_TYPE, \
+ GArrowDoubleDataType))
+#define GARROW_DOUBLE_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_DOUBLE_DATA_TYPE, \
+ GArrowDoubleDataTypeClass))
+#define GARROW_IS_DOUBLE_DATA_TYPE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_DOUBLE_DATA_TYPE))
+#define GARROW_IS_DOUBLE_DATA_TYPE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_DOUBLE_DATA_TYPE))
+#define GARROW_DOUBLE_DATA_TYPE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_DOUBLE_DATA_TYPE, \
+ GArrowDoubleDataTypeClass))
+
+typedef struct _GArrowDoubleDataType GArrowDoubleDataType;
+typedef struct _GArrowDoubleDataTypeClass GArrowDoubleDataTypeClass;
+
+/**
+ * GArrowDoubleDataType:
+ *
+ * It wraps `arrow::DoubleType`.
+ */
+struct _GArrowDoubleDataType
+{
+ /*< private >*/
+ GArrowDataType parent_instance;
+};
+
+struct _GArrowDoubleDataTypeClass
+{
+ GArrowDataTypeClass parent_class;
+};
+
+GType garrow_double_data_type_get_type(void) G_GNUC_CONST;
+
+GArrowDoubleDataType *garrow_double_data_type_new(void);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/enums.c.template
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/enums.c.template b/c_glib/arrow-glib/enums.c.template
new file mode 100644
index 0000000..6becbd5
--- /dev/null
+++ b/c_glib/arrow-glib/enums.c.template
@@ -0,0 +1,56 @@
+/*** 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/arrow-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 ***/
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/enums.h.template
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/enums.h.template b/c_glib/arrow-glib/enums.h.template
new file mode 100644
index 0000000..3509ed2
--- /dev/null
+++ b/c_glib/arrow-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 <arrow-glib/error.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 ***/
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/error.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/error.cpp b/c_glib/arrow-glib/error.cpp
new file mode 100644
index 0000000..efbc6ae
--- /dev/null
+++ b/c_glib/arrow-glib/error.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow-glib/error.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: error
+ * @title: GArrowError
+ * @short_description: Error code mapping between Arrow and arrow-glib
+ *
+ * #GArrowError provides error codes corresponding to `arrow::Status`
+ * values.
+ */
+
+G_DEFINE_QUARK(garrow-error-quark, garrow_error)
+
+static GArrowError
+garrow_error_code(const arrow::Status &status)
+{
+ switch (status.code()) {
+ case arrow::StatusCode::OK:
+ return GARROW_ERROR_UNKNOWN;
+ case arrow::StatusCode::OutOfMemory:
+ return GARROW_ERROR_OUT_OF_MEMORY;
+ case arrow::StatusCode::KeyError:
+ return GARROW_ERROR_KEY;
+ case arrow::StatusCode::TypeError:
+ return GARROW_ERROR_TYPE;
+ case arrow::StatusCode::Invalid:
+ return GARROW_ERROR_INVALID;
+ case arrow::StatusCode::IOError:
+ return GARROW_ERROR_IO;
+ case arrow::StatusCode::UnknownError:
+ return GARROW_ERROR_UNKNOWN;
+ case arrow::StatusCode::NotImplemented:
+ return GARROW_ERROR_NOT_IMPLEMENTED;
+ default:
+ return GARROW_ERROR_UNKNOWN;
+ }
+}
+
+G_END_DECLS
+
+void
+garrow_error_set(GError **error,
+ const arrow::Status &status,
+ const char *context)
+{
+ if (status.ok()) {
+ return;
+ }
+
+ g_set_error(error,
+ GARROW_ERROR,
+ garrow_error_code(status),
+ "%s: %s",
+ context,
+ status.ToString().c_str());
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/error.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/error.h b/c_glib/arrow-glib/error.h
new file mode 100644
index 0000000..b4a4fac
--- /dev/null
+++ b/c_glib/arrow-glib/error.h
@@ -0,0 +1,54 @@
+/*
+ * 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-object.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GArrowError:
+ * @GARROW_ERROR_OUT_OF_MEMORY: Out of memory error.
+ * @GARROW_ERROR_KEY: Key error.
+ * @GARROW_ERROR_TYPE: Type error.
+ * @GARROW_ERROR_INVALID: Invalid value error.
+ * @GARROW_ERROR_IO: IO error.
+ * @GARROW_ERROR_UNKNOWN: Unknown error.
+ * @GARROW_ERROR_NOT_IMPLEMENTED: The feature is not implemented.
+ *
+ * The error codes are used by all arrow-glib functions.
+ *
+ * They are corresponding to `arrow::Status` values.
+ */
+typedef enum {
+ GARROW_ERROR_OUT_OF_MEMORY = 1,
+ GARROW_ERROR_KEY,
+ GARROW_ERROR_TYPE,
+ GARROW_ERROR_INVALID,
+ GARROW_ERROR_IO,
+ GARROW_ERROR_UNKNOWN = 9,
+ GARROW_ERROR_NOT_IMPLEMENTED = 10
+} GArrowError;
+
+#define GARROW_ERROR garrow_error_quark()
+
+GQuark garrow_error_quark(void);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/39c7274f/c_glib/arrow-glib/error.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/error.hpp b/c_glib/arrow-glib/error.hpp
new file mode 100644
index 0000000..357d293
--- /dev/null
+++ b/c_glib/arrow-glib/error.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 <arrow/api.h>
+
+#include <arrow-glib/error.h>
+
+void garrow_error_set(GError **error,
+ const arrow::Status &status,
+ const char *context);