Repository: arrow
Updated Branches:
  refs/heads/master 03dce9dca -> 14bec24c5


ARROW-908: [GLib] Unify OutputStream files

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

Closes #609 from kou/glib-unify-output-stream and squashes the following 
commits:

f62f869 [Kouhei Sutou] [GLib] Unify OutputStream files


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

Branch: refs/heads/master
Commit: 14bec24c584dc6fa05b84b6ed00d7474d62fd1d7
Parents: 03dce9d
Author: Kouhei Sutou <k...@clear-code.com>
Authored: Thu Apr 27 18:13:47 2017 +0200
Committer: Uwe L. Korn <uw...@xhochy.com>
Committed: Thu Apr 27 18:13:47 2017 +0200

----------------------------------------------------------------------
 c_glib/arrow-glib/Makefile.am             |   3 -
 c_glib/arrow-glib/arrow-glib.h            |   1 -
 c_glib/arrow-glib/arrow-glib.hpp          |   1 -
 c_glib/arrow-glib/file-output-stream.cpp  | 231 -------------------------
 c_glib/arrow-glib/file-output-stream.h    |  72 --------
 c_glib/arrow-glib/file-output-stream.hpp  |  28 ---
 c_glib/arrow-glib/output-stream.cpp       | 201 ++++++++++++++++++++-
 c_glib/arrow-glib/output-stream.h         |  52 ++++++
 c_glib/arrow-glib/output-stream.hpp       |   5 +-
 c_glib/doc/reference/arrow-glib-docs.sgml |   3 +-
 10 files changed, 256 insertions(+), 341 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/Makefile.am
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/Makefile.am b/c_glib/arrow-glib/Makefile.am
index bbc1101..54fb7f8 100644
--- a/c_glib/arrow-glib/Makefile.am
+++ b/c_glib/arrow-glib/Makefile.am
@@ -59,7 +59,6 @@ libarrow_glib_la_headers =                    \
 libarrow_glib_la_headers +=                    \
        file.h                                  \
        file-mode.h                             \
-       file-output-stream.h                    \
        input-stream.h                          \
        memory-mapped-file.h                    \
        output-stream.h                         \
@@ -102,7 +101,6 @@ libarrow_glib_la_sources =                  \
 libarrow_glib_la_sources +=                    \
        file.cpp                                \
        file-mode.cpp                           \
-       file-output-stream.cpp                  \
        input-stream.cpp                        \
        memory-mapped-file.cpp                  \
        output-stream.cpp                       \
@@ -137,7 +135,6 @@ libarrow_glib_la_cpp_headers =                      \
 libarrow_glib_la_cpp_headers +=                        \
        file.hpp                                \
        file-mode.hpp                           \
-       file-output-stream.hpp                  \
        input-stream.hpp                        \
        memory-mapped-file.hpp                  \
        output-stream.hpp                       \

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/arrow-glib.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/arrow-glib.h b/c_glib/arrow-glib/arrow-glib.h
index efff571..e88b66b 100644
--- a/c_glib/arrow-glib/arrow-glib.h
+++ b/c_glib/arrow-glib/arrow-glib.h
@@ -35,7 +35,6 @@
 
 #include <arrow-glib/file.h>
 #include <arrow-glib/file-mode.h>
-#include <arrow-glib/file-output-stream.h>
 #include <arrow-glib/input-stream.h>
 #include <arrow-glib/memory-mapped-file.h>
 #include <arrow-glib/output-stream.h>

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/arrow-glib.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/arrow-glib.hpp b/c_glib/arrow-glib/arrow-glib.hpp
index d6ef370..339773f 100644
--- a/c_glib/arrow-glib/arrow-glib.hpp
+++ b/c_glib/arrow-glib/arrow-glib.hpp
@@ -40,7 +40,6 @@
 
 #include <arrow-glib/file.hpp>
 #include <arrow-glib/file-mode.hpp>
-#include <arrow-glib/file-output-stream.hpp>
 #include <arrow-glib/input-stream.hpp>
 #include <arrow-glib/memory-mapped-file.hpp>
 #include <arrow-glib/output-stream.hpp>

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/file-output-stream.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-output-stream.cpp 
b/c_glib/arrow-glib/file-output-stream.cpp
deleted file mode 100644
index e1e1e27..0000000
--- a/c_glib/arrow-glib/file-output-stream.cpp
+++ /dev/null
@@ -1,231 +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.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <arrow/io/file.h>
-
-#include <arrow-glib/error.hpp>
-#include <arrow-glib/file.hpp>
-#include <arrow-glib/file-output-stream.hpp>
-#include <arrow-glib/output-stream.hpp>
-#include <arrow-glib/writeable.hpp>
-
-G_BEGIN_DECLS
-
-/**
- * SECTION: file-output-stream
- * @short_description: A file output stream.
- *
- * The #GArrowFileOutputStream is a class for file output stream.
- */
-
-typedef struct GArrowFileOutputStreamPrivate_ {
-  std::shared_ptr<arrow::io::FileOutputStream> file_output_stream;
-} GArrowFileOutputStreamPrivate;
-
-enum {
-  PROP_0,
-  PROP_FILE_OUTPUT_STREAM
-};
-
-static std::shared_ptr<arrow::io::FileInterface>
-garrow_file_output_stream_get_raw_file_interface(GArrowFile *file)
-{
-  auto file_output_stream = GARROW_FILE_OUTPUT_STREAM(file);
-  auto arrow_file_output_stream =
-    garrow_file_output_stream_get_raw(file_output_stream);
-  return arrow_file_output_stream;
-}
-
-static void
-garrow_file_interface_init(GArrowFileInterface *iface)
-{
-  iface->get_raw = garrow_file_output_stream_get_raw_file_interface;
-}
-
-static std::shared_ptr<arrow::io::Writeable>
-garrow_file_output_stream_get_raw_writeable_interface(GArrowWriteable 
*writeable)
-{
-  auto file_output_stream = GARROW_FILE_OUTPUT_STREAM(writeable);
-  auto arrow_file_output_stream =
-    garrow_file_output_stream_get_raw(file_output_stream);
-  return arrow_file_output_stream;
-}
-
-static void
-garrow_writeable_interface_init(GArrowWriteableInterface *iface)
-{
-  iface->get_raw = garrow_file_output_stream_get_raw_writeable_interface;
-}
-
-static std::shared_ptr<arrow::io::OutputStream>
-garrow_file_output_stream_get_raw_output_stream_interface(GArrowOutputStream 
*output_stream)
-{
-  auto file_output_stream = GARROW_FILE_OUTPUT_STREAM(output_stream);
-  auto arrow_file_output_stream =
-    garrow_file_output_stream_get_raw(file_output_stream);
-  return arrow_file_output_stream;
-}
-
-static void
-garrow_output_stream_interface_init(GArrowOutputStreamInterface *iface)
-{
-  iface->get_raw = garrow_file_output_stream_get_raw_output_stream_interface;
-}
-
-G_DEFINE_TYPE_WITH_CODE(GArrowFileOutputStream,
-                        garrow_file_output_stream,
-                        G_TYPE_OBJECT,
-                        G_ADD_PRIVATE(GArrowFileOutputStream)
-                        G_IMPLEMENT_INTERFACE(GARROW_TYPE_FILE,
-                                              garrow_file_interface_init)
-                        G_IMPLEMENT_INTERFACE(GARROW_TYPE_WRITEABLE,
-                                              garrow_writeable_interface_init)
-                        G_IMPLEMENT_INTERFACE(GARROW_TYPE_OUTPUT_STREAM,
-                                              
garrow_output_stream_interface_init));
-
-#define GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(obj)                   \
-  (G_TYPE_INSTANCE_GET_PRIVATE((obj),                                   \
-                               GARROW_TYPE_FILE_OUTPUT_STREAM,       \
-                               GArrowFileOutputStreamPrivate))
-
-static void
-garrow_file_output_stream_finalize(GObject *object)
-{
-  GArrowFileOutputStreamPrivate *priv;
-
-  priv = GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(object);
-
-  priv->file_output_stream = nullptr;
-
-  G_OBJECT_CLASS(garrow_file_output_stream_parent_class)->finalize(object);
-}
-
-static void
-garrow_file_output_stream_set_property(GObject *object,
-                                          guint prop_id,
-                                          const GValue *value,
-                                          GParamSpec *pspec)
-{
-  GArrowFileOutputStreamPrivate *priv;
-
-  priv = GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(object);
-
-  switch (prop_id) {
-  case PROP_FILE_OUTPUT_STREAM:
-    priv->file_output_stream =
-      *static_cast<std::shared_ptr<arrow::io::FileOutputStream> 
*>(g_value_get_pointer(value));
-    break;
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
-    break;
-  }
-}
-
-static void
-garrow_file_output_stream_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_file_output_stream_init(GArrowFileOutputStream *object)
-{
-}
-
-static void
-garrow_file_output_stream_class_init(GArrowFileOutputStreamClass *klass)
-{
-  GObjectClass *gobject_class;
-  GParamSpec *spec;
-
-  gobject_class = G_OBJECT_CLASS(klass);
-
-  gobject_class->finalize     = garrow_file_output_stream_finalize;
-  gobject_class->set_property = garrow_file_output_stream_set_property;
-  gobject_class->get_property = garrow_file_output_stream_get_property;
-
-  spec = g_param_spec_pointer("file-output-stream",
-                              "io::FileOutputStream",
-                              "The raw 
std::shared<arrow::io::FileOutputStream> *",
-                              static_cast<GParamFlags>(G_PARAM_WRITABLE |
-                                                       
G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property(gobject_class, PROP_FILE_OUTPUT_STREAM, 
spec);
-}
-
-/**
- * garrow_file_output_stream_open:
- * @path: The path of the file output stream.
- * @append: Whether the path is opened as append mode or recreate mode.
- * @error: (nullable): Return location for a #GError or %NULL.
- *
- * Returns: (nullable) (transfer full): A newly opened
- *   #GArrowFileOutputStream or %NULL on error.
- */
-GArrowFileOutputStream *
-garrow_file_output_stream_open(const gchar *path,
-                                  gboolean append,
-                                  GError **error)
-{
-  std::shared_ptr<arrow::io::FileOutputStream> arrow_file_output_stream;
-  auto status =
-    arrow::io::FileOutputStream::Open(std::string(path),
-                                      append,
-                                      &arrow_file_output_stream);
-  if (status.ok()) {
-    return garrow_file_output_stream_new_raw(&arrow_file_output_stream);
-  } else {
-    std::string context("[io][file-output-stream][open]: <");
-    context += path;
-    context += ">";
-    garrow_error_check(error, status, context.c_str());
-    return NULL;
-  }
-}
-
-G_END_DECLS
-
-GArrowFileOutputStream *
-garrow_file_output_stream_new_raw(std::shared_ptr<arrow::io::FileOutputStream> 
*arrow_file_output_stream)
-{
-  auto file_output_stream =
-    GARROW_FILE_OUTPUT_STREAM(g_object_new(GARROW_TYPE_FILE_OUTPUT_STREAM,
-                                              "file-output-stream", 
arrow_file_output_stream,
-                                              NULL));
-  return file_output_stream;
-}
-
-std::shared_ptr<arrow::io::FileOutputStream>
-garrow_file_output_stream_get_raw(GArrowFileOutputStream *file_output_stream)
-{
-  GArrowFileOutputStreamPrivate *priv;
-
-  priv = GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(file_output_stream);
-  return priv->file_output_stream;
-}

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/file-output-stream.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-output-stream.h 
b/c_glib/arrow-glib/file-output-stream.h
deleted file mode 100644
index bef3700..0000000
--- a/c_glib/arrow-glib/file-output-stream.h
+++ /dev/null
@@ -1,72 +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.
- */
-
-#pragma once
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define GARROW_TYPE_FILE_OUTPUT_STREAM       \
-  (garrow_file_output_stream_get_type())
-#define GARROW_FILE_OUTPUT_STREAM(obj)                               \
-  (G_TYPE_CHECK_INSTANCE_CAST((obj),                                    \
-                              GARROW_TYPE_FILE_OUTPUT_STREAM,        \
-                              GArrowFileOutputStream))
-#define GARROW_FILE_OUTPUT_STREAM_CLASS(klass)               \
-  (G_TYPE_CHECK_CLASS_CAST((klass),                             \
-                           GARROW_TYPE_FILE_OUTPUT_STREAM,   \
-                           GArrowFileOutputStreamClass))
-#define GARROW_IS_FILE_OUTPUT_STREAM(obj)                            \
-  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                                    \
-                              GARROW_TYPE_FILE_OUTPUT_STREAM))
-#define GARROW_IS_FILE_OUTPUT_STREAM_CLASS(klass)            \
-  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
-                           GARROW_TYPE_FILE_OUTPUT_STREAM))
-#define GARROW_FILE_OUTPUT_STREAM_GET_CLASS(obj)             \
-  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
-                             GARROW_TYPE_FILE_OUTPUT_STREAM, \
-                             GArrowFileOutputStreamClass))
-
-typedef struct _GArrowFileOutputStream         GArrowFileOutputStream;
-typedef struct _GArrowFileOutputStreamClass    GArrowFileOutputStreamClass;
-
-/**
- * GArrowFileOutputStream:
- *
- * It wraps `arrow::io::FileOutputStream`.
- */
-struct _GArrowFileOutputStream
-{
-  /*< private >*/
-  GObject parent_instance;
-};
-
-struct _GArrowFileOutputStreamClass
-{
-  GObjectClass parent_class;
-};
-
-GType garrow_file_output_stream_get_type(void) G_GNUC_CONST;
-
-GArrowFileOutputStream *garrow_file_output_stream_open(const gchar *path,
-                                                            gboolean append,
-                                                            GError **error);
-
-G_END_DECLS

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/file-output-stream.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-output-stream.hpp 
b/c_glib/arrow-glib/file-output-stream.hpp
deleted file mode 100644
index 0b10418..0000000
--- a/c_glib/arrow-glib/file-output-stream.hpp
+++ /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.
- */
-
-#pragma once
-
-#include <arrow/api.h>
-#include <arrow/io/file.h>
-
-#include <arrow-glib/file-output-stream.h>
-
-GArrowFileOutputStream 
*garrow_file_output_stream_new_raw(std::shared_ptr<arrow::io::FileOutputStream> 
*arrow_file_output_stream);
-std::shared_ptr<arrow::io::FileOutputStream> 
garrow_file_output_stream_get_raw(GArrowFileOutputStream *file_output_stream);

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/output-stream.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/output-stream.cpp 
b/c_glib/arrow-glib/output-stream.cpp
index bbc29b7..037814c 100644
--- a/c_glib/arrow-glib/output-stream.cpp
+++ b/c_glib/arrow-glib/output-stream.cpp
@@ -24,17 +24,22 @@
 #include <arrow/api.h>
 
 #include <arrow-glib/error.hpp>
+#include <arrow-glib/file.hpp>
 #include <arrow-glib/output-stream.hpp>
+#include <arrow-glib/writeable.hpp>
 
 G_BEGIN_DECLS
 
 /**
  * SECTION: output-stream
- * @title: GArrowOutputStream
- * @short_description: Stream output interface
+ * @section_id: output-stream-classes
+ * @title: Output stream classes
+ * @include: arrow-glib/arrow-glib.h
  *
  * #GArrowOutputStream is an interface for stream output. Stream
  * output is file based and writeable
+ *
+ * #GArrowFileOutputStream is a class for file output stream.
  */
 
 G_DEFINE_INTERFACE(GArrowOutputStream,
@@ -46,6 +51,178 @@ garrow_output_stream_default_init 
(GArrowOutputStreamInterface *iface)
 {
 }
 
+
+typedef struct GArrowFileOutputStreamPrivate_ {
+  std::shared_ptr<arrow::io::FileOutputStream> file_output_stream;
+} GArrowFileOutputStreamPrivate;
+
+enum {
+  PROP_0,
+  PROP_FILE_OUTPUT_STREAM
+};
+
+static std::shared_ptr<arrow::io::FileInterface>
+garrow_file_output_stream_get_raw_file_interface(GArrowFile *file)
+{
+  auto file_output_stream = GARROW_FILE_OUTPUT_STREAM(file);
+  auto arrow_file_output_stream =
+    garrow_file_output_stream_get_raw(file_output_stream);
+  return arrow_file_output_stream;
+}
+
+static void
+garrow_file_interface_init(GArrowFileInterface *iface)
+{
+  iface->get_raw = garrow_file_output_stream_get_raw_file_interface;
+}
+
+static std::shared_ptr<arrow::io::Writeable>
+garrow_file_output_stream_get_raw_writeable_interface(GArrowWriteable 
*writeable)
+{
+  auto file_output_stream = GARROW_FILE_OUTPUT_STREAM(writeable);
+  auto arrow_file_output_stream =
+    garrow_file_output_stream_get_raw(file_output_stream);
+  return arrow_file_output_stream;
+}
+
+static void
+garrow_writeable_interface_init(GArrowWriteableInterface *iface)
+{
+  iface->get_raw = garrow_file_output_stream_get_raw_writeable_interface;
+}
+
+static std::shared_ptr<arrow::io::OutputStream>
+garrow_file_output_stream_get_raw_output_stream_interface(GArrowOutputStream 
*output_stream)
+{
+  auto file_output_stream = GARROW_FILE_OUTPUT_STREAM(output_stream);
+  auto arrow_file_output_stream =
+    garrow_file_output_stream_get_raw(file_output_stream);
+  return arrow_file_output_stream;
+}
+
+static void
+garrow_output_stream_interface_init(GArrowOutputStreamInterface *iface)
+{
+  iface->get_raw = garrow_file_output_stream_get_raw_output_stream_interface;
+}
+
+G_DEFINE_TYPE_WITH_CODE(GArrowFileOutputStream,
+                        garrow_file_output_stream,
+                        G_TYPE_OBJECT,
+                        G_ADD_PRIVATE(GArrowFileOutputStream)
+                        G_IMPLEMENT_INTERFACE(GARROW_TYPE_FILE,
+                                              garrow_file_interface_init)
+                        G_IMPLEMENT_INTERFACE(GARROW_TYPE_WRITEABLE,
+                                              garrow_writeable_interface_init)
+                        G_IMPLEMENT_INTERFACE(GARROW_TYPE_OUTPUT_STREAM,
+                                              
garrow_output_stream_interface_init));
+
+#define GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(obj)              \
+  (G_TYPE_INSTANCE_GET_PRIVATE((obj),                           \
+                               GARROW_TYPE_FILE_OUTPUT_STREAM,  \
+                               GArrowFileOutputStreamPrivate))
+
+static void
+garrow_file_output_stream_finalize(GObject *object)
+{
+  GArrowFileOutputStreamPrivate *priv;
+
+  priv = GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(object);
+
+  priv->file_output_stream = nullptr;
+
+  G_OBJECT_CLASS(garrow_file_output_stream_parent_class)->finalize(object);
+}
+
+static void
+garrow_file_output_stream_set_property(GObject *object,
+                                          guint prop_id,
+                                          const GValue *value,
+                                          GParamSpec *pspec)
+{
+  GArrowFileOutputStreamPrivate *priv;
+
+  priv = GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(object);
+
+  switch (prop_id) {
+  case PROP_FILE_OUTPUT_STREAM:
+    priv->file_output_stream =
+      *static_cast<std::shared_ptr<arrow::io::FileOutputStream> 
*>(g_value_get_pointer(value));
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    break;
+  }
+}
+
+static void
+garrow_file_output_stream_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_file_output_stream_init(GArrowFileOutputStream *object)
+{
+}
+
+static void
+garrow_file_output_stream_class_init(GArrowFileOutputStreamClass *klass)
+{
+  GObjectClass *gobject_class;
+  GParamSpec *spec;
+
+  gobject_class = G_OBJECT_CLASS(klass);
+
+  gobject_class->finalize     = garrow_file_output_stream_finalize;
+  gobject_class->set_property = garrow_file_output_stream_set_property;
+  gobject_class->get_property = garrow_file_output_stream_get_property;
+
+  spec = g_param_spec_pointer("file-output-stream",
+                              "io::FileOutputStream",
+                              "The raw 
std::shared<arrow::io::FileOutputStream> *",
+                              static_cast<GParamFlags>(G_PARAM_WRITABLE |
+                                                       
G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property(gobject_class, PROP_FILE_OUTPUT_STREAM, 
spec);
+}
+
+/**
+ * garrow_file_output_stream_open:
+ * @path: The path of the file output stream.
+ * @append: Whether the path is opened as append mode or recreate mode.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full): A newly opened
+ *   #GArrowFileOutputStream or %NULL on error.
+ */
+GArrowFileOutputStream *
+garrow_file_output_stream_open(const gchar *path,
+                                  gboolean append,
+                                  GError **error)
+{
+  std::shared_ptr<arrow::io::FileOutputStream> arrow_file_output_stream;
+  auto status =
+    arrow::io::FileOutputStream::Open(std::string(path),
+                                      append,
+                                      &arrow_file_output_stream);
+  if (status.ok()) {
+    return garrow_file_output_stream_new_raw(&arrow_file_output_stream);
+  } else {
+    std::string context("[io][file-output-stream][open]: <");
+    context += path;
+    context += ">";
+    garrow_error_check(error, status, context.c_str());
+    return NULL;
+  }
+}
+
 G_END_DECLS
 
 std::shared_ptr<arrow::io::OutputStream>
@@ -54,3 +231,23 @@ garrow_output_stream_get_raw(GArrowOutputStream 
*output_stream)
   auto *iface = GARROW_OUTPUT_STREAM_GET_IFACE(output_stream);
   return iface->get_raw(output_stream);
 }
+
+
+GArrowFileOutputStream *
+garrow_file_output_stream_new_raw(std::shared_ptr<arrow::io::FileOutputStream> 
*arrow_file_output_stream)
+{
+  auto file_output_stream =
+    GARROW_FILE_OUTPUT_STREAM(g_object_new(GARROW_TYPE_FILE_OUTPUT_STREAM,
+                                           "file-output-stream", 
arrow_file_output_stream,
+                                           NULL));
+  return file_output_stream;
+}
+
+std::shared_ptr<arrow::io::FileOutputStream>
+garrow_file_output_stream_get_raw(GArrowFileOutputStream *file_output_stream)
+{
+  GArrowFileOutputStreamPrivate *priv;
+
+  priv = GARROW_FILE_OUTPUT_STREAM_GET_PRIVATE(file_output_stream);
+  return priv->file_output_stream;
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/output-stream.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/output-stream.h 
b/c_glib/arrow-glib/output-stream.h
index 3481072..043832e 100644
--- a/c_glib/arrow-glib/output-stream.h
+++ b/c_glib/arrow-glib/output-stream.h
@@ -42,4 +42,56 @@ typedef struct _GArrowOutputStreamInterface 
GArrowOutputStreamInterface;
 
 GType garrow_output_stream_get_type(void) G_GNUC_CONST;
 
+
+#define GARROW_TYPE_FILE_OUTPUT_STREAM          \
+  (garrow_file_output_stream_get_type())
+#define GARROW_FILE_OUTPUT_STREAM(obj)                          \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_FILE_OUTPUT_STREAM,   \
+                              GArrowFileOutputStream))
+#define GARROW_FILE_OUTPUT_STREAM_CLASS(klass)                  \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                             \
+                           GARROW_TYPE_FILE_OUTPUT_STREAM,      \
+                           GArrowFileOutputStreamClass))
+#define GARROW_IS_FILE_OUTPUT_STREAM(obj)                       \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_FILE_OUTPUT_STREAM))
+#define GARROW_IS_FILE_OUTPUT_STREAM_CLASS(klass)               \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
+                           GARROW_TYPE_FILE_OUTPUT_STREAM))
+#define GARROW_FILE_OUTPUT_STREAM_GET_CLASS(obj)                \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_FILE_OUTPUT_STREAM,    \
+                             GArrowFileOutputStreamClass))
+
+typedef struct _GArrowFileOutputStream         GArrowFileOutputStream;
+#ifndef __GTK_DOC_IGNORE__
+typedef struct _GArrowFileOutputStreamClass    GArrowFileOutputStreamClass;
+#endif
+
+/**
+ * GArrowFileOutputStream:
+ *
+ * It wraps `arrow::io::FileOutputStream`.
+ */
+struct _GArrowFileOutputStream
+{
+  /*< private >*/
+  GObject parent_instance;
+};
+
+#ifndef __GTK_DOC_IGNORE__
+struct _GArrowFileOutputStreamClass
+{
+  GObjectClass parent_class;
+};
+#endif
+
+GType garrow_file_output_stream_get_type(void) G_GNUC_CONST;
+
+GArrowFileOutputStream *garrow_file_output_stream_open(const gchar *path,
+                                                       gboolean append,
+                                                       GError **error);
+
+
 G_END_DECLS

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/arrow-glib/output-stream.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/output-stream.hpp 
b/c_glib/arrow-glib/output-stream.hpp
index 635da10..e8e7321 100644
--- a/c_glib/arrow-glib/output-stream.hpp
+++ b/c_glib/arrow-glib/output-stream.hpp
@@ -19,7 +19,7 @@
 
 #pragma once
 
-#include <arrow/io/interfaces.h>
+#include <arrow/io/file.h>
 
 #include <arrow-glib/output-stream.h>
 
@@ -36,3 +36,6 @@ struct _GArrowOutputStreamInterface
 };
 
 std::shared_ptr<arrow::io::OutputStream> 
garrow_output_stream_get_raw(GArrowOutputStream *output_stream);
+
+GArrowFileOutputStream 
*garrow_file_output_stream_new_raw(std::shared_ptr<arrow::io::FileOutputStream> 
*arrow_file_output_stream);
+std::shared_ptr<arrow::io::FileOutputStream> 
garrow_file_output_stream_get_raw(GArrowFileOutputStream *file_output_stream);

http://git-wip-us.apache.org/repos/asf/arrow/blob/14bec24c/c_glib/doc/reference/arrow-glib-docs.sgml
----------------------------------------------------------------------
diff --git a/c_glib/doc/reference/arrow-glib-docs.sgml 
b/c_glib/doc/reference/arrow-glib-docs.sgml
index 75e4a0a..7ba37b4 100644
--- a/c_glib/doc/reference/arrow-glib-docs.sgml
+++ b/c_glib/doc/reference/arrow-glib-docs.sgml
@@ -87,9 +87,8 @@
     <chapter id="output">
       <title>Output</title>
       <xi:include href="xml/writeable.xml"/>
-      <xi:include href="xml/output-stream.xml"/>
       <xi:include href="xml/writeable-file.xml"/>
-      <xi:include href="xml/file-output-stream.xml"/>
+      <xi:include href="xml/output-stream.xml"/>
     </chapter>
     <chapter id="input-output">
       <title>Input and output</title>

Reply via email to