arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [1/4] arrow git commit: ARROW-810: [GLib] Remove io/ipc prefix
Date Wed, 12 Apr 2017 14:54:49 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 5e5a5878d -> 6443b8287


http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/stream-writer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-writer.cpp b/c_glib/arrow-glib/stream-writer.cpp
new file mode 100644
index 0000000..016ce93
--- /dev/null
+++ b/c_glib/arrow-glib/stream-writer.cpp
@@ -0,0 +1,232 @@
+/*
+ * 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/ipc/api.h>
+
+#include <arrow-glib/array.hpp>
+#include <arrow-glib/error.hpp>
+#include <arrow-glib/record-batch.hpp>
+#include <arrow-glib/schema.hpp>
+
+#include <arrow-glib/output-stream.hpp>
+
+#include <arrow-glib/stream-writer.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: stream-writer
+ * @short_description: Stream writer class
+ *
+ * #GArrowStreamWriter is a class for sending data by stream based
+ * IPC.
+ */
+
+typedef struct GArrowStreamWriterPrivate_ {
+  std::shared_ptr<arrow::ipc::StreamWriter> stream_writer;
+} GArrowStreamWriterPrivate;
+
+enum {
+  PROP_0,
+  PROP_STREAM_WRITER
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowStreamWriter,
+                           garrow_stream_writer,
+                           G_TYPE_OBJECT);
+
+#define GARROW_STREAM_WRITER_GET_PRIVATE(obj)               \
+  (G_TYPE_INSTANCE_GET_PRIVATE((obj),                           \
+                               GARROW_TYPE_STREAM_WRITER,   \
+                               GArrowStreamWriterPrivate))
+
+static void
+garrow_stream_writer_finalize(GObject *object)
+{
+  GArrowStreamWriterPrivate *priv;
+
+  priv = GARROW_STREAM_WRITER_GET_PRIVATE(object);
+
+  priv->stream_writer = nullptr;
+
+  G_OBJECT_CLASS(garrow_stream_writer_parent_class)->finalize(object);
+}
+
+static void
+garrow_stream_writer_set_property(GObject *object,
+                                    guint prop_id,
+                                    const GValue *value,
+                                    GParamSpec *pspec)
+{
+  GArrowStreamWriterPrivate *priv;
+
+  priv = GARROW_STREAM_WRITER_GET_PRIVATE(object);
+
+  switch (prop_id) {
+  case PROP_STREAM_WRITER:
+    priv->stream_writer =
+      *static_cast<std::shared_ptr<arrow::ipc::StreamWriter> *>(g_value_get_pointer(value));
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+    break;
+  }
+}
+
+static void
+garrow_stream_writer_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_stream_writer_init(GArrowStreamWriter *object)
+{
+}
+
+static void
+garrow_stream_writer_class_init(GArrowStreamWriterClass *klass)
+{
+  GObjectClass *gobject_class;
+  GParamSpec *spec;
+
+  gobject_class = G_OBJECT_CLASS(klass);
+
+  gobject_class->finalize     = garrow_stream_writer_finalize;
+  gobject_class->set_property = garrow_stream_writer_set_property;
+  gobject_class->get_property = garrow_stream_writer_get_property;
+
+  spec = g_param_spec_pointer("stream-writer",
+                              "ipc::StreamWriter",
+                              "The raw std::shared<arrow::ipc::StreamWriter> *",
+                              static_cast<GParamFlags>(G_PARAM_WRITABLE |
+                                                       G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property(gobject_class, PROP_STREAM_WRITER, spec);
+}
+
+/**
+ * garrow_stream_writer_open:
+ * @sink: The output of the writer.
+ * @schema: The schema of the writer.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full): A newly opened
+ *   #GArrowStreamWriter or %NULL on error.
+ */
+GArrowStreamWriter *
+garrow_stream_writer_open(GArrowOutputStream *sink,
+                              GArrowSchema *schema,
+                              GError **error)
+{
+  std::shared_ptr<arrow::ipc::StreamWriter> arrow_stream_writer;
+  auto status =
+    arrow::ipc::StreamWriter::Open(garrow_output_stream_get_raw(sink).get(),
+                                 garrow_schema_get_raw(schema),
+                                 &arrow_stream_writer);
+  if (status.ok()) {
+    return garrow_stream_writer_new_raw(&arrow_stream_writer);
+  } else {
+    garrow_error_set(error, status, "[ipc][stream-writer][open]");
+    return NULL;
+  }
+}
+
+/**
+ * garrow_stream_writer_write_record_batch:
+ * @stream_writer: A #GArrowStreamWriter.
+ * @record_batch: The record batch to be written.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_stream_writer_write_record_batch(GArrowStreamWriter *stream_writer,
+                                            GArrowRecordBatch *record_batch,
+                                            GError **error)
+{
+  auto arrow_stream_writer =
+    garrow_stream_writer_get_raw(stream_writer);
+  auto arrow_record_batch =
+    garrow_record_batch_get_raw(record_batch);
+  auto arrow_record_batch_raw =
+    arrow_record_batch.get();
+
+  auto status = arrow_stream_writer->WriteRecordBatch(*arrow_record_batch_raw);
+  if (status.ok()) {
+    return TRUE;
+  } else {
+    garrow_error_set(error, status, "[ipc][stream-writer][write-record-batch]");
+    return FALSE;
+  }
+}
+
+/**
+ * garrow_stream_writer_close:
+ * @stream_writer: A #GArrowStreamWriter.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_stream_writer_close(GArrowStreamWriter *stream_writer,
+                               GError **error)
+{
+  auto arrow_stream_writer =
+    garrow_stream_writer_get_raw(stream_writer);
+
+  auto status = arrow_stream_writer->Close();
+  if (status.ok()) {
+    return TRUE;
+  } else {
+    garrow_error_set(error, status, "[ipc][stream-writer][close]");
+    return FALSE;
+  }
+}
+
+G_END_DECLS
+
+GArrowStreamWriter *
+garrow_stream_writer_new_raw(std::shared_ptr<arrow::ipc::StreamWriter> *arrow_stream_writer)
+{
+  auto stream_writer =
+    GARROW_STREAM_WRITER(g_object_new(GARROW_TYPE_STREAM_WRITER,
+                                        "stream-writer", arrow_stream_writer,
+                                        NULL));
+  return stream_writer;
+}
+
+std::shared_ptr<arrow::ipc::StreamWriter>
+garrow_stream_writer_get_raw(GArrowStreamWriter *stream_writer)
+{
+  GArrowStreamWriterPrivate *priv;
+
+  priv = GARROW_STREAM_WRITER_GET_PRIVATE(stream_writer);
+  return priv->stream_writer;
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/stream-writer.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-writer.h b/c_glib/arrow-glib/stream-writer.h
new file mode 100644
index 0000000..6e773f1
--- /dev/null
+++ b/c_glib/arrow-glib/stream-writer.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/record-batch.h>
+#include <arrow-glib/schema.h>
+
+#include <arrow-glib/output-stream.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_STREAM_WRITER           \
+  (garrow_stream_writer_get_type())
+#define GARROW_STREAM_WRITER(obj)                           \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_STREAM_WRITER,    \
+                              GArrowStreamWriter))
+#define GARROW_STREAM_WRITER_CLASS(klass)                   \
+  (G_TYPE_CHECK_CLASS_CAST((klass),                             \
+                           GARROW_TYPE_STREAM_WRITER,       \
+                           GArrowStreamWriterClass))
+#define GARROW_IS_STREAM_WRITER(obj)                        \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_STREAM_WRITER))
+#define GARROW_IS_STREAM_WRITER_CLASS(klass)                \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),                             \
+                           GARROW_TYPE_STREAM_WRITER))
+#define GARROW_STREAM_WRITER_GET_CLASS(obj)                 \
+  (G_TYPE_INSTANCE_GET_CLASS((obj),                             \
+                             GARROW_TYPE_STREAM_WRITER,     \
+                             GArrowStreamWriterClass))
+
+typedef struct _GArrowStreamWriter         GArrowStreamWriter;
+typedef struct _GArrowStreamWriterClass    GArrowStreamWriterClass;
+
+/**
+ * GArrowStreamWriter:
+ *
+ * It wraps `arrow::ipc::StreamWriter`.
+ */
+struct _GArrowStreamWriter
+{
+  /*< private >*/
+  GObject parent_instance;
+};
+
+struct _GArrowStreamWriterClass
+{
+  GObjectClass parent_class;
+};
+
+GType garrow_stream_writer_get_type(void) G_GNUC_CONST;
+
+GArrowStreamWriter *garrow_stream_writer_open(GArrowOutputStream *sink,
+                                                     GArrowSchema *schema,
+                                                     GError **error);
+
+gboolean garrow_stream_writer_write_record_batch(GArrowStreamWriter *stream_writer,
+                                                     GArrowRecordBatch *record_batch,
+                                                     GError **error);
+gboolean garrow_stream_writer_close(GArrowStreamWriter *stream_writer,
+                                        GError **error);
+
+G_END_DECLS

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/stream-writer.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-writer.hpp b/c_glib/arrow-glib/stream-writer.hpp
new file mode 100644
index 0000000..994c83b
--- /dev/null
+++ b/c_glib/arrow-glib/stream-writer.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/ipc/api.h>
+
+#include <arrow-glib/stream-writer.h>
+
+GArrowStreamWriter *garrow_stream_writer_new_raw(std::shared_ptr<arrow::ipc::StreamWriter> *arrow_stream_writer);
+std::shared_ptr<arrow::ipc::StreamWriter> garrow_stream_writer_get_raw(GArrowStreamWriter *stream_writer);

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/writeable-file.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable-file.cpp b/c_glib/arrow-glib/writeable-file.cpp
new file mode 100644
index 0000000..d0937ea
--- /dev/null
+++ b/c_glib/arrow-glib/writeable-file.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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/api.h>
+
+#include <arrow-glib/error.hpp>
+#include <arrow-glib/writeable-file.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: writeable-file
+ * @title: GArrowWriteableFile
+ * @short_description: File output interface
+ *
+ * #GArrowWriteableFile is an interface for file output.
+ */
+
+G_DEFINE_INTERFACE(GArrowWriteableFile,
+                   garrow_writeable_file,
+                   G_TYPE_OBJECT)
+
+static void
+garrow_writeable_file_default_init (GArrowWriteableFileInterface *iface)
+{
+}
+
+/**
+ * garrow_writeable_file_write_at:
+ * @writeable_file: A #GArrowWriteableFile.
+ * @position: The write start position.
+ * @data: (array length=n_bytes): The data to be written.
+ * @n_bytes: The number of bytes to be written.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_writeable_file_write_at(GArrowWriteableFile *writeable_file,
+                                  gint64 position,
+                                  const guint8 *data,
+                                  gint64 n_bytes,
+                                  GError **error)
+{
+  const auto arrow_writeable_file =
+    garrow_writeable_file_get_raw(writeable_file);
+
+  auto status = arrow_writeable_file->WriteAt(position, data, n_bytes);
+  if (status.ok()) {
+    return TRUE;
+  } else {
+    garrow_error_set(error, status, "[io][writeable-file][write-at]");
+    return FALSE;
+  }
+}
+
+G_END_DECLS
+
+std::shared_ptr<arrow::io::WriteableFile>
+garrow_writeable_file_get_raw(GArrowWriteableFile *writeable_file)
+{
+  auto *iface = GARROW_WRITEABLE_FILE_GET_IFACE(writeable_file);
+  return iface->get_raw(writeable_file);
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/writeable-file.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable-file.h b/c_glib/arrow-glib/writeable-file.h
new file mode 100644
index 0000000..7f4c186
--- /dev/null
+++ b/c_glib/arrow-glib/writeable-file.h
@@ -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.
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_WRITEABLE_FILE           \
+  (garrow_writeable_file_get_type())
+#define GARROW_WRITEABLE_FILE(obj)                           \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_WRITEABLE_FILE,    \
+                              GArrowWriteableFile))
+#define GARROW_IS_WRITEABLE_FILE(obj)                        \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_WRITEABLE_FILE))
+#define GARROW_WRITEABLE_FILE_GET_IFACE(obj)                         \
+  (G_TYPE_INSTANCE_GET_INTERFACE((obj),                                 \
+                                 GARROW_TYPE_WRITEABLE_FILE,         \
+                                 GArrowWriteableFileInterface))
+
+typedef struct _GArrowWriteableFile          GArrowWriteableFile;
+typedef struct _GArrowWriteableFileInterface GArrowWriteableFileInterface;
+
+GType garrow_writeable_file_get_type(void) G_GNUC_CONST;
+
+gboolean garrow_writeable_file_write_at(GArrowWriteableFile *writeable_file,
+                                           gint64 position,
+                                           const guint8 *data,
+                                           gint64 n_bytes,
+                                           GError **error);
+
+G_END_DECLS

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/writeable-file.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable-file.hpp b/c_glib/arrow-glib/writeable-file.hpp
new file mode 100644
index 0000000..aa3cc50
--- /dev/null
+++ b/c_glib/arrow-glib/writeable-file.hpp
@@ -0,0 +1,38 @@
+/*
+ * 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/io/interfaces.h>
+
+#include <arrow-glib/writeable-file.h>
+
+/**
+ * GArrowWriteableFile:
+ *
+ * It wraps `arrow::io::WriteableFile`.
+ */
+struct _GArrowWriteableFileInterface
+{
+  GTypeInterface parent_iface;
+
+  std::shared_ptr<arrow::io::WriteableFile> (*get_raw)(GArrowWriteableFile *file);
+};
+
+std::shared_ptr<arrow::io::WriteableFile> garrow_writeable_file_get_raw(GArrowWriteableFile *writeable_file);

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/writeable.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable.cpp b/c_glib/arrow-glib/writeable.cpp
new file mode 100644
index 0000000..6f4c630
--- /dev/null
+++ b/c_glib/arrow-glib/writeable.cpp
@@ -0,0 +1,106 @@
+/*
+ * 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/api.h>
+
+#include <arrow-glib/error.hpp>
+#include <arrow-glib/writeable.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: writeable
+ * @title: GArrowWriteable
+ * @short_description: Output interface
+ *
+ * #GArrowWriteable is an interface for output. Output must be
+ * writeable.
+ */
+
+G_DEFINE_INTERFACE(GArrowWriteable,
+                   garrow_writeable,
+                   G_TYPE_OBJECT)
+
+static void
+garrow_writeable_default_init (GArrowWriteableInterface *iface)
+{
+}
+
+/**
+ * garrow_writeable_write:
+ * @writeable: A #GArrowWriteable.
+ * @data: (array length=n_bytes): The data to be written.
+ * @n_bytes: The number of bytes to be written.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_writeable_write(GArrowWriteable *writeable,
+                          const guint8 *data,
+                          gint64 n_bytes,
+                          GError **error)
+{
+  const auto arrow_writeable = garrow_writeable_get_raw(writeable);
+
+  auto status = arrow_writeable->Write(data, n_bytes);
+  if (status.ok()) {
+    return TRUE;
+  } else {
+    garrow_error_set(error, status, "[io][writeable][write]");
+    return FALSE;
+  }
+}
+
+/**
+ * garrow_writeable_flush:
+ * @writeable: A #GArrowWriteable.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * It ensures writing all data on memory to storage.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_writeable_flush(GArrowWriteable *writeable,
+                          GError **error)
+{
+  const auto arrow_writeable = garrow_writeable_get_raw(writeable);
+
+  auto status = arrow_writeable->Flush();
+  if (status.ok()) {
+    return TRUE;
+  } else {
+    garrow_error_set(error, status, "[io][writeable][flush]");
+    return FALSE;
+  }
+}
+
+G_END_DECLS
+
+std::shared_ptr<arrow::io::Writeable>
+garrow_writeable_get_raw(GArrowWriteable *writeable)
+{
+  auto *iface = GARROW_WRITEABLE_GET_IFACE(writeable);
+  return iface->get_raw(writeable);
+}

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/writeable.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable.h b/c_glib/arrow-glib/writeable.h
new file mode 100644
index 0000000..66d6922
--- /dev/null
+++ b/c_glib/arrow-glib/writeable.h
@@ -0,0 +1,52 @@
+/*
+ * 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_WRITEABLE                \
+  (garrow_writeable_get_type())
+#define GARROW_WRITEABLE(obj)                                \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),                            \
+                              GARROW_TYPE_WRITEABLE,         \
+                              GArrowWriteable))
+#define GARROW_IS_WRITEABLE(obj)                             \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),                            \
+                              GARROW_TYPE_WRITEABLE))
+#define GARROW_WRITEABLE_GET_IFACE(obj)                      \
+  (G_TYPE_INSTANCE_GET_INTERFACE((obj),                         \
+                                 GARROW_TYPE_WRITEABLE,      \
+                                 GArrowWriteableInterface))
+
+typedef struct _GArrowWriteable          GArrowWriteable;
+typedef struct _GArrowWriteableInterface GArrowWriteableInterface;
+
+GType garrow_writeable_get_type(void) G_GNUC_CONST;
+
+gboolean garrow_writeable_write(GArrowWriteable *writeable,
+                                   const guint8 *data,
+                                   gint64 n_bytes,
+                                   GError **error);
+gboolean garrow_writeable_flush(GArrowWriteable *writeable,
+                                   GError **error);
+
+G_END_DECLS

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/writeable.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writeable.hpp b/c_glib/arrow-glib/writeable.hpp
new file mode 100644
index 0000000..2b398f8
--- /dev/null
+++ b/c_glib/arrow-glib/writeable.hpp
@@ -0,0 +1,38 @@
+/*
+ * 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/io/interfaces.h>
+
+#include <arrow-glib/writeable.h>
+
+/**
+ * GArrowWriteableInterface:
+ *
+ * It wraps `arrow::io::Writeable`.
+ */
+struct _GArrowWriteableInterface
+{
+  GTypeInterface parent_iface;
+
+  std::shared_ptr<arrow::io::Writeable> (*get_raw)(GArrowWriteable *file);
+};
+
+std::shared_ptr<arrow::io::Writeable> garrow_writeable_get_raw(GArrowWriteable *writeable);

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/doc/reference/Makefile.am
----------------------------------------------------------------------
diff --git a/c_glib/doc/reference/Makefile.am b/c_glib/doc/reference/Makefile.am
index 116bc6c..d3389dc 100644
--- a/c_glib/doc/reference/Makefile.am
+++ b/c_glib/doc/reference/Makefile.am
@@ -26,7 +26,7 @@ SCAN_OPTIONS =						\
 	--deprecated-guards="GARROW_DISABLE_DEPRECATED"
 
 MKDB_OPTIONS =					\
-	--name-space=arrow			\
+	--name-space=garrow			\
 	--source-suffixes="c,cpp,h"
 
 HFILE_GLOB =					\

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/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 06a1936..396dce5 100644
--- a/c_glib/doc/reference/arrow-glib-docs.sgml
+++ b/c_glib/doc/reference/arrow-glib-docs.sgml
@@ -31,8 +31,8 @@
     </releaseinfo>
   </bookinfo>
 
-  <part id="arrow">
-    <title>GArrow</title>
+  <part id="data">
+    <title>Data</title>
     <chapter id="array">
       <title>Array</title>
       <xi:include href="xml/array.xml"/>
@@ -111,47 +111,47 @@
     </chapter>
   </part>
 
-  <part id="arrow-io">
-    <title>GArrowIO</title>
-    <chapter id="io-mode">
-      <title>Enums</title>
-      <xi:include href="xml/io-file-mode.xml"/>
+  <part id="io">
+    <title>IO</title>
+    <chapter id="mode">
+      <title>Mode</title>
+      <xi:include href="xml/file-mode.xml"/>
     </chapter>
-    <chapter id="io-input">
+    <chapter id="input">
       <title>Input</title>
-      <xi:include href="xml/io-readable.xml"/>
-      <xi:include href="xml/io-input-stream.xml"/>
-      <xi:include href="xml/io-random-access-file.xml"/>
+      <xi:include href="xml/readable.xml"/>
+      <xi:include href="xml/input-stream.xml"/>
+      <xi:include href="xml/random-access-file.xml"/>
     </chapter>
-    <chapter id="io-output">
+    <chapter id="output">
       <title>Output</title>
-      <xi:include href="xml/io-writeable.xml"/>
-      <xi:include href="xml/io-output-stream.xml"/>
-      <xi:include href="xml/io-writeable-file.xml"/>
-      <xi:include href="xml/io-file-output-stream.xml"/>
+      <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"/>
     </chapter>
-    <chapter id="io-input-output">
+    <chapter id="input-output">
       <title>Input and output</title>
-      <xi:include href="xml/io-file.xml"/>
-      <xi:include href="xml/io-memory-mapped-file.xml"/>
+      <xi:include href="xml/file.xml"/>
+      <xi:include href="xml/memory-mapped-file.xml"/>
     </chapter>
   </part>
 
-  <part id="arrow-ipc">
-    <title>GArrowIPC</title>
-    <chapter id="ipc-metadata">
-      <title>Enums</title>
-      <xi:include href="xml/ipc-metadata-version.xml"/>
+  <part id="ipc">
+    <title>IPC</title>
+    <chapter id="metadata">
+      <title>Metadata</title>
+      <xi:include href="xml/metadata-version.xml"/>
     </chapter>
-    <chapter id="ipc-reader">
+    <chapter id="reader">
       <title>Reader</title>
-      <xi:include href="xml/ipc-file-reader.xml"/>
-      <xi:include href="xml/ipc-stream-reader.xml"/>
+      <xi:include href="xml/file-reader.xml"/>
+      <xi:include href="xml/stream-reader.xml"/>
     </chapter>
-    <chapter id="ipc-writer">
-      <title>Input</title>
-      <xi:include href="xml/ipc-file-writer.xml"/>
-      <xi:include href="xml/ipc-stream-writer.xml"/>
+    <chapter id="writer">
+      <title>Writer</title>
+      <xi:include href="xml/file-writer.xml"/>
+      <xi:include href="xml/stream-writer.xml"/>
     </chapter>
   </part>
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/example/read-batch.c
----------------------------------------------------------------------
diff --git a/c_glib/example/read-batch.c b/c_glib/example/read-batch.c
index a55b085..dce96b8 100644
--- a/c_glib/example/read-batch.c
+++ b/c_glib/example/read-batch.c
@@ -87,14 +87,14 @@ int
 main(int argc, char **argv)
 {
   const char *input_path = "/tmp/batch.arrow";
-  GArrowIOMemoryMappedFile *input;
+  GArrowMemoryMappedFile *input;
   GError *error = NULL;
 
   if (argc > 1)
     input_path = argv[1];
-  input = garrow_io_memory_mapped_file_open(input_path,
-                                            GARROW_IO_FILE_MODE_READ,
-                                            &error);
+  input = garrow_memory_mapped_file_open(input_path,
+                                         GARROW_FILE_MODE_READ,
+                                         &error);
   if (!input) {
     g_print("failed to open file: %s\n", error->message);
     g_error_free(error);
@@ -102,10 +102,10 @@ main(int argc, char **argv)
   }
 
   {
-    GArrowIPCFileReader *reader;
+    GArrowFileReader *reader;
 
-    reader = garrow_ipc_file_reader_open(GARROW_IO_RANDOM_ACCESS_FILE(input),
-                                         &error);
+    reader = garrow_file_reader_open(GARROW_RANDOM_ACCESS_FILE(input),
+                                     &error);
     if (!reader) {
       g_print("failed to open file reader: %s\n", error->message);
       g_error_free(error);
@@ -116,12 +116,12 @@ main(int argc, char **argv)
     {
       guint i, n;
 
-      n = garrow_ipc_file_reader_get_n_record_batches(reader);
+      n = garrow_file_reader_get_n_record_batches(reader);
       for (i = 0; i < n; i++) {
         GArrowRecordBatch *record_batch;
 
         record_batch =
-          garrow_ipc_file_reader_get_record_batch(reader, i, &error);
+          garrow_file_reader_get_record_batch(reader, i, &error);
         if (!record_batch) {
           g_print("failed to open file reader: %s\n", error->message);
           g_error_free(error);

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/example/read-stream.c
----------------------------------------------------------------------
diff --git a/c_glib/example/read-stream.c b/c_glib/example/read-stream.c
index c56942c..ba461e3 100644
--- a/c_glib/example/read-stream.c
+++ b/c_glib/example/read-stream.c
@@ -87,14 +87,14 @@ int
 main(int argc, char **argv)
 {
   const char *input_path = "/tmp/stream.arrow";
-  GArrowIOMemoryMappedFile *input;
+  GArrowMemoryMappedFile *input;
   GError *error = NULL;
 
   if (argc > 1)
     input_path = argv[1];
-  input = garrow_io_memory_mapped_file_open(input_path,
-                                            GARROW_IO_FILE_MODE_READ,
-                                            &error);
+  input = garrow_memory_mapped_file_open(input_path,
+                                         GARROW_FILE_MODE_READ,
+                                         &error);
   if (!input) {
     g_print("failed to open file: %s\n", error->message);
     g_error_free(error);
@@ -102,10 +102,10 @@ main(int argc, char **argv)
   }
 
   {
-    GArrowIPCStreamReader *reader;
+    GArrowStreamReader *reader;
 
-    reader = garrow_ipc_stream_reader_open(GARROW_IO_INPUT_STREAM(input),
-                                           &error);
+    reader = garrow_stream_reader_open(GARROW_INPUT_STREAM(input),
+                                       &error);
     if (!reader) {
       g_print("failed to open stream reader: %s\n", error->message);
       g_error_free(error);
@@ -117,7 +117,7 @@ main(int argc, char **argv)
       GArrowRecordBatch *record_batch;
 
       record_batch =
-        garrow_ipc_stream_reader_get_next_record_batch(reader, &error);
+        garrow_stream_reader_get_next_record_batch(reader, &error);
       if (error) {
         g_print("failed to get record batch: %s\n", error->message);
         g_error_free(error);

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-file-output-stream.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-file-output-stream.rb b/c_glib/test/test-file-output-stream.rb
new file mode 100644
index 0000000..26737c0
--- /dev/null
+++ b/c_glib/test/test-file-output-stream.rb
@@ -0,0 +1,38 @@
+# 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 TestFileOutputStream < Test::Unit::TestCase
+  sub_test_case(".open") do
+    def test_create
+      tempfile = Tempfile.open("arrow-io-file-output-stream")
+      tempfile.write("Hello")
+      tempfile.close
+      file = Arrow::FileOutputStream.open(tempfile.path, false)
+      file.close
+      assert_equal("", File.read(tempfile.path))
+    end
+
+    def test_append
+      tempfile = Tempfile.open("arrow-io-file-output-stream")
+      tempfile.write("Hello")
+      tempfile.close
+      file = Arrow::FileOutputStream.open(tempfile.path, true)
+      file.close
+      assert_equal("Hello", File.read(tempfile.path))
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-file-writer.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-file-writer.rb b/c_glib/test/test-file-writer.rb
new file mode 100644
index 0000000..31c094d
--- /dev/null
+++ b/c_glib/test/test-file-writer.rb
@@ -0,0 +1,45 @@
+# 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 TestFileWriter < Test::Unit::TestCase
+  def test_write_record_batch
+    tempfile = Tempfile.open("arrow-ipc-file-writer")
+    output = Arrow::FileOutputStream.open(tempfile.path, false)
+    begin
+      field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
+      schema = Arrow::Schema.new([field])
+      file_writer = Arrow::FileWriter.open(output, schema)
+      begin
+        record_batch = Arrow::RecordBatch.new(schema, 0, [])
+        file_writer.write_record_batch(record_batch)
+      ensure
+        file_writer.close
+      end
+    ensure
+      output.close
+    end
+
+    input = Arrow::MemoryMappedFile.open(tempfile.path, :read)
+    begin
+      file_reader = Arrow::FileReader.open(input)
+      assert_equal(["enabled"],
+                   file_reader.schema.fields.collect(&:name))
+    ensure
+      input.close
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-io-file-output-stream.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-io-file-output-stream.rb b/c_glib/test/test-io-file-output-stream.rb
deleted file mode 100644
index e35a183..0000000
--- a/c_glib/test/test-io-file-output-stream.rb
+++ /dev/null
@@ -1,38 +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 TestIOFileOutputStream < Test::Unit::TestCase
-  sub_test_case(".open") do
-    def test_create
-      tempfile = Tempfile.open("arrow-io-file-output-stream")
-      tempfile.write("Hello")
-      tempfile.close
-      file = Arrow::IOFileOutputStream.open(tempfile.path, false)
-      file.close
-      assert_equal("", File.read(tempfile.path))
-    end
-
-    def test_append
-      tempfile = Tempfile.open("arrow-io-file-output-stream")
-      tempfile.write("Hello")
-      tempfile.close
-      file = Arrow::IOFileOutputStream.open(tempfile.path, true)
-      file.close
-      assert_equal("Hello", File.read(tempfile.path))
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-io-memory-mapped-file.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-io-memory-mapped-file.rb b/c_glib/test/test-io-memory-mapped-file.rb
deleted file mode 100644
index 197d188..0000000
--- a/c_glib/test/test-io-memory-mapped-file.rb
+++ /dev/null
@@ -1,138 +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 TestIOMemoryMappedFile < Test::Unit::TestCase
-  def test_open
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :read)
-    begin
-      buffer = " " * 5
-      file.read(buffer)
-      assert_equal("Hello", buffer)
-    ensure
-      file.close
-    end
-  end
-
-  def test_size
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :read)
-    begin
-      assert_equal(5, file.size)
-    ensure
-      file.close
-    end
-  end
-
-  def test_read
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello World")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :read)
-    begin
-      buffer = " " * 5
-      _success, n_read_bytes = file.read(buffer)
-      assert_equal("Hello", buffer.byteslice(0, n_read_bytes))
-    ensure
-      file.close
-    end
-  end
-
-  def test_read_at
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello World")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :read)
-    begin
-      buffer = " " * 5
-      _success, n_read_bytes = file.read_at(6, buffer)
-      assert_equal("World", buffer.byteslice(0, n_read_bytes))
-    ensure
-      file.close
-    end
-  end
-
-  def test_write
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :readwrite)
-    begin
-      file.write("World")
-    ensure
-      file.close
-    end
-    assert_equal("World", File.read(tempfile.path))
-  end
-
-  def test_write_at
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :readwrite)
-    begin
-      file.write_at(2, "rld")
-    ensure
-      file.close
-    end
-    assert_equal("Herld", File.read(tempfile.path))
-  end
-
-  def test_flush
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :readwrite)
-    begin
-      file.write("World")
-      file.flush
-      assert_equal("World", File.read(tempfile.path))
-    ensure
-      file.close
-    end
-  end
-
-  def test_tell
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello World")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :read)
-    begin
-      buffer = " " * 5
-      file.read(buffer)
-      assert_equal(5, file.tell)
-    ensure
-      file.close
-    end
-  end
-
-  def test_mode
-    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
-    tempfile.write("Hello World")
-    tempfile.close
-    file = Arrow::IOMemoryMappedFile.open(tempfile.path, :readwrite)
-    begin
-      assert_equal(Arrow::IOFileMode::READWRITE, file.mode)
-    ensure
-      file.close
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-ipc-file-writer.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-ipc-file-writer.rb b/c_glib/test/test-ipc-file-writer.rb
deleted file mode 100644
index 1c33ccc..0000000
--- a/c_glib/test/test-ipc-file-writer.rb
+++ /dev/null
@@ -1,45 +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 TestIPCFileWriter < Test::Unit::TestCase
-  def test_write_record_batch
-    tempfile = Tempfile.open("arrow-ipc-file-writer")
-    output = Arrow::IOFileOutputStream.open(tempfile.path, false)
-    begin
-      field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
-      schema = Arrow::Schema.new([field])
-      file_writer = Arrow::IPCFileWriter.open(output, schema)
-      begin
-        record_batch = Arrow::RecordBatch.new(schema, 0, [])
-        file_writer.write_record_batch(record_batch)
-      ensure
-        file_writer.close
-      end
-    ensure
-      output.close
-    end
-
-    input = Arrow::IOMemoryMappedFile.open(tempfile.path, :read)
-    begin
-      file_reader = Arrow::IPCFileReader.open(input)
-      assert_equal(["enabled"],
-                   file_reader.schema.fields.collect(&:name))
-    ensure
-      input.close
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-ipc-stream-writer.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-ipc-stream-writer.rb b/c_glib/test/test-ipc-stream-writer.rb
deleted file mode 100644
index 78bb4a7..0000000
--- a/c_glib/test/test-ipc-stream-writer.rb
+++ /dev/null
@@ -1,53 +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 TestIPCStreamWriter < Test::Unit::TestCase
-  include Helper::Buildable
-
-  def test_write_record_batch
-    tempfile = Tempfile.open("arrow-ipc-stream-writer")
-    output = Arrow::IOFileOutputStream.open(tempfile.path, false)
-    begin
-      field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
-      schema = Arrow::Schema.new([field])
-      stream_writer = Arrow::IPCStreamWriter.open(output, schema)
-      begin
-        columns = [
-          build_boolean_array([true]),
-        ]
-        record_batch = Arrow::RecordBatch.new(schema, 1, columns)
-        stream_writer.write_record_batch(record_batch)
-      ensure
-        stream_writer.close
-      end
-    ensure
-      output.close
-    end
-
-    input = Arrow::IOMemoryMappedFile.open(tempfile.path, :read)
-    begin
-      stream_reader = Arrow::IPCStreamReader.open(input)
-      assert_equal(["enabled"],
-                   stream_reader.schema.fields.collect(&:name))
-      assert_equal(true,
-                   stream_reader.next_record_batch.get_column(0).get_value(0))
-      assert_nil(stream_reader.next_record_batch)
-    ensure
-      input.close
-    end
-  end
-end

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-memory-mapped-file.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-memory-mapped-file.rb b/c_glib/test/test-memory-mapped-file.rb
new file mode 100644
index 0000000..e78d07a
--- /dev/null
+++ b/c_glib/test/test-memory-mapped-file.rb
@@ -0,0 +1,138 @@
+# 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 TestMemoryMappedFile < Test::Unit::TestCase
+  def test_open
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :read)
+    begin
+      buffer = " " * 5
+      file.read(buffer)
+      assert_equal("Hello", buffer)
+    ensure
+      file.close
+    end
+  end
+
+  def test_size
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :read)
+    begin
+      assert_equal(5, file.size)
+    ensure
+      file.close
+    end
+  end
+
+  def test_read
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello World")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :read)
+    begin
+      buffer = " " * 5
+      _success, n_read_bytes = file.read(buffer)
+      assert_equal("Hello", buffer.byteslice(0, n_read_bytes))
+    ensure
+      file.close
+    end
+  end
+
+  def test_read_at
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello World")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :read)
+    begin
+      buffer = " " * 5
+      _success, n_read_bytes = file.read_at(6, buffer)
+      assert_equal("World", buffer.byteslice(0, n_read_bytes))
+    ensure
+      file.close
+    end
+  end
+
+  def test_write
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :readwrite)
+    begin
+      file.write("World")
+    ensure
+      file.close
+    end
+    assert_equal("World", File.read(tempfile.path))
+  end
+
+  def test_write_at
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :readwrite)
+    begin
+      file.write_at(2, "rld")
+    ensure
+      file.close
+    end
+    assert_equal("Herld", File.read(tempfile.path))
+  end
+
+  def test_flush
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :readwrite)
+    begin
+      file.write("World")
+      file.flush
+      assert_equal("World", File.read(tempfile.path))
+    ensure
+      file.close
+    end
+  end
+
+  def test_tell
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello World")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :read)
+    begin
+      buffer = " " * 5
+      file.read(buffer)
+      assert_equal(5, file.tell)
+    ensure
+      file.close
+    end
+  end
+
+  def test_mode
+    tempfile = Tempfile.open("arrow-io-memory-mapped-file")
+    tempfile.write("Hello World")
+    tempfile.close
+    file = Arrow::MemoryMappedFile.open(tempfile.path, :readwrite)
+    begin
+      assert_equal(Arrow::FileMode::READWRITE, file.mode)
+    ensure
+      file.close
+    end
+  end
+end

http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/test/test-stream-writer.rb
----------------------------------------------------------------------
diff --git a/c_glib/test/test-stream-writer.rb b/c_glib/test/test-stream-writer.rb
new file mode 100644
index 0000000..306115e
--- /dev/null
+++ b/c_glib/test/test-stream-writer.rb
@@ -0,0 +1,53 @@
+# 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 TestStreamWriter < Test::Unit::TestCase
+  include Helper::Buildable
+
+  def test_write_record_batch
+    tempfile = Tempfile.open("arrow-ipc-stream-writer")
+    output = Arrow::FileOutputStream.open(tempfile.path, false)
+    begin
+      field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
+      schema = Arrow::Schema.new([field])
+      stream_writer = Arrow::StreamWriter.open(output, schema)
+      begin
+        columns = [
+          build_boolean_array([true]),
+        ]
+        record_batch = Arrow::RecordBatch.new(schema, 1, columns)
+        stream_writer.write_record_batch(record_batch)
+      ensure
+        stream_writer.close
+      end
+    ensure
+      output.close
+    end
+
+    input = Arrow::MemoryMappedFile.open(tempfile.path, :read)
+    begin
+      stream_reader = Arrow::StreamReader.open(input)
+      assert_equal(["enabled"],
+                   stream_reader.schema.fields.collect(&:name))
+      assert_equal(true,
+                   stream_reader.next_record_batch.get_column(0).get_value(0))
+      assert_nil(stream_reader.next_record_batch)
+    ensure
+      input.close
+    end
+  end
+end


Mime
View raw message