You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/05/11 12:26:20 UTC
arrow git commit: ARROW-1001: [GLib] Unify writer files
Repository: arrow
Updated Branches:
refs/heads/master 02161456c -> 885654107
ARROW-1001: [GLib] Unify writer files
Author: Kouhei Sutou <ko...@clear-code.com>
Closes #671 from kou/glib-unify-writer-files and squashes the following commits:
f1e58e0 [Kouhei Sutou] [GLib] Unify writer files
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/88565410
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/88565410
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/88565410
Branch: refs/heads/master
Commit: 885654107f367cc92a3ccb9a7b5930de8707f7f5
Parents: 0216145
Author: Kouhei Sutou <ko...@clear-code.com>
Authored: Thu May 11 08:26:14 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Thu May 11 08:26:14 2017 -0400
----------------------------------------------------------------------
c_glib/arrow-glib/Makefile.am | 11 +-
c_glib/arrow-glib/arrow-glib.h | 3 +-
c_glib/arrow-glib/file-writer.cpp | 149 -------------
c_glib/arrow-glib/file-writer.h | 78 -------
c_glib/arrow-glib/file-writer.hpp | 28 ---
c_glib/arrow-glib/stream-writer.cpp | 223 -------------------
c_glib/arrow-glib/stream-writer.h | 82 -------
c_glib/arrow-glib/stream-writer.hpp | 28 ---
c_glib/arrow-glib/writer.cpp | 284 +++++++++++++++++++++++++
c_glib/arrow-glib/writer.h | 137 ++++++++++++
c_glib/arrow-glib/writer.hpp | 31 +++
c_glib/doc/reference/arrow-glib-docs.sgml | 3 +-
12 files changed, 458 insertions(+), 599 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/c_glib/arrow-glib/Makefile.am
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/Makefile.am b/c_glib/arrow-glib/Makefile.am
index 2425072..0f83f56 100644
--- a/c_glib/arrow-glib/Makefile.am
+++ b/c_glib/arrow-glib/Makefile.am
@@ -67,10 +67,9 @@ libarrow_glib_la_headers += \
libarrow_glib_la_headers += \
file-reader.h \
- file-writer.h \
stream-reader.h \
- stream-writer.h \
- metadata-version.h
+ metadata-version.h \
+ writer.h
libarrow_glib_la_generated_headers = \
enums.h
@@ -107,10 +106,9 @@ libarrow_glib_la_sources += \
libarrow_glib_la_sources += \
file-reader.cpp \
- file-writer.cpp \
metadata-version.cpp \
stream-reader.cpp \
- stream-writer.cpp
+ writer.cpp
libarrow_glib_la_cpp_headers = \
array.hpp \
@@ -139,10 +137,9 @@ libarrow_glib_la_cpp_headers += \
libarrow_glib_la_cpp_headers += \
file-reader.hpp \
- file-writer.hpp \
metadata-version.hpp \
stream-reader.hpp \
- stream-writer.hpp
+ writer.hpp
libarrow_glib_la_SOURCES = \
$(libarrow_glib_la_sources) \
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/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 0a06cb8..f98899c 100644
--- a/c_glib/arrow-glib/arrow-glib.h
+++ b/c_glib/arrow-glib/arrow-glib.h
@@ -42,7 +42,6 @@
#include <arrow-glib/writeable-file.h>
#include <arrow-glib/file-reader.h>
-#include <arrow-glib/file-writer.h>
#include <arrow-glib/metadata-version.h>
#include <arrow-glib/stream-reader.h>
-#include <arrow-glib/stream-writer.h>
+#include <arrow-glib/writer.h>
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/c_glib/arrow-glib/file-writer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-writer.cpp b/c_glib/arrow-glib/file-writer.cpp
deleted file mode 100644
index e3c721c..0000000
--- a/c_glib/arrow-glib/file-writer.cpp
+++ /dev/null
@@ -1,149 +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/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>
-#include <arrow-glib/file-writer.hpp>
-
-G_BEGIN_DECLS
-
-/**
- * SECTION: file-writer
- * @short_description: File writer class
- *
- * #GArrowFileWriter is a class for sending data by file based IPC.
- */
-
-G_DEFINE_TYPE(GArrowFileWriter,
- garrow_file_writer,
- GARROW_TYPE_STREAM_WRITER);
-
-static void
-garrow_file_writer_init(GArrowFileWriter *object)
-{
-}
-
-static void
-garrow_file_writer_class_init(GArrowFileWriterClass *klass)
-{
-}
-
-/**
- * garrow_file_writer_new:
- * @sink: The output of the writer.
- * @schema: The schema of the writer.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: (nullable): A newly created #GArrowFileWriter or %NULL on
- * error.
- */
-GArrowFileWriter *
-garrow_file_writer_new(GArrowOutputStream *sink,
- GArrowSchema *schema,
- GError **error)
-{
- std::shared_ptr<arrow::ipc::FileWriter> arrow_file_writer;
- auto status =
- arrow::ipc::FileWriter::Open(garrow_output_stream_get_raw(sink).get(),
- garrow_schema_get_raw(schema),
- &arrow_file_writer);
- if (garrow_error_check(error, status, "[ipc][file-writer][open]")) {
- return garrow_file_writer_new_raw(&arrow_file_writer);
- } else {
- return NULL;
- }
-}
-
-/**
- * garrow_file_writer_write_record_batch:
- * @file_writer: A #GArrowFileWriter.
- * @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_file_writer_write_record_batch(GArrowFileWriter *file_writer,
- GArrowRecordBatch *record_batch,
- GError **error)
-{
- auto arrow_file_writer =
- garrow_file_writer_get_raw(file_writer);
- auto arrow_record_batch =
- garrow_record_batch_get_raw(record_batch);
- auto arrow_record_batch_raw =
- arrow_record_batch.get();
-
- auto status = arrow_file_writer->WriteRecordBatch(*arrow_record_batch_raw);
- return garrow_error_check(error,
- status,
- "[ipc][file-writer][write-record-batch]");
-}
-
-/**
- * garrow_file_writer_close:
- * @file_writer: A #GArrowFileWriter.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: %TRUE on success, %FALSE if there was an error.
- */
-gboolean
-garrow_file_writer_close(GArrowFileWriter *file_writer,
- GError **error)
-{
- auto arrow_file_writer =
- garrow_file_writer_get_raw(file_writer);
-
- auto status = arrow_file_writer->Close();
- return garrow_error_check(error, status, "[ipc][file-writer][close]");
-}
-
-G_END_DECLS
-
-GArrowFileWriter *
-garrow_file_writer_new_raw(std::shared_ptr<arrow::ipc::FileWriter> *arrow_file_writer)
-{
- auto file_writer =
- GARROW_FILE_WRITER(g_object_new(GARROW_TYPE_FILE_WRITER,
- "stream-writer", arrow_file_writer,
- NULL));
- return file_writer;
-}
-
-arrow::ipc::FileWriter *
-garrow_file_writer_get_raw(GArrowFileWriter *file_writer)
-{
- auto arrow_stream_writer =
- garrow_stream_writer_get_raw(GARROW_STREAM_WRITER(file_writer));
- auto arrow_file_writer_raw =
- dynamic_cast<arrow::ipc::FileWriter *>(arrow_stream_writer.get());
- return arrow_file_writer_raw;
-}
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/c_glib/arrow-glib/file-writer.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-writer.h b/c_glib/arrow-glib/file-writer.h
deleted file mode 100644
index 346dc6f..0000000
--- a/c_glib/arrow-glib/file-writer.h
+++ /dev/null
@@ -1,78 +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-glib/stream-writer.h>
-
-G_BEGIN_DECLS
-
-#define GARROW_TYPE_FILE_WRITER \
- (garrow_file_writer_get_type())
-#define GARROW_FILE_WRITER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GARROW_TYPE_FILE_WRITER, \
- GArrowFileWriter))
-#define GARROW_FILE_WRITER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- GARROW_TYPE_FILE_WRITER, \
- GArrowFileWriterClass))
-#define GARROW_IS_FILE_WRITER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- GARROW_TYPE_FILE_WRITER))
-#define GARROW_IS_FILE_WRITER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- GARROW_TYPE_FILE_WRITER))
-#define GARROW_FILE_WRITER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- GARROW_TYPE_FILE_WRITER, \
- GArrowFileWriterClass))
-
-typedef struct _GArrowFileWriter GArrowFileWriter;
-typedef struct _GArrowFileWriterClass GArrowFileWriterClass;
-
-/**
- * GArrowFileWriter:
- *
- * It wraps `arrow::ipc::FileWriter`.
- */
-struct _GArrowFileWriter
-{
- /*< private >*/
- GArrowStreamWriter parent_instance;
-};
-
-struct _GArrowFileWriterClass
-{
- GObjectClass parent_class;
-};
-
-GType garrow_file_writer_get_type(void) G_GNUC_CONST;
-
-GArrowFileWriter *garrow_file_writer_new(GArrowOutputStream *sink,
- GArrowSchema *schema,
- GError **error);
-
-gboolean garrow_file_writer_write_record_batch(GArrowFileWriter *file_writer,
- GArrowRecordBatch *record_batch,
- GError **error);
-gboolean garrow_file_writer_close(GArrowFileWriter *file_writer,
- GError **error);
-
-G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/c_glib/arrow-glib/file-writer.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-writer.hpp b/c_glib/arrow-glib/file-writer.hpp
deleted file mode 100644
index f6a720a..0000000
--- a/c_glib/arrow-glib/file-writer.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/ipc/api.h>
-
-#include <arrow-glib/file-writer.h>
-
-GArrowFileWriter *garrow_file_writer_new_raw(std::shared_ptr<arrow::ipc::FileWriter> *arrow_file_writer);
-arrow::ipc::FileWriter *garrow_file_writer_get_raw(GArrowFileWriter *file_writer);
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/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
deleted file mode 100644
index 45e2fb0..0000000
--- a/c_glib/arrow-glib/stream-writer.cpp
+++ /dev/null
@@ -1,223 +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/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_new:
- * @sink: The output of the writer.
- * @schema: The schema of the writer.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: (nullable): A newly created #GArrowStreamWriter or %NULL on
- * error.
- */
-GArrowStreamWriter *
-garrow_stream_writer_new(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 (garrow_error_check(error, status, "[ipc][stream-writer][open]")) {
- return garrow_stream_writer_new_raw(&arrow_stream_writer);
- } else {
- 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);
- return garrow_error_check(error,
- status,
- "[ipc][stream-writer][write-record-batch]");
-}
-
-/**
- * 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();
- return garrow_error_check(error, status, "[ipc][stream-writer][close]");
-}
-
-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/88565410/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
deleted file mode 100644
index d718b18..0000000
--- a/c_glib/arrow-glib/stream-writer.h
+++ /dev/null
@@ -1,82 +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-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_new(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/88565410/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
deleted file mode 100644
index 994c83b..0000000
--- a/c_glib/arrow-glib/stream-writer.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/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/88565410/c_glib/arrow-glib/writer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writer.cpp b/c_glib/arrow-glib/writer.cpp
new file mode 100644
index 0000000..625a19e
--- /dev/null
+++ b/c_glib/arrow-glib/writer.cpp
@@ -0,0 +1,284 @@
+/*
+ * 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/writer.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: writer
+ * @section_id: writer-classes
+ * @title: Writer classes
+ * @include: arrow-glib/arrow-glib.h
+ *
+ * #GArrowStreamWriter is a class for writing data in stream mode.
+ *
+ * #GArrowFileWriter is a class for writing data in random access
+ * mode.
+ */
+
+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_new:
+ * @sink: The output of the writer.
+ * @schema: The schema of the writer.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GArrowStreamWriter or %NULL on
+ * error.
+ */
+GArrowStreamWriter *
+garrow_stream_writer_new(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 (garrow_error_check(error, status, "[ipc][stream-writer][open]")) {
+ return garrow_stream_writer_new_raw(&arrow_stream_writer);
+ } else {
+ 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);
+ return garrow_error_check(error,
+ status,
+ "[ipc][stream-writer][write-record-batch]");
+}
+
+/**
+ * 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();
+ return garrow_error_check(error, status, "[ipc][stream-writer][close]");
+}
+
+
+G_DEFINE_TYPE(GArrowFileWriter,
+ garrow_file_writer,
+ GARROW_TYPE_STREAM_WRITER);
+
+static void
+garrow_file_writer_init(GArrowFileWriter *object)
+{
+}
+
+static void
+garrow_file_writer_class_init(GArrowFileWriterClass *klass)
+{
+}
+
+/**
+ * garrow_file_writer_new:
+ * @sink: The output of the writer.
+ * @schema: The schema of the writer.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GArrowFileWriter or %NULL on
+ * error.
+ */
+GArrowFileWriter *
+garrow_file_writer_new(GArrowOutputStream *sink,
+ GArrowSchema *schema,
+ GError **error)
+{
+ std::shared_ptr<arrow::ipc::FileWriter> arrow_file_writer;
+ auto status =
+ arrow::ipc::FileWriter::Open(garrow_output_stream_get_raw(sink).get(),
+ garrow_schema_get_raw(schema),
+ &arrow_file_writer);
+ if (garrow_error_check(error, status, "[ipc][file-writer][open]")) {
+ return garrow_file_writer_new_raw(&arrow_file_writer);
+ } else {
+ return NULL;
+ }
+}
+
+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;
+}
+
+GArrowFileWriter *
+garrow_file_writer_new_raw(std::shared_ptr<arrow::ipc::FileWriter> *arrow_file_writer)
+{
+ auto file_writer =
+ GARROW_FILE_WRITER(g_object_new(GARROW_TYPE_FILE_WRITER,
+ "stream-writer", arrow_file_writer,
+ NULL));
+ return file_writer;
+}
+
+arrow::ipc::FileWriter *
+garrow_file_writer_get_raw(GArrowFileWriter *file_writer)
+{
+ auto arrow_stream_writer =
+ garrow_stream_writer_get_raw(GARROW_STREAM_WRITER(file_writer));
+ auto arrow_file_writer_raw =
+ dynamic_cast<arrow::ipc::FileWriter *>(arrow_stream_writer.get());
+ return arrow_file_writer_raw;
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/c_glib/arrow-glib/writer.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writer.h b/c_glib/arrow-glib/writer.h
new file mode 100644
index 0000000..2aaa776
--- /dev/null
+++ b/c_glib/arrow-glib/writer.h
@@ -0,0 +1,137 @@
+/*
+ * 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;
+#ifndef __GTK_DOC_IGNORE__
+typedef struct _GArrowStreamWriterClass GArrowStreamWriterClass;
+#endif
+
+/**
+ * GArrowStreamWriter:
+ *
+ * It wraps `arrow::ipc::StreamWriter`.
+ */
+struct _GArrowStreamWriter
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+#ifndef __GTK_DOC_IGNORE__
+struct _GArrowStreamWriterClass
+{
+ GObjectClass parent_class;
+};
+#endif
+
+GType garrow_stream_writer_get_type(void) G_GNUC_CONST;
+
+GArrowStreamWriter *garrow_stream_writer_new(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);
+
+
+#define GARROW_TYPE_FILE_WRITER \
+ (garrow_file_writer_get_type())
+#define GARROW_FILE_WRITER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_FILE_WRITER, \
+ GArrowFileWriter))
+#define GARROW_FILE_WRITER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_FILE_WRITER, \
+ GArrowFileWriterClass))
+#define GARROW_IS_FILE_WRITER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_FILE_WRITER))
+#define GARROW_IS_FILE_WRITER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_FILE_WRITER))
+#define GARROW_FILE_WRITER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_FILE_WRITER, \
+ GArrowFileWriterClass))
+
+typedef struct _GArrowFileWriter GArrowFileWriter;
+#ifndef __GTK_DOC_IGNORE__
+typedef struct _GArrowFileWriterClass GArrowFileWriterClass;
+#endif
+
+/**
+ * GArrowFileWriter:
+ *
+ * It wraps `arrow::ipc::FileWriter`.
+ */
+struct _GArrowFileWriter
+{
+ /*< private >*/
+ GArrowStreamWriter parent_instance;
+};
+
+#ifndef __GTK_DOC_IGNORE__
+struct _GArrowFileWriterClass
+{
+ GArrowStreamWriterClass parent_class;
+};
+#endif
+
+GType garrow_file_writer_get_type(void) G_GNUC_CONST;
+
+GArrowFileWriter *garrow_file_writer_new(GArrowOutputStream *sink,
+ GArrowSchema *schema,
+ GError **error);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/c_glib/arrow-glib/writer.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/writer.hpp b/c_glib/arrow-glib/writer.hpp
new file mode 100644
index 0000000..199f205
--- /dev/null
+++ b/c_glib/arrow-glib/writer.hpp
@@ -0,0 +1,31 @@
+/*
+ * 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/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);
+
+GArrowFileWriter *garrow_file_writer_new_raw(std::shared_ptr<arrow::ipc::FileWriter> *arrow_file_writer);
+arrow::ipc::FileWriter *garrow_file_writer_get_raw(GArrowFileWriter *file_writer);
http://git-wip-us.apache.org/repos/asf/arrow/blob/88565410/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 8c691de..dae89e2 100644
--- a/c_glib/doc/reference/arrow-glib-docs.sgml
+++ b/c_glib/doc/reference/arrow-glib-docs.sgml
@@ -108,8 +108,7 @@
</chapter>
<chapter id="writer">
<title>Writer</title>
- <xi:include href="xml/file-writer.xml"/>
- <xi:include href="xml/stream-writer.xml"/>
+ <xi:include href="xml/writer.xml"/>
</chapter>
</part>