arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1462: [GLib] Add GArrowTime32Array and GArrowTime64Array
Date Tue, 05 Sep 2017 23:19:51 GMT
Repository: arrow
Updated Branches:
  refs/heads/master f355354c2 -> 9634f4bd0


ARROW-1462: [GLib] Add GArrowTime32Array and GArrowTime64Array

Author: Kouhei Sutou <kou@clear-code.com>

Closes #1045 from kou/glib-support-time-array and squashes the following commits:

86e2fcab [Kouhei Sutou] [GLib] Add GArrowTime32Array and GArrowTime64Array


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/9634f4bd
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/9634f4bd
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/9634f4bd

Branch: refs/heads/master
Commit: 9634f4bd09791ef369d63626a1184234a199d76d
Parents: f355354
Author: Kouhei Sutou <kou@clear-code.com>
Authored: Tue Sep 5 19:19:46 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Tue Sep 5 19:19:46 2017 -0400

----------------------------------------------------------------------
 c_glib/arrow-glib/array-builder.cpp        | 186 ++++++++++++++++++++
 c_glib/arrow-glib/array-builder.h          | 104 +++++++++++
 c_glib/arrow-glib/array.cpp                | 224 ++++++++++++++++++++++++
 c_glib/arrow-glib/array.h                  | 110 ++++++++++++
 c_glib/arrow-glib/data-type.cpp            | 193 +++++++++++++++++++-
 c_glib/arrow-glib/data-type.h              | 134 ++++++++++++++
 c_glib/arrow-glib/type.cpp                 |  34 ++++
 c_glib/arrow-glib/type.h                   |  16 ++
 c_glib/arrow-glib/type.hpp                 |   2 +
 c_glib/test/helper/buildable.rb            |  45 +++--
 c_glib/test/test-date64-array-data-type.rb |  28 ---
 c_glib/test/test-date64-data-type.rb       |  28 +++
 c_glib/test/test-time32-array.rb           |  69 ++++++++
 c_glib/test/test-time32-data-type.rb       |  51 ++++++
 c_glib/test/test-time64-array.rb           |  57 ++++++
 c_glib/test/test-time64-data-type.rb       |  51 ++++++
 16 files changed, 1282 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/arrow-glib/array-builder.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array-builder.cpp b/c_glib/arrow-glib/array-builder.cpp
index 12c5046..9919bff 100644
--- a/c_glib/arrow-glib/array-builder.cpp
+++ b/c_glib/arrow-glib/array-builder.cpp
@@ -113,6 +113,12 @@ G_BEGIN_DECLS
  * #GArrowDate64ArrayBuilder is the class to create a new
  * #GArrowDate64Array.
  *
+ * #GArrowTime32ArrayBuilder is the class to create a new
+ * #GArrowTime32Array.
+ *
+ * #GArrowTime64ArrayBuilder is the class to create a new
+ * #GArrowTime64Array.
+ *
  * #GArrowListArrayBuilder is the class to create a new
  * #GArrowListArray.
  *
@@ -1308,6 +1314,180 @@ garrow_date64_array_builder_append_null(GArrowDate64ArrayBuilder *builder,
 }
 
 
+G_DEFINE_TYPE(GArrowTime32ArrayBuilder,
+              garrow_time32_array_builder,
+              GARROW_TYPE_ARRAY_BUILDER)
+
+static void
+garrow_time32_array_builder_init(GArrowTime32ArrayBuilder *builder)
+{
+}
+
+static void
+garrow_time32_array_builder_class_init(GArrowTime32ArrayBuilderClass *klass)
+{
+}
+
+/**
+ * garrow_time32_array_builder_new:
+ * @data_type: A #GArrowTime32DataType.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable):
+ *   A newly created #GArrowTime32ArrayBuilder on success, %NULL on error.
+ *
+ * Since: 0.7.0
+ */
+GArrowTime32ArrayBuilder *
+garrow_time32_array_builder_new(GArrowDataType *data_type,
+                                GError **error)
+{
+  if (!GARROW_IS_TIME32_DATA_TYPE(data_type)) {
+    g_set_error(error,
+                GARROW_ERROR,
+                GARROW_ERROR_INVALID,
+                "[time32-array-builder][new] "
+                "data type must be time32 data type: <%s>",
+                G_OBJECT_TYPE_NAME(data_type));
+    return NULL;
+  }
+
+  auto arrow_data_type = garrow_data_type_get_raw(data_type);
+  auto builder = garrow_array_builder_new(arrow_data_type,
+                                          NULL,
+                                          "[time32-array-builder][new]");
+  return GARROW_TIME32_ARRAY_BUILDER(builder);
+}
+
+/**
+ * garrow_time32_array_builder_append:
+ * @builder: A #GArrowTime32ArrayBuilder.
+ * @value: The number of days since UNIX epoch in signed 32bit integer.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ *
+ * Since: 0.7.0
+ */
+gboolean
+garrow_time32_array_builder_append(GArrowTime32ArrayBuilder *builder,
+                                   gint32 value,
+                                   GError **error)
+{
+  return garrow_array_builder_append<arrow::Time32Builder *>
+    (GARROW_ARRAY_BUILDER(builder),
+     value,
+     error,
+     "[time32-array-builder][append]");
+}
+
+/**
+ * garrow_time32_array_builder_append_null:
+ * @builder: A #GArrowTime32ArrayBuilder.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ *
+ * Since: 0.7.0
+ */
+gboolean
+garrow_time32_array_builder_append_null(GArrowTime32ArrayBuilder *builder,
+                                        GError **error)
+{
+  return garrow_array_builder_append_null<arrow::Time32Builder *>
+    (GARROW_ARRAY_BUILDER(builder),
+     error,
+     "[time32-array-builder][append-null]");
+}
+
+
+G_DEFINE_TYPE(GArrowTime64ArrayBuilder,
+              garrow_time64_array_builder,
+              GARROW_TYPE_ARRAY_BUILDER)
+
+static void
+garrow_time64_array_builder_init(GArrowTime64ArrayBuilder *builder)
+{
+}
+
+static void
+garrow_time64_array_builder_class_init(GArrowTime64ArrayBuilderClass *klass)
+{
+}
+
+/**
+ * garrow_time64_array_builder_new:
+ * @data_type: A #GArrowTime64DataType.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable):
+ *   A newly created #GArrowTime64ArrayBuilder on success, %NULL on error.
+ *
+ * Since: 0.7.0
+ */
+GArrowTime64ArrayBuilder *
+garrow_time64_array_builder_new(GArrowDataType *data_type,
+                                GError **error)
+{
+  if (!GARROW_IS_TIME64_DATA_TYPE(data_type)) {
+    g_set_error(error,
+                GARROW_ERROR,
+                GARROW_ERROR_INVALID,
+                "[time64-array-builder][new] "
+                "data type must be time64 data type: <%s>",
+                G_OBJECT_TYPE_NAME(data_type));
+    return NULL;
+  }
+
+  auto arrow_data_type = garrow_data_type_get_raw(data_type);
+  auto builder = garrow_array_builder_new(arrow_data_type,
+                                          NULL,
+                                          "[time64-array-builder][new]");
+  return GARROW_TIME64_ARRAY_BUILDER(builder);
+}
+
+/**
+ * garrow_time64_array_builder_append:
+ * @builder: A #GArrowTime64ArrayBuilder.
+ * @value: The number of milliseconds since UNIX epoch in signed 64bit integer.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ *
+ * Since: 0.7.0
+ */
+gboolean
+garrow_time64_array_builder_append(GArrowTime64ArrayBuilder *builder,
+                                   gint64 value,
+                                   GError **error)
+{
+  return garrow_array_builder_append<arrow::Time64Builder *>
+    (GARROW_ARRAY_BUILDER(builder),
+     value,
+     error,
+     "[time64-array-builder][append]");
+}
+
+/**
+ * garrow_time64_array_builder_append_null:
+ * @builder: A #GArrowTime64ArrayBuilder.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ *
+ * Since: 0.7.0
+ */
+gboolean
+garrow_time64_array_builder_append_null(GArrowTime64ArrayBuilder *builder,
+                                        GError **error)
+{
+  return garrow_array_builder_append_null<arrow::Time64Builder *>
+    (GARROW_ARRAY_BUILDER(builder),
+     error,
+     "[time64-array-builder][append-null]");
+}
+
+
 typedef struct GArrowListArrayBuilderPrivate_ {
   GArrowArrayBuilder *value_builder;
 } GArrowListArrayBuilderPrivate;
@@ -1703,6 +1883,12 @@ garrow_array_builder_new_raw(arrow::ArrayBuilder *arrow_builder,
     case arrow::Type::type::DATE64:
       type = GARROW_TYPE_DATE64_ARRAY_BUILDER;
       break;
+    case arrow::Type::type::TIME32:
+      type = GARROW_TYPE_TIME32_ARRAY_BUILDER;
+      break;
+    case arrow::Type::type::TIME64:
+      type = GARROW_TYPE_TIME64_ARRAY_BUILDER;
+      break;
     case arrow::Type::type::LIST:
       type = GARROW_TYPE_LIST_ARRAY_BUILDER;
       break;

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/arrow-glib/array-builder.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array-builder.h b/c_glib/arrow-glib/array-builder.h
index b6d79a8..981f0bc 100644
--- a/c_glib/arrow-glib/array-builder.h
+++ b/c_glib/arrow-glib/array-builder.h
@@ -884,6 +884,110 @@ gboolean garrow_date64_array_builder_append_null(GArrowDate64ArrayBuilder *build
                                                  GError **error);
 
 
+#define GARROW_TYPE_TIME32_ARRAY_BUILDER        \
+  (garrow_time32_array_builder_get_type())
+#define GARROW_TIME32_ARRAY_BUILDER(obj)                        \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_TIME32_ARRAY_BUILDER, \
+                              GArrowTime32ArrayBuilder))
+#define GARROW_TIME32_ARRAY_BUILDER_CLASS(klass)                \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                             \
+                           GARROW_TYPE_TIME32_ARRAY_BUILDER,    \
+                           GArrowTime32ArrayBuilderClass))
+#define GARROW_IS_TIME32_ARRAY_BUILDER(obj)                             \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                                    \
+                              GARROW_TYPE_TIME32_ARRAY_BUILDER))
+#define GARROW_IS_TIME32_ARRAY_BUILDER_CLASS(klass)             \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
+                           GARROW_TYPE_TIME32_ARRAY_BUILDER))
+#define GARROW_TIME32_ARRAY_BUILDER_GET_CLASS(obj)              \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_TIME32_ARRAY_BUILDER,  \
+                             GArrowTime32ArrayBuilderClass))
+
+typedef struct _GArrowTime32ArrayBuilder         GArrowTime32ArrayBuilder;
+typedef struct _GArrowTime32ArrayBuilderClass    GArrowTime32ArrayBuilderClass;
+
+/**
+ * GArrowTime32ArrayBuilder:
+ *
+ * It wraps `arrow::Time32Builder`.
+ */
+struct _GArrowTime32ArrayBuilder
+{
+  /*< private >*/
+  GArrowArrayBuilder parent_instance;
+};
+
+struct _GArrowTime32ArrayBuilderClass
+{
+  GArrowArrayBuilderClass parent_class;
+};
+
+GType garrow_time32_array_builder_get_type(void) G_GNUC_CONST;
+
+GArrowTime32ArrayBuilder *garrow_time32_array_builder_new(GArrowDataType *data_type,
+                                                          GError **error);
+
+gboolean garrow_time32_array_builder_append(GArrowTime32ArrayBuilder *builder,
+                                            gint32 value,
+                                            GError **error);
+gboolean garrow_time32_array_builder_append_null(GArrowTime32ArrayBuilder *builder,
+                                                 GError **error);
+
+
+#define GARROW_TYPE_TIME64_ARRAY_BUILDER        \
+  (garrow_time64_array_builder_get_type())
+#define GARROW_TIME64_ARRAY_BUILDER(obj)                        \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_TIME64_ARRAY_BUILDER, \
+                              GArrowTime64ArrayBuilder))
+#define GARROW_TIME64_ARRAY_BUILDER_CLASS(klass)                \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                             \
+                           GARROW_TYPE_TIME64_ARRAY_BUILDER,    \
+                           GArrowTime64ArrayBuilderClass))
+#define GARROW_IS_TIME64_ARRAY_BUILDER(obj)                             \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                                    \
+                              GARROW_TYPE_TIME64_ARRAY_BUILDER))
+#define GARROW_IS_TIME64_ARRAY_BUILDER_CLASS(klass)             \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
+                           GARROW_TYPE_TIME64_ARRAY_BUILDER))
+#define GARROW_TIME64_ARRAY_BUILDER_GET_CLASS(obj)              \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_TIME64_ARRAY_BUILDER,  \
+                             GArrowTime64ArrayBuilderClass))
+
+typedef struct _GArrowTime64ArrayBuilder         GArrowTime64ArrayBuilder;
+typedef struct _GArrowTime64ArrayBuilderClass    GArrowTime64ArrayBuilderClass;
+
+/**
+ * GArrowTime64ArrayBuilder:
+ *
+ * It wraps `arrow::Time64Builder`.
+ */
+struct _GArrowTime64ArrayBuilder
+{
+  /*< private >*/
+  GArrowArrayBuilder parent_instance;
+};
+
+struct _GArrowTime64ArrayBuilderClass
+{
+  GArrowArrayBuilderClass parent_class;
+};
+
+GType garrow_time64_array_builder_get_type(void) G_GNUC_CONST;
+
+GArrowTime64ArrayBuilder *garrow_time64_array_builder_new(GArrowDataType *data_type,
+                                                          GError **error);
+
+gboolean garrow_time64_array_builder_append(GArrowTime64ArrayBuilder *builder,
+                                            gint64 value,
+                                            GError **error);
+gboolean garrow_time64_array_builder_append_null(GArrowTime64ArrayBuilder *builder,
+                                                 GError **error);
+
+
 #define GARROW_TYPE_LIST_ARRAY_BUILDER          \
   (garrow_list_array_builder_get_type())
 #define GARROW_LIST_ARRAY_BUILDER(obj)                          \

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/arrow-glib/array.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.cpp b/c_glib/arrow-glib/array.cpp
index d61790f..17553ec 100644
--- a/c_glib/arrow-glib/array.cpp
+++ b/c_glib/arrow-glib/array.cpp
@@ -60,6 +60,28 @@ garrow_primitive_array_new(gint64 length,
   return garrow_array_new_raw(&arrow_array);
 };
 
+template <typename T>
+GArrowArray *
+garrow_primitive_array_new(GArrowDataType *data_type,
+                           gint64 length,
+                           GArrowBuffer *data,
+                           GArrowBuffer *null_bitmap,
+                           gint64 n_nulls)
+{
+  auto arrow_data_type = garrow_data_type_get_raw(data_type);
+  const auto arrow_data = garrow_buffer_get_raw(data);
+  const auto arrow_bitmap = garrow_buffer_get_raw(null_bitmap);
+  auto arrow_specific_array =
+    std::make_shared<typename arrow::TypeTraits<T>::ArrayType>(arrow_data_type,
+                                                               length,
+                                                               arrow_data,
+                                                               arrow_bitmap,
+                                                               n_nulls);
+  auto arrow_array =
+    std::static_pointer_cast<arrow::Array>(arrow_specific_array);
+  return garrow_array_new_raw(&arrow_array);
+};
+
 G_BEGIN_DECLS
 
 /**
@@ -156,6 +178,16 @@ G_BEGIN_DECLS
  * more date data. If you don't have Arrow format data, you need to
  * use #GArrowDate64ArrayBuilder to create a new array.
  *
+ * #GArrowTime32Array is a class for the number of seconds or
+ * milliseconds since midnight in 32-bit signed integer array. It can
+ * store zero or more time data. If you don't have Arrow format data,
+ * you need to use #GArrowTime32ArrayBuilder to create a new array.
+ *
+ * #GArrowTime64Array is a class for the number of microseconds or
+ * nanoseconds since midnight in 64-bit signed integer array. It can
+ * store zero or more time data. If you don't have Arrow format data,
+ * you need to use #GArrowTime64ArrayBuilder to create a new array.
+ *
  * #GArrowListArray is a class for list array. It can store zero or
  * more list data. If you don't have Arrow format data, you need to
  * use #GArrowListArrayBuilder to create a new array.
@@ -1672,6 +1704,192 @@ garrow_date64_array_get_values(GArrowDate64Array *array,
 }
 
 
+G_DEFINE_TYPE(GArrowTime32Array,               \
+              garrow_time32_array,             \
+              GARROW_TYPE_PRIMITIVE_ARRAY)
+
+static void
+garrow_time32_array_init(GArrowTime32Array *object)
+{
+}
+
+static void
+garrow_time32_array_class_init(GArrowTime32ArrayClass *klass)
+{
+}
+
+/**
+ * garrow_time32_array_new:
+ * @data_type: The #GArrowTime32DataType.
+ * @length: The number of elements.
+ * @data: The binary data in Arrow format of the array.
+ * @null_bitmap: (nullable): The bitmap that shows null elements. The
+ *   N-th element is null when the N-th bit is 0, not null otherwise.
+ *   If the array has no null elements, the bitmap must be %NULL and
+ *   @n_nulls is 0.
+ * @n_nulls: The number of null elements. If -1 is specified, the
+ *   number of nulls are computed from @null_bitmap.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable):
+ *   A newly created #GArrowTime32Array on success, %NULL on error.
+ *
+ * Since: 0.7.0
+ */
+GArrowTime32Array *
+garrow_time32_array_new(GArrowDataType *data_type,
+                        gint64 length,
+                        GArrowBuffer *data,
+                        GArrowBuffer *null_bitmap,
+                        gint64 n_nulls,
+                        GError **error)
+{
+  if (!GARROW_IS_TIME32_DATA_TYPE(data_type)) {
+    g_set_error(error,
+                GARROW_ERROR,
+                GARROW_ERROR_INVALID,
+                "[time32-array][new] data type must be time32 data type: <%s>",
+                G_OBJECT_TYPE_NAME(data_type));
+    return NULL;
+  }
+
+  auto array = garrow_primitive_array_new<arrow::Time32Type>(data_type,
+                                                             length,
+                                                             data,
+                                                             null_bitmap,
+                                                             n_nulls);
+  return GARROW_TIME32_ARRAY(array);
+}
+
+/**
+ * garrow_time32_array_get_value:
+ * @array: A #GArrowTime32Array.
+ * @i: The index of the target value.
+ *
+ * Returns: The i-th value.
+ *
+ * Since: 0.7.0
+ */
+gint32
+garrow_time32_array_get_value(GArrowTime32Array *array,
+                              gint64 i)
+{
+  auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
+  return static_cast<arrow::Time32Array *>(arrow_array.get())->Value(i);
+}
+
+/**
+ * garrow_time32_array_get_values:
+ * @array: A #GArrowTime32Array.
+ * @length: (out): The number of values.
+ *
+ * Returns: (array length=length): The raw values.
+ *
+ * Since: 0.7.0
+ */
+const gint32 *
+garrow_time32_array_get_values(GArrowTime32Array *array,
+                               gint64 *length)
+{
+  auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
+  return garrow_array_get_values_raw<arrow::Time32Type>(arrow_array, length);
+}
+
+
+G_DEFINE_TYPE(GArrowTime64Array,               \
+              garrow_time64_array,             \
+              GARROW_TYPE_PRIMITIVE_ARRAY)
+
+static void
+garrow_time64_array_init(GArrowTime64Array *object)
+{
+}
+
+static void
+garrow_time64_array_class_init(GArrowTime64ArrayClass *klass)
+{
+}
+
+/**
+ * garrow_time64_array_new:
+ * @data_type: The #GArrowTime64DataType.
+ * @length: The number of elements.
+ * @data: The binary data in Arrow format of the array.
+ * @null_bitmap: (nullable): The bitmap that shows null elements. The
+ *   N-th element is null when the N-th bit is 0, not null otherwise.
+ *   If the array has no null elements, the bitmap must be %NULL and
+ *   @n_nulls is 0.
+ * @n_nulls: The number of null elements. If -1 is specified, the
+ *   number of nulls are computed from @null_bitmap.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable):
+ *   A newly created #GArrowTime64Array on success, %NULL on error.
+ *
+ * Since: 0.7.0
+ */
+GArrowTime64Array *
+garrow_time64_array_new(GArrowDataType *data_type,
+                        gint64 length,
+                        GArrowBuffer *data,
+                        GArrowBuffer *null_bitmap,
+                        gint64 n_nulls,
+                        GError **error)
+{
+  if (!GARROW_IS_TIME64_DATA_TYPE(data_type)) {
+    g_set_error(error,
+                GARROW_ERROR,
+                GARROW_ERROR_INVALID,
+                "[time64-array][new] data type must be time64 data type: <%s>",
+                G_OBJECT_TYPE_NAME(data_type));
+    return NULL;
+  }
+
+  auto array = garrow_primitive_array_new<arrow::Time64Type>(data_type,
+                                                             length,
+                                                             data,
+                                                             null_bitmap,
+                                                             n_nulls);
+  return GARROW_TIME64_ARRAY(array);
+}
+
+/**
+ * garrow_time64_array_get_value:
+ * @array: A #GArrowTime64Array.
+ * @i: The index of the target value.
+ *
+ * Returns: The i-th value.
+ *
+ * Since: 0.7.0
+ */
+gint64
+garrow_time64_array_get_value(GArrowTime64Array *array,
+                              gint64 i)
+{
+  auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
+  return static_cast<arrow::Time64Array *>(arrow_array.get())->Value(i);
+}
+
+/**
+ * garrow_time64_array_get_values:
+ * @array: A #GArrowTime64Array.
+ * @length: (out): The number of values.
+ *
+ * Returns: (array length=length): The raw values.
+ *
+ * Since: 0.7.0
+ */
+const gint64 *
+garrow_time64_array_get_values(GArrowTime64Array *array,
+                               gint64 *length)
+{
+  auto arrow_array = garrow_array_get_raw(GARROW_ARRAY(array));
+  auto values =
+    garrow_array_get_values_raw<arrow::Time64Type>(arrow_array, length);
+  return reinterpret_cast<const gint64 *>(values);
+}
+
+
 G_DEFINE_TYPE(GArrowListArray,               \
               garrow_list_array,             \
               GARROW_TYPE_ARRAY)
@@ -1917,6 +2135,12 @@ garrow_array_new_raw(std::shared_ptr<arrow::Array> *arrow_array)
   case arrow::Type::type::DATE64:
     type = GARROW_TYPE_DATE64_ARRAY;
     break;
+  case arrow::Type::type::TIME32:
+    type = GARROW_TYPE_TIME32_ARRAY;
+    break;
+  case arrow::Type::type::TIME64:
+    type = GARROW_TYPE_TIME64_ARRAY;
+    break;
   case arrow::Type::type::LIST:
     type = GARROW_TYPE_LIST_ARRAY;
     break;

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/arrow-glib/array.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/array.h b/c_glib/arrow-glib/array.h
index 851c8ea..9aaca47 100644
--- a/c_glib/arrow-glib/array.h
+++ b/c_glib/arrow-glib/array.h
@@ -966,6 +966,116 @@ const gint64 *garrow_date64_array_get_values(GArrowDate64Array *array,
                                              gint64 *length);
 
 
+#define GARROW_TYPE_TIME32_ARRAY                \
+  (garrow_time32_array_get_type())
+#define GARROW_TIME32_ARRAY(obj)                        \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                    \
+                              GARROW_TYPE_TIME32_ARRAY, \
+                              GArrowTime32Array))
+#define GARROW_TIME32_ARRAY_CLASS(klass)                \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                     \
+                           GARROW_TYPE_TIME32_ARRAY,    \
+                           GArrowTime32ArrayClass))
+#define GARROW_IS_TIME32_ARRAY(obj)                             \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_TIME32_ARRAY))
+#define GARROW_IS_TIME32_ARRAY_CLASS(klass)             \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                     \
+                           GARROW_TYPE_TIME32_ARRAY))
+#define GARROW_TIME32_ARRAY_GET_CLASS(obj)              \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                     \
+                             GARROW_TYPE_TIME32_ARRAY,  \
+                             GArrowTime32ArrayClass))
+
+typedef struct _GArrowTime32Array         GArrowTime32Array;
+typedef struct _GArrowTime32ArrayClass    GArrowTime32ArrayClass;
+
+/**
+ * GArrowTime32Array:
+ *
+ * It wraps `arrow::Time32Array`.
+ */
+struct _GArrowTime32Array
+{
+  /*< private >*/
+  GArrowPrimitiveArray parent_instance;
+};
+
+struct _GArrowTime32ArrayClass
+{
+  GArrowPrimitiveArrayClass parent_class;
+};
+
+GType garrow_time32_array_get_type(void) G_GNUC_CONST;
+
+GArrowTime32Array *garrow_time32_array_new(GArrowDataType *data_type,
+                                           gint64 length,
+                                           GArrowBuffer *data,
+                                           GArrowBuffer *null_bitmap,
+                                           gint64 n_nulls,
+                                           GError **error);
+
+gint32 garrow_time32_array_get_value(GArrowTime32Array *array,
+                                     gint64 i);
+const gint32 *garrow_time32_array_get_values(GArrowTime32Array *array,
+                                             gint64 *length);
+
+
+#define GARROW_TYPE_TIME64_ARRAY                \
+  (garrow_time64_array_get_type())
+#define GARROW_TIME64_ARRAY(obj)                        \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                    \
+                              GARROW_TYPE_TIME64_ARRAY, \
+                              GArrowTime64Array))
+#define GARROW_TIME64_ARRAY_CLASS(klass)                \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                     \
+                           GARROW_TYPE_TIME64_ARRAY,    \
+                           GArrowTime64ArrayClass))
+#define GARROW_IS_TIME64_ARRAY(obj)                             \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_TIME64_ARRAY))
+#define GARROW_IS_TIME64_ARRAY_CLASS(klass)             \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                     \
+                           GARROW_TYPE_TIME64_ARRAY))
+#define GARROW_TIME64_ARRAY_GET_CLASS(obj)              \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                     \
+                             GARROW_TYPE_TIME64_ARRAY,  \
+                             GArrowTime64ArrayClass))
+
+typedef struct _GArrowTime64Array         GArrowTime64Array;
+typedef struct _GArrowTime64ArrayClass    GArrowTime64ArrayClass;
+
+/**
+ * GArrowTime64Array:
+ *
+ * It wraps `arrow::Time64Array`.
+ */
+struct _GArrowTime64Array
+{
+  /*< private >*/
+  GArrowPrimitiveArray parent_instance;
+};
+
+struct _GArrowTime64ArrayClass
+{
+  GArrowPrimitiveArrayClass parent_class;
+};
+
+GType garrow_time64_array_get_type(void) G_GNUC_CONST;
+
+GArrowTime64Array *garrow_time64_array_new(GArrowDataType *data_type,
+                                           gint64 length,
+                                           GArrowBuffer *data,
+                                           GArrowBuffer *null_bitmap,
+                                           gint64 n_nulls,
+                                           GError **error);
+
+gint64 garrow_time64_array_get_value(GArrowTime64Array *array,
+                                     gint64 i);
+const gint64 *garrow_time64_array_get_values(GArrowTime64Array *array,
+                                             gint64 *length);
+
+
 #define GARROW_TYPE_LIST_ARRAY                  \
   (garrow_list_array_get_type())
 #define GARROW_LIST_ARRAY(obj)                          \

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/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
index 7cacf6a..c2c7461 100644
--- a/c_glib/arrow-glib/data-type.cpp
+++ b/c_glib/arrow-glib/data-type.cpp
@@ -22,6 +22,8 @@
 #endif
 
 #include <arrow-glib/data-type.hpp>
+#include <arrow-glib/enums.h>
+#include <arrow-glib/error.hpp>
 #include <arrow-glib/field.hpp>
 #include <arrow-glib/type.hpp>
 
@@ -67,12 +69,18 @@ G_BEGIN_DECLS
  * #GArrowStringDataType is a class for UTF-8 encoded string data
  * type.
  *
- * #GArrowData32DataType is a class for the number of days since UNIX
+ * #GArrowDate32DataType is a class for the number of days since UNIX
  * epoch in 32-bit signed integer data type.
  *
- * #GArrowData64DataType is a class for the number of milliseconds
+ * #GArrowDate64DataType is a class for the number of milliseconds
  * since UNIX epoch in 64-bit signed integer data type.
  *
+ * #GArrowTime32DataType is a class for the number of seconds or
+ * milliseconds since midnight in 32-bit signed integer data type.
+ *
+ * #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.
@@ -677,7 +685,8 @@ garrow_date32_data_type_class_init(GArrowDate32DataTypeClass *klass)
 /**
  * garrow_date32_data_type_new:
  *
- * Returns: The newly created 64-bit floating point data type.
+ * Returns: A newly created the number of milliseconds
+ *   since UNIX epoch in 32-bit signed integer data type.
  *
  * Since: 0.7.0
  */
@@ -711,7 +720,8 @@ garrow_date64_data_type_class_init(GArrowDate64DataTypeClass *klass)
 /**
  * garrow_date64_data_type_new:
  *
- * Returns: The newly created 64-bit floating point data type.
+ * Returns: A newly created the number of milliseconds
+ *   since UNIX epoch in 64-bit signed integer data type.
  *
  * Since: 0.7.0
  */
@@ -728,6 +738,175 @@ garrow_date64_data_type_new(void)
 }
 
 
+G_DEFINE_TYPE(GArrowTimeDataType,               \
+              garrow_time_data_type,            \
+              GARROW_TYPE_DATA_TYPE)
+
+static void
+garrow_time_data_type_init(GArrowTimeDataType *object)
+{
+}
+
+static void
+garrow_time_data_type_class_init(GArrowTimeDataTypeClass *klass)
+{
+}
+
+/**
+ * garrow_time_data_type_get_unit:
+ * @time_data_type: The #GArrowTimeDataType.
+ *
+ * Returns: The unit of the time data type.
+ *
+ * Since: 0.7.0
+ */
+GArrowTimeUnit
+garrow_time_data_type_get_unit(GArrowTimeDataType *time_data_type)
+{
+  const auto arrow_data_type =
+    garrow_data_type_get_raw(GARROW_DATA_TYPE(time_data_type));
+  const auto arrow_time_data_type =
+    std::static_pointer_cast<arrow::TimeType>(arrow_data_type);
+  return garrow_time_unit_from_raw(arrow_time_data_type->unit());
+}
+
+
+G_DEFINE_TYPE(GArrowTime32DataType,                \
+              garrow_time32_data_type,             \
+              GARROW_TYPE_TIME_DATA_TYPE)
+
+static void
+garrow_time32_data_type_init(GArrowTime32DataType *object)
+{
+}
+
+static void
+garrow_time32_data_type_class_init(GArrowTime32DataTypeClass *klass)
+{
+}
+
+/**
+ * garrow_time32_data_type_new:
+ * @unit: %GARROW_TIME_UNIT_SECOND or %GARROW_TIME_UNIT_MILLI.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable):
+ *   A newly created the number of seconds or milliseconds since
+ *   midnight in 32-bit signed integer data type.
+ *
+ * Since: 0.7.0
+ */
+GArrowTime32DataType *
+garrow_time32_data_type_new(GArrowTimeUnit unit, GError **error)
+{
+  switch (unit) {
+  case GARROW_TIME_UNIT_SECOND:
+  case GARROW_TIME_UNIT_MILLI:
+    break;
+  default:
+    {
+      auto enum_class = G_ENUM_CLASS(g_type_class_ref(GARROW_TYPE_TIME_UNIT));
+      GEnumValue *value = g_enum_get_value(enum_class, unit);
+      if (value) {
+        g_set_error(error,
+                    GARROW_ERROR,
+                    GARROW_ERROR_INVALID,
+                    "[time32-data-type][new] time unit must be second or milli: "
+                    "<%s>",
+                    value->value_nick);
+      } else {
+        g_set_error(error,
+                    GARROW_ERROR,
+                    GARROW_ERROR_INVALID,
+                    "[time32-data-type][new] "
+                    "time unit must be second(%d) or milli(%d): <%d>",
+                    GARROW_TIME_UNIT_SECOND,
+                    GARROW_TIME_UNIT_MILLI,
+                    unit);
+      }
+      g_type_class_unref(enum_class);
+    }
+    return NULL;
+  }
+
+  auto arrow_unit = garrow_time_unit_to_raw(unit);
+  auto arrow_data_type = arrow::time32(arrow_unit);
+  auto data_type =
+    GARROW_TIME32_DATA_TYPE(g_object_new(GARROW_TYPE_TIME32_DATA_TYPE,
+                                         "data-type", &arrow_data_type,
+                                         NULL));
+  return data_type;
+}
+
+
+G_DEFINE_TYPE(GArrowTime64DataType,                \
+              garrow_time64_data_type,             \
+              GARROW_TYPE_TIME_DATA_TYPE)
+
+static void
+garrow_time64_data_type_init(GArrowTime64DataType *object)
+{
+}
+
+static void
+garrow_time64_data_type_class_init(GArrowTime64DataTypeClass *klass)
+{
+}
+
+/**
+ * garrow_time64_data_type_new:
+ * @unit: %GARROW_TIME_UNIT_SECOND or %GARROW_TIME_UNIT_MILLI.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable):
+ *   A newly created the number of seconds or milliseconds since
+ *   midnight in 64-bit signed integer data type.
+ *
+ * Since: 0.7.0
+ */
+GArrowTime64DataType *
+garrow_time64_data_type_new(GArrowTimeUnit unit, GError **error)
+{
+  switch (unit) {
+  case GARROW_TIME_UNIT_MICRO:
+  case GARROW_TIME_UNIT_NANO:
+    break;
+  default:
+    {
+      auto enum_class = G_ENUM_CLASS(g_type_class_ref(GARROW_TYPE_TIME_UNIT));
+      auto value = g_enum_get_value(enum_class, unit);
+      if (value) {
+        g_set_error(error,
+                    GARROW_ERROR,
+                    GARROW_ERROR_INVALID,
+                    "[time64-data-type][new] time unit must be micro or nano: "
+                    "<%s>",
+                    value->value_nick);
+      } else {
+        g_set_error(error,
+                    GARROW_ERROR,
+                    GARROW_ERROR_INVALID,
+                    "[time64-data-type][new] "
+                    "time unit must be micro(%d) or nano(%d): <%d>",
+                    GARROW_TIME_UNIT_MICRO,
+                    GARROW_TIME_UNIT_NANO,
+                    unit);
+      }
+      g_type_class_unref(enum_class);
+    }
+    return NULL;
+  }
+
+  auto arrow_unit = garrow_time_unit_to_raw(unit);
+  auto arrow_data_type = arrow::time64(arrow_unit);
+  auto data_type =
+    GARROW_TIME64_DATA_TYPE(g_object_new(GARROW_TYPE_TIME64_DATA_TYPE,
+                                         "data-type", &arrow_data_type,
+                                         NULL));
+  return data_type;
+}
+
+
 G_DEFINE_TYPE(GArrowListDataType,                \
               garrow_list_data_type,             \
               GARROW_TYPE_DATA_TYPE)
@@ -878,6 +1057,12 @@ garrow_data_type_new_raw(std::shared_ptr<arrow::DataType> *arrow_data_type)
   case arrow::Type::type::DATE64:
     type = GARROW_TYPE_DATE64_DATA_TYPE;
     break;
+  case arrow::Type::type::TIME32:
+    type = GARROW_TYPE_TIME32_DATA_TYPE;
+    break;
+  case arrow::Type::type::TIME64:
+    type = GARROW_TYPE_TIME64_DATA_TYPE;
+    break;
   case arrow::Type::type::LIST:
     type = GARROW_TYPE_LIST_DATA_TYPE;
     break;

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/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
index 5a0d2bc..c01201d 100644
--- a/c_glib/arrow-glib/data-type.h
+++ b/c_glib/arrow-glib/data-type.h
@@ -780,6 +780,140 @@ GType                 garrow_date64_data_type_get_type (void) G_GNUC_CONST;
 GArrowDate64DataType *garrow_date64_data_type_new      (void);
 
 
+#define GARROW_TYPE_TIME_DATA_TYPE              \
+  (garrow_time_data_type_get_type())
+#define GARROW_TIME_DATA_TYPE(obj)                              \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_TIME_DATA_TYPE,       \
+                              GArrowTimeDataType))
+#define GARROW_TIME_DATA_TYPE_CLASS(klass)              \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                     \
+                           GARROW_TYPE_TIME_DATA_TYPE,  \
+                           GArrowTimeDataTypeClass))
+#define GARROW_IS_TIME_DATA_TYPE(obj)                           \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_TIME_DATA_TYPE))
+#define GARROW_IS_TIME_DATA_TYPE_CLASS(klass)           \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                     \
+                           GARROW_TYPE_TIME_DATA_TYPE))
+#define GARROW_TIME_DATA_TYPE_GET_CLASS(obj)                    \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_TIME_DATA_TYPE,        \
+                             GArrowTimeDataTypeClass))
+
+typedef struct _GArrowTimeDataType         GArrowTimeDataType;
+typedef struct _GArrowTimeDataTypeClass    GArrowTimeDataTypeClass;
+
+/**
+ * GArrowTimeDataType:
+ *
+ * It wraps `arrow::TimeType`.
+ */
+struct _GArrowTimeDataType
+{
+  /*< private >*/
+  GArrowDataType parent_instance;
+};
+
+struct _GArrowTimeDataTypeClass
+{
+  GArrowDataTypeClass parent_class;
+};
+
+GType          garrow_time_data_type_get_type (void) G_GNUC_CONST;
+GArrowTimeUnit garrow_time_data_type_get_unit (GArrowTimeDataType *time_data_type);
+
+
+#define GARROW_TYPE_TIME32_DATA_TYPE           \
+  (garrow_time32_data_type_get_type())
+#define GARROW_TIME32_DATA_TYPE(obj)                            \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_TIME32_DATA_TYPE,     \
+                              GArrowTime32DataType))
+#define GARROW_TIME32_DATA_TYPE_CLASS(klass)                    \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                             \
+                           GARROW_TYPE_TIME32_DATA_TYPE,        \
+                           GArrowTime32DataTypeClass))
+#define GARROW_IS_TIME32_DATA_TYPE(obj)                         \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_TIME32_DATA_TYPE))
+#define GARROW_IS_TIME32_DATA_TYPE_CLASS(klass)                 \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
+                           GARROW_TYPE_TIME32_DATA_TYPE))
+#define GARROW_TIME32_DATA_TYPE_GET_CLASS(obj)                  \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_TIME32_DATA_TYPE,      \
+                             GArrowTime32DataTypeClass))
+
+typedef struct _GArrowTime32DataType         GArrowTime32DataType;
+typedef struct _GArrowTime32DataTypeClass    GArrowTime32DataTypeClass;
+
+/**
+ * GArrowTime32DataType:
+ *
+ * It wraps `arrow::Time32Type`.
+ */
+struct _GArrowTime32DataType
+{
+  /*< private >*/
+  GArrowTimeDataType parent_instance;
+};
+
+struct _GArrowTime32DataTypeClass
+{
+  GArrowTimeDataTypeClass parent_class;
+};
+
+GType                 garrow_time32_data_type_get_type (void) G_GNUC_CONST;
+GArrowTime32DataType *garrow_time32_data_type_new      (GArrowTimeUnit unit,
+                                                        GError **error);
+
+
+#define GARROW_TYPE_TIME64_DATA_TYPE           \
+  (garrow_time64_data_type_get_type())
+#define GARROW_TIME64_DATA_TYPE(obj)                            \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_TIME64_DATA_TYPE,     \
+                              GArrowTime64DataType))
+#define GARROW_TIME64_DATA_TYPE_CLASS(klass)                    \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                             \
+                           GARROW_TYPE_TIME64_DATA_TYPE,        \
+                           GArrowTime64DataTypeClass))
+#define GARROW_IS_TIME64_DATA_TYPE(obj)                         \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_TIME64_DATA_TYPE))
+#define GARROW_IS_TIME64_DATA_TYPE_CLASS(klass)                 \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
+                           GARROW_TYPE_TIME64_DATA_TYPE))
+#define GARROW_TIME64_DATA_TYPE_GET_CLASS(obj)                  \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_TIME64_DATA_TYPE,      \
+                             GArrowTime64DataTypeClass))
+
+typedef struct _GArrowTime64DataType         GArrowTime64DataType;
+typedef struct _GArrowTime64DataTypeClass    GArrowTime64DataTypeClass;
+
+/**
+ * GArrowTime64DataType:
+ *
+ * It wraps `arrow::Time64Type`.
+ */
+struct _GArrowTime64DataType
+{
+  /*< private >*/
+  GArrowTimeDataType parent_instance;
+};
+
+struct _GArrowTime64DataTypeClass
+{
+  GArrowTimeDataTypeClass parent_class;
+};
+
+GType                 garrow_time64_data_type_get_type (void) G_GNUC_CONST;
+GArrowTime64DataType *garrow_time64_data_type_new      (GArrowTimeUnit unit,
+                                                        GError **error);
+
+
 #define GARROW_TYPE_LIST_DATA_TYPE              \
   (garrow_list_data_type_get_type())
 #define GARROW_LIST_DATA_TYPE(obj)                              \

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/arrow-glib/type.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/type.cpp b/c_glib/arrow-glib/type.cpp
index 8adbaa9..68ebc96 100644
--- a/c_glib/arrow-glib/type.cpp
+++ b/c_glib/arrow-glib/type.cpp
@@ -92,3 +92,37 @@ garrow_type_from_raw(arrow::Type::type type)
     return GARROW_TYPE_NA;
   }
 }
+
+GArrowTimeUnit
+garrow_time_unit_from_raw(arrow::TimeUnit::type unit)
+{
+  switch (unit) {
+  case arrow::TimeUnit::type::SECOND:
+    return GARROW_TIME_UNIT_SECOND;
+  case arrow::TimeUnit::type::MILLI:
+    return GARROW_TIME_UNIT_MILLI;
+  case arrow::TimeUnit::type::MICRO:
+    return GARROW_TIME_UNIT_MICRO;
+  case arrow::TimeUnit::type::NANO:
+    return GARROW_TIME_UNIT_NANO;
+  default:
+    return GARROW_TIME_UNIT_SECOND;
+  }
+}
+
+arrow::TimeUnit::type
+garrow_time_unit_to_raw(GArrowTimeUnit unit)
+{
+  switch (unit) {
+  case GARROW_TIME_UNIT_SECOND:
+    return arrow::TimeUnit::type::SECOND;
+  case GARROW_TIME_UNIT_MILLI:
+    return arrow::TimeUnit::type::MILLI;
+  case GARROW_TIME_UNIT_MICRO:
+    return arrow::TimeUnit::type::MICRO;
+  case GARROW_TIME_UNIT_NANO:
+    return arrow::TimeUnit::type::NANO;
+  default:
+    return arrow::TimeUnit::type::SECOND;
+  }
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/arrow-glib/type.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/type.h b/c_glib/arrow-glib/type.h
index e171aa3..65d2895 100644
--- a/c_glib/arrow-glib/type.h
+++ b/c_glib/arrow-glib/type.h
@@ -85,4 +85,20 @@ typedef enum {
   GARROW_TYPE_DICTIONARY
 } GArrowType;
 
+/**
+ * GArrowTimeUnit:
+ * @GARROW_TIME_UNIT_SECOND: Second.
+ * @GARROW_TIME_UNIT_MILLISECOND: Millisecond.
+ * @GARROW_TIME_UNIT_MICRO: Microsecond.
+ * @GARROW_TIME_UNIT_NANO: Nanosecond.
+ *
+ * They are corresponding to `arrow::TimeUnit::type` values.
+ */
+typedef enum {
+  GARROW_TIME_UNIT_SECOND,
+  GARROW_TIME_UNIT_MILLI,
+  GARROW_TIME_UNIT_MICRO,
+  GARROW_TIME_UNIT_NANO
+} GArrowTimeUnit;
+
 G_END_DECLS

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/arrow-glib/type.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/type.hpp b/c_glib/arrow-glib/type.hpp
index 2a452be..6f65697 100644
--- a/c_glib/arrow-glib/type.hpp
+++ b/c_glib/arrow-glib/type.hpp
@@ -24,3 +24,5 @@
 #include <arrow-glib/type.h>
 
 GArrowType garrow_type_from_raw(arrow::Type::type type);
+GArrowTimeUnit garrow_time_unit_from_raw(arrow::TimeUnit::type unit);
+arrow::TimeUnit::type garrow_time_unit_to_raw(GArrowTimeUnit unit);

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/test/helper/buildable.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/helper/buildable.rb b/c_glib/test/helper/buildable.rb
index d51503e..cb427d7 100644
--- a/c_glib/test/helper/buildable.rb
+++ b/c_glib/test/helper/buildable.rb
@@ -18,67 +18,77 @@
 module Helper
   module Buildable
     def build_boolean_array(values)
-      build_array(Arrow::BooleanArrayBuilder, values)
+      build_array(Arrow::BooleanArrayBuilder.new, values)
     end
 
     def build_int_array(values)
-      build_array(Arrow::IntArrayBuilder, values)
+      build_array(Arrow::IntArrayBuilder.new, values)
     end
 
     def build_int8_array(values)
-      build_array(Arrow::Int8ArrayBuilder, values)
+      build_array(Arrow::Int8ArrayBuilder.new, values)
     end
 
     def build_uint8_array(values)
-      build_array(Arrow::UInt8ArrayBuilder, values)
+      build_array(Arrow::UInt8ArrayBuilder.new, values)
     end
 
     def build_int16_array(values)
-      build_array(Arrow::Int16ArrayBuilder, values)
+      build_array(Arrow::Int16ArrayBuilder.new, values)
     end
 
     def build_uint16_array(values)
-      build_array(Arrow::UInt16ArrayBuilder, values)
+      build_array(Arrow::UInt16ArrayBuilder.new, values)
     end
 
     def build_int32_array(values)
-      build_array(Arrow::Int32ArrayBuilder, values)
+      build_array(Arrow::Int32ArrayBuilder.new, values)
     end
 
     def build_uint32_array(values)
-      build_array(Arrow::UInt32ArrayBuilder, values)
+      build_array(Arrow::UInt32ArrayBuilder.new, values)
     end
 
     def build_int64_array(values)
-      build_array(Arrow::Int64ArrayBuilder, values)
+      build_array(Arrow::Int64ArrayBuilder.new, values)
     end
 
     def build_uint64_array(values)
-      build_array(Arrow::UInt64ArrayBuilder, values)
+      build_array(Arrow::UInt64ArrayBuilder.new, values)
     end
 
     def build_float_array(values)
-      build_array(Arrow::FloatArrayBuilder, values)
+      build_array(Arrow::FloatArrayBuilder.new, values)
     end
 
     def build_double_array(values)
-      build_array(Arrow::DoubleArrayBuilder, values)
+      build_array(Arrow::DoubleArrayBuilder.new, values)
     end
 
     def build_date32_array(values)
-      build_array(Arrow::Date32ArrayBuilder, values)
+      build_array(Arrow::Date32ArrayBuilder.new, values)
     end
 
     def build_date64_array(values)
-      build_array(Arrow::Date64ArrayBuilder, values)
+      build_array(Arrow::Date64ArrayBuilder.new, values)
+    end
+
+    def build_time32_array(unit, values)
+      build_array(Arrow::Time32ArrayBuilder.new(Arrow::Time32DataType.new(unit)),
+                  values)
+    end
+
+    def build_time64_array(unit, values)
+      build_array(Arrow::Time64ArrayBuilder.new(Arrow::Time64DataType.new(unit)),
+                  values)
     end
 
     def build_binary_array(values)
-      build_array(Arrow::BinaryArrayBuilder, values)
+      build_array(Arrow::BinaryArrayBuilder.new, values)
     end
 
     def build_string_array(values)
-      build_array(Arrow::StringArrayBuilder, values)
+      build_array(Arrow::StringArrayBuilder.new, values)
     end
 
     def build_list_array(value_data_type, values_list)
@@ -126,8 +136,7 @@ module Helper
     end
 
     private
-    def build_array(builder_class, values)
-      builder = builder_class.new
+    def build_array(builder, values)
       values.each do |value|
         if value.nil?
           builder.append_null

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/test/test-date64-array-data-type.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-date64-array-data-type.rb b/c_glib/test/test-date64-array-data-type.rb
deleted file mode 100644
index 7999cd8..0000000
--- a/c_glib/test/test-date64-array-data-type.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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.
-
-class TestDate64DataType < Test::Unit::TestCase
-  def test_type
-    data_type = Arrow::Date64DataType.new
-    assert_equal(Arrow::Type::DATE64, data_type.id)
-  end
-
-  def test_to_s
-    data_type = Arrow::Date64DataType.new
-    assert_equal("date64[ms]", data_type.to_s)
-  end
-end

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/test/test-date64-data-type.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-date64-data-type.rb b/c_glib/test/test-date64-data-type.rb
new file mode 100644
index 0000000..7999cd8
--- /dev/null
+++ b/c_glib/test/test-date64-data-type.rb
@@ -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.
+
+class TestDate64DataType < Test::Unit::TestCase
+  def test_type
+    data_type = Arrow::Date64DataType.new
+    assert_equal(Arrow::Type::DATE64, data_type.id)
+  end
+
+  def test_to_s
+    data_type = Arrow::Date64DataType.new
+    assert_equal("date64[ms]", data_type.to_s)
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/test/test-time32-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-time32-array.rb b/c_glib/test/test-time32-array.rb
new file mode 100644
index 0000000..b648c69
--- /dev/null
+++ b/c_glib/test/test-time32-array.rb
@@ -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.
+
+class TestTime32Array < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_new
+    midnight = 0
+    after_midnight = 60 * 10 # 00:10:00
+    raw_data = [midnight, after_midnight]
+    data_type = Arrow::Time32DataType.new(:second)
+    assert_equal(build_time32_array(:second, [*raw_data, nil]),
+                 Arrow::Time32Array.new(data_type,
+                                        3,
+                                        Arrow::Buffer.new(raw_data.pack("l*")),
+                                        Arrow::Buffer.new([0b011].pack("C*")),
+                                        -1))
+  end
+
+  def test_buffer
+    midnight = 0
+    after_midnight = 60 * 10 # 00:10:00
+    raw_data = [midnight, after_midnight]
+    array = build_time32_array(:second, raw_data)
+    assert_equal(raw_data.pack("l*"),
+                 array.buffer.data.to_s)
+  end
+
+  def test_value
+    after_midnight = 60 * 10 # 00:10:00
+    array = build_time32_array(:second, [after_midnight])
+    assert_equal(after_midnight, array.get_value(0))
+  end
+
+  def test_values
+    midnight = 0
+    after_midnight = 60 * 10 # 00:10:00
+    raw_data = [midnight, after_midnight]
+    array = build_time32_array(:second, raw_data)
+    assert_equal(raw_data, array.values)
+  end
+
+  sub_test_case("unit") do
+    def test_second
+      array = build_time32_array(:second, [])
+      assert_equal(Arrow::TimeUnit::SECOND, array.value_data_type.unit)
+    end
+
+    def test_milli
+      array = build_time32_array(:milli, [])
+      assert_equal(Arrow::TimeUnit::MILLI, array.value_data_type.unit)
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/test/test-time32-data-type.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-time32-data-type.rb b/c_glib/test/test-time32-data-type.rb
new file mode 100644
index 0000000..df3b58b
--- /dev/null
+++ b/c_glib/test/test-time32-data-type.rb
@@ -0,0 +1,51 @@
+# 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.
+
+class TestTime32DataType < Test::Unit::TestCase
+  def test_type
+    data_type = Arrow::Time32DataType.new(:second)
+    assert_equal(Arrow::Type::TIME32, data_type.id)
+  end
+
+  def test_invalid_unit
+    message =
+      "[time32-data-type][new] time unit must be second or milli: <micro>"
+    assert_raise(Arrow::Error::Invalid.new(message)) do
+      Arrow::Time32DataType.new(:micro)
+    end
+  end
+
+  sub_test_case("second") do
+    def setup
+      @data_type = Arrow::Time32DataType.new(:second)
+    end
+
+    def test_to_s
+      assert_equal("time32[s]", @data_type.to_s)
+    end
+  end
+
+  sub_test_case("milli") do
+    def setup
+      @data_type = Arrow::Time32DataType.new(:milli)
+    end
+
+    def test_to_s
+      assert_equal("time32[ms]", @data_type.to_s)
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/test/test-time64-array.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-time64-array.rb b/c_glib/test/test-time64-array.rb
new file mode 100644
index 0000000..775d315
--- /dev/null
+++ b/c_glib/test/test-time64-array.rb
@@ -0,0 +1,57 @@
+# 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.
+
+class TestTime64Array < Test::Unit::TestCase
+  include Helper::Buildable
+  include Helper::Omittable
+
+  def test_new
+    midnight = 0
+    after_midnight = 60 * 10 * 1000 * 1000 # 00:10:00.000000
+    raw_data = [midnight, after_midnight]
+    data_type = Arrow::Time64DataType.new(:micro)
+    assert_equal(build_time64_array(:micro, [*raw_data, nil]),
+                 Arrow::Time64Array.new(data_type,
+                                        3,
+                                        Arrow::Buffer.new(raw_data.pack("q*")),
+                                        Arrow::Buffer.new([0b011].pack("C*")),
+                                        -1))
+  end
+
+  def test_buffer
+    midnight = 0
+    after_midnight = 60 * 10 * 1000 * 1000 # 00:10:00.000000
+    raw_data = [midnight, after_midnight]
+    array = build_time64_array(:micro, raw_data)
+    assert_equal(raw_data.pack("q*"),
+                 array.buffer.data.to_s)
+  end
+
+  def test_value
+    after_midnight = 60 * 10 * 1000 * 1000 # 00:10:00.000000
+    array = build_time64_array(:micro, [after_midnight])
+    assert_equal(after_midnight, array.get_value(0))
+  end
+
+  def test_values
+    midnight = 0
+    after_midnight = 60 * 10 * 1000 * 1000 # 00:10:00.000000
+    raw_data = [midnight, after_midnight]
+    array = build_time64_array(:micro, raw_data)
+    assert_equal(raw_data, array.values)
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/9634f4bd/c_glib/test/test-time64-data-type.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-time64-data-type.rb b/c_glib/test/test-time64-data-type.rb
new file mode 100644
index 0000000..32e3051
--- /dev/null
+++ b/c_glib/test/test-time64-data-type.rb
@@ -0,0 +1,51 @@
+# 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.
+
+class TestTime64DataType < Test::Unit::TestCase
+  def test_type
+    data_type = Arrow::Time64DataType.new(:micro)
+    assert_equal(Arrow::Type::TIME64, data_type.id)
+  end
+
+  def test_invalid_unit
+    message =
+      "[time64-data-type][new] time unit must be micro or nano: <second>"
+    assert_raise(Arrow::Error::Invalid.new(message)) do
+      Arrow::Time64DataType.new(:second)
+    end
+  end
+
+  sub_test_case("micro") do
+    def setup
+      @data_type = Arrow::Time64DataType.new(:micro)
+    end
+
+    def test_to_s
+      assert_equal("time64[us]", @data_type.to_s)
+    end
+  end
+
+  sub_test_case("nano") do
+    def setup
+      @data_type = Arrow::Time64DataType.new(:nano)
+    end
+
+    def test_to_s
+      assert_equal("time64[ns]", @data_type.to_s)
+    end
+  end
+end


Mime
View raw message