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/16 14:00:32 UTC
arrow git commit: ARROW-1037: [GLib] Follow reader name change
Repository: arrow
Updated Branches:
refs/heads/master ce0bb5338 -> 8a8e7bb0d
ARROW-1037: [GLib] Follow reader name change
Author: Kouhei Sutou <ko...@clear-code.com>
Closes #695 from kou/glib-follow-reader-name-change and squashes the following commits:
2b4e0bc [Kouhei Sutou] [GLib] Follow reader name change
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/8a8e7bb0
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/8a8e7bb0
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/8a8e7bb0
Branch: refs/heads/master
Commit: 8a8e7bb0da3e92fea17cf174f7193b6a44046168
Parents: ce0bb53
Author: Kouhei Sutou <ko...@clear-code.com>
Authored: Tue May 16 10:00:26 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Tue May 16 10:00:26 2017 -0400
----------------------------------------------------------------------
c_glib/arrow-glib/Makefile.am | 9 +-
c_glib/arrow-glib/arrow-glib.h | 3 +-
c_glib/arrow-glib/arrow-glib.hpp | 6 +-
c_glib/arrow-glib/file-reader.cpp | 249 -------------
c_glib/arrow-glib/file-reader.h | 83 -----
c_glib/arrow-glib/file-reader.hpp | 28 --
c_glib/arrow-glib/reader.cpp | 472 +++++++++++++++++++++++++
c_glib/arrow-glib/reader.h | 196 ++++++++++
c_glib/arrow-glib/reader.hpp | 33 ++
c_glib/arrow-glib/stream-reader.cpp | 221 ------------
c_glib/arrow-glib/stream-reader.h | 80 -----
c_glib/arrow-glib/stream-reader.hpp | 28 --
c_glib/doc/reference/arrow-glib-docs.sgml | 3 +-
c_glib/example/read-batch.c | 11 +-
c_glib/example/read-stream.c | 13 +-
c_glib/test/test-file-writer.rb | 2 +-
c_glib/test/test-stream-writer.rb | 2 +-
17 files changed, 724 insertions(+), 715 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/Makefile.am
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/Makefile.am b/c_glib/arrow-glib/Makefile.am
index 0f83f56..f0bb601 100644
--- a/c_glib/arrow-glib/Makefile.am
+++ b/c_glib/arrow-glib/Makefile.am
@@ -66,9 +66,8 @@ libarrow_glib_la_headers += \
writeable-file.h
libarrow_glib_la_headers += \
- file-reader.h \
- stream-reader.h \
metadata-version.h \
+ reader.h \
writer.h
libarrow_glib_la_generated_headers = \
@@ -105,9 +104,8 @@ libarrow_glib_la_sources += \
writeable-file.cpp
libarrow_glib_la_sources += \
- file-reader.cpp \
metadata-version.cpp \
- stream-reader.cpp \
+ reader.cpp \
writer.cpp
libarrow_glib_la_cpp_headers = \
@@ -136,9 +134,8 @@ libarrow_glib_la_cpp_headers += \
writeable-file.hpp
libarrow_glib_la_cpp_headers += \
- file-reader.hpp \
metadata-version.hpp \
- stream-reader.hpp \
+ reader.hpp \
writer.hpp
libarrow_glib_la_SOURCES = \
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/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 f98899c..7ab9531 100644
--- a/c_glib/arrow-glib/arrow-glib.h
+++ b/c_glib/arrow-glib/arrow-glib.h
@@ -41,7 +41,6 @@
#include <arrow-glib/writeable.h>
#include <arrow-glib/writeable-file.h>
-#include <arrow-glib/file-reader.h>
#include <arrow-glib/metadata-version.h>
-#include <arrow-glib/stream-reader.h>
+#include <arrow-glib/reader.h>
#include <arrow-glib/writer.h>
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/arrow-glib.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/arrow-glib.hpp b/c_glib/arrow-glib/arrow-glib.hpp
index 3184761..ae55070 100644
--- a/c_glib/arrow-glib/arrow-glib.hpp
+++ b/c_glib/arrow-glib/arrow-glib.hpp
@@ -43,8 +43,6 @@
#include <arrow-glib/writeable.hpp>
#include <arrow-glib/writeable-file.hpp>
-#include <arrow-glib/file-reader.hpp>
-#include <arrow-glib/file-writer.hpp>
#include <arrow-glib/metadata-version.hpp>
-#include <arrow-glib/stream-reader.hpp>
-#include <arrow-glib/stream-writer.hpp>
+#include <arrow-glib/reader.hpp>
+#include <arrow-glib/writer.hpp>
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/file-reader.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-reader.cpp b/c_glib/arrow-glib/file-reader.cpp
deleted file mode 100644
index c16bf19..0000000
--- a/c_glib/arrow-glib/file-reader.cpp
+++ /dev/null
@@ -1,249 +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/error.hpp>
-#include <arrow-glib/record-batch.hpp>
-#include <arrow-glib/schema.hpp>
-
-#include <arrow-glib/input-stream.hpp>
-
-#include <arrow-glib/file-reader.hpp>
-#include <arrow-glib/metadata-version.hpp>
-
-G_BEGIN_DECLS
-
-/**
- * SECTION: file-reader
- * @short_description: File reader class
- *
- * #GArrowFileReader is a class for receiving data by file based IPC.
- */
-
-typedef struct GArrowFileReaderPrivate_ {
- std::shared_ptr<arrow::ipc::FileReader> file_reader;
-} GArrowFileReaderPrivate;
-
-enum {
- PROP_0,
- PROP_FILE_READER
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE(GArrowFileReader,
- garrow_file_reader,
- G_TYPE_OBJECT);
-
-#define GARROW_FILE_READER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
- GARROW_TYPE_FILE_READER, \
- GArrowFileReaderPrivate))
-
-static void
-garrow_file_reader_finalize(GObject *object)
-{
- GArrowFileReaderPrivate *priv;
-
- priv = GARROW_FILE_READER_GET_PRIVATE(object);
-
- priv->file_reader = nullptr;
-
- G_OBJECT_CLASS(garrow_file_reader_parent_class)->finalize(object);
-}
-
-static void
-garrow_file_reader_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GArrowFileReaderPrivate *priv;
-
- priv = GARROW_FILE_READER_GET_PRIVATE(object);
-
- switch (prop_id) {
- case PROP_FILE_READER:
- priv->file_reader =
- *static_cast<std::shared_ptr<arrow::ipc::FileReader> *>(g_value_get_pointer(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-garrow_file_reader_get_property(GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-garrow_file_reader_init(GArrowFileReader *object)
-{
-}
-
-static void
-garrow_file_reader_class_init(GArrowFileReaderClass *klass)
-{
- GObjectClass *gobject_class;
- GParamSpec *spec;
-
- gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->finalize = garrow_file_reader_finalize;
- gobject_class->set_property = garrow_file_reader_set_property;
- gobject_class->get_property = garrow_file_reader_get_property;
-
- spec = g_param_spec_pointer("file-reader",
- "ipc::FileReader",
- "The raw std::shared<arrow::ipc::FileReader> *",
- static_cast<GParamFlags>(G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property(gobject_class, PROP_FILE_READER, spec);
-}
-
-/**
- * garrow_file_reader_new:
- * @input_stream: The seekable input stream to read data.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: (nullable): A newly created #GArrowFileReader or %NULL on
- * error.
- */
-GArrowFileReader *
-garrow_file_reader_new(GArrowSeekableInputStream *input_stream,
- GError **error)
-{
- auto arrow_random_access_file =
- garrow_seekable_input_stream_get_raw(input_stream);
- std::shared_ptr<arrow::ipc::FileReader> arrow_file_reader;
- auto status =
- arrow::ipc::FileReader::Open(arrow_random_access_file,
- &arrow_file_reader);
- if (garrow_error_check(error, status, "[ipc][file-reader][open]")) {
- return garrow_file_reader_new_raw(&arrow_file_reader);
- } else {
- return NULL;
- }
-}
-
-/**
- * garrow_file_reader_get_schema:
- * @file_reader: A #GArrowFileReader.
- *
- * Returns: (transfer full): The schema in the file.
- */
-GArrowSchema *
-garrow_file_reader_get_schema(GArrowFileReader *file_reader)
-{
- auto arrow_file_reader =
- garrow_file_reader_get_raw(file_reader);
- auto arrow_schema = arrow_file_reader->schema();
- return garrow_schema_new_raw(&arrow_schema);
-}
-
-/**
- * garrow_file_reader_get_n_record_batches:
- * @file_reader: A #GArrowFileReader.
- *
- * Returns: The number of record batches in the file.
- */
-guint
-garrow_file_reader_get_n_record_batches(GArrowFileReader *file_reader)
-{
- auto arrow_file_reader =
- garrow_file_reader_get_raw(file_reader);
- return arrow_file_reader->num_record_batches();
-}
-
-/**
- * garrow_file_reader_get_version:
- * @file_reader: A #GArrowFileReader.
- *
- * Returns: The format version in the file.
- */
-GArrowMetadataVersion
-garrow_file_reader_get_version(GArrowFileReader *file_reader)
-{
- auto arrow_file_reader =
- garrow_file_reader_get_raw(file_reader);
- auto arrow_version = arrow_file_reader->version();
- return garrow_metadata_version_from_raw(arrow_version);
-}
-
-/**
- * garrow_file_reader_get_record_batch:
- * @file_reader: A #GArrowFileReader.
- * @i: The index of the target record batch.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: (nullable) (transfer full):
- * The i-th record batch in the file or %NULL on error.
- */
-GArrowRecordBatch *
-garrow_file_reader_get_record_batch(GArrowFileReader *file_reader,
- guint i,
- GError **error)
-{
- auto arrow_file_reader =
- garrow_file_reader_get_raw(file_reader);
- std::shared_ptr<arrow::RecordBatch> arrow_record_batch;
- auto status = arrow_file_reader->GetRecordBatch(i, &arrow_record_batch);
-
- if (garrow_error_check(error,
- status,
- "[ipc][file-reader][get-record-batch]")) {
- return garrow_record_batch_new_raw(&arrow_record_batch);
- } else {
- return NULL;
- }
-}
-
-G_END_DECLS
-
-GArrowFileReader *
-garrow_file_reader_new_raw(std::shared_ptr<arrow::ipc::FileReader> *arrow_file_reader)
-{
- auto file_reader =
- GARROW_FILE_READER(g_object_new(GARROW_TYPE_FILE_READER,
- "file-reader", arrow_file_reader,
- NULL));
- return file_reader;
-}
-
-std::shared_ptr<arrow::ipc::FileReader>
-garrow_file_reader_get_raw(GArrowFileReader *file_reader)
-{
- GArrowFileReaderPrivate *priv;
-
- priv = GARROW_FILE_READER_GET_PRIVATE(file_reader);
- return priv->file_reader;
-}
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/file-reader.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-reader.h b/c_glib/arrow-glib/file-reader.h
deleted file mode 100644
index 551e05a..0000000
--- a/c_glib/arrow-glib/file-reader.h
+++ /dev/null
@@ -1,83 +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/record-batch.h>
-#include <arrow-glib/schema.h>
-
-#include <arrow-glib/input-stream.h>
-
-#include <arrow-glib/metadata-version.h>
-
-G_BEGIN_DECLS
-
-#define GARROW_TYPE_FILE_READER \
- (garrow_file_reader_get_type())
-#define GARROW_FILE_READER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GARROW_TYPE_FILE_READER, \
- GArrowFileReader))
-#define GARROW_FILE_READER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- GARROW_TYPE_FILE_READER, \
- GArrowFileReaderClass))
-#define GARROW_IS_FILE_READER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- GARROW_TYPE_FILE_READER))
-#define GARROW_IS_FILE_READER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- GARROW_TYPE_FILE_READER))
-#define GARROW_FILE_READER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- GARROW_TYPE_FILE_READER, \
- GArrowFileReaderClass))
-
-typedef struct _GArrowFileReader GArrowFileReader;
-typedef struct _GArrowFileReaderClass GArrowFileReaderClass;
-
-/**
- * GArrowFileReader:
- *
- * It wraps `arrow::ipc::FileReader`.
- */
-struct _GArrowFileReader
-{
- /*< private >*/
- GObject parent_instance;
-};
-
-struct _GArrowFileReaderClass
-{
- GObjectClass parent_class;
-};
-
-GType garrow_file_reader_get_type(void) G_GNUC_CONST;
-
-GArrowFileReader *garrow_file_reader_new(GArrowSeekableInputStream *input_stream,
- GError **error);
-
-GArrowSchema *garrow_file_reader_get_schema(GArrowFileReader *file_reader);
-guint garrow_file_reader_get_n_record_batches(GArrowFileReader *file_reader);
-GArrowMetadataVersion garrow_file_reader_get_version(GArrowFileReader *file_reader);
-GArrowRecordBatch *garrow_file_reader_get_record_batch(GArrowFileReader *file_reader,
- guint i,
- GError **error);
-
-G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/file-reader.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/file-reader.hpp b/c_glib/arrow-glib/file-reader.hpp
deleted file mode 100644
index 152379b..0000000
--- a/c_glib/arrow-glib/file-reader.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-reader.h>
-
-GArrowFileReader *garrow_file_reader_new_raw(std::shared_ptr<arrow::ipc::FileReader> *arrow_file_reader);
-std::shared_ptr<arrow::ipc::FileReader> garrow_file_reader_get_raw(GArrowFileReader *file_reader);
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/reader.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/reader.cpp b/c_glib/arrow-glib/reader.cpp
new file mode 100644
index 0000000..c092324
--- /dev/null
+++ b/c_glib/arrow-glib/reader.cpp
@@ -0,0 +1,472 @@
+/*
+ * 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/error.hpp>
+#include <arrow-glib/record-batch.hpp>
+#include <arrow-glib/schema.hpp>
+
+#include <arrow-glib/input-stream.hpp>
+
+#include <arrow-glib/metadata-version.hpp>
+#include <arrow-glib/reader.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: reader
+ * @section_id: reader-classes
+ * @title: Reader classes
+ * @include: arrow-glib/arrow-glib.h
+ *
+ * #GArrowRecordBatchReader is a base class for reading record batches
+ * in stream format from input.
+ *
+ * #GArrowRecordBatchStreamReader is a class for reading record
+ * batches in stream format from input synchronously.
+ *
+ * #GArrowRecordBatchFileReader is a class for reading record
+ * batches in file format from input.
+ */
+
+typedef struct GArrowRecordBatchReaderPrivate_ {
+ std::shared_ptr<arrow::ipc::RecordBatchReader> record_batch_reader;
+} GArrowRecordBatchReaderPrivate;
+
+enum {
+ PROP_0,
+ PROP_RECORD_BATCH_READER
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowRecordBatchReader,
+ garrow_record_batch_reader,
+ G_TYPE_OBJECT);
+
+#define GARROW_RECORD_BATCH_READER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GARROW_TYPE_RECORD_BATCH_READER, \
+ GArrowRecordBatchReaderPrivate))
+
+static void
+garrow_record_batch_reader_finalize(GObject *object)
+{
+ GArrowRecordBatchReaderPrivate *priv;
+
+ priv = GARROW_RECORD_BATCH_READER_GET_PRIVATE(object);
+
+ priv->record_batch_reader = nullptr;
+
+ G_OBJECT_CLASS(garrow_record_batch_reader_parent_class)->finalize(object);
+}
+
+static void
+garrow_record_batch_reader_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GArrowRecordBatchReaderPrivate *priv;
+
+ priv = GARROW_RECORD_BATCH_READER_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_RECORD_BATCH_READER:
+ priv->record_batch_reader =
+ *static_cast<std::shared_ptr<arrow::ipc::RecordBatchReader> *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_record_batch_reader_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_record_batch_reader_init(GArrowRecordBatchReader *object)
+{
+}
+
+static void
+garrow_record_batch_reader_class_init(GArrowRecordBatchReaderClass *klass)
+{
+ GObjectClass *gobject_class;
+ GParamSpec *spec;
+
+ gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = garrow_record_batch_reader_finalize;
+ gobject_class->set_property = garrow_record_batch_reader_set_property;
+ gobject_class->get_property = garrow_record_batch_reader_get_property;
+
+ spec = g_param_spec_pointer("record-batch-reader",
+ "arrow::ipc::RecordBatchReader",
+ "The raw std::shared<arrow::ipc::RecordBatchRecordBatchReader> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_RECORD_BATCH_READER, spec);
+}
+
+/**
+ * garrow_record_batch_reader_get_schema:
+ * @reader: A #GArrowRecordBatchReader.
+ *
+ * Returns: (transfer full): The schema in the stream.
+ *
+ * Since: 0.4.0
+ */
+GArrowSchema *
+garrow_record_batch_reader_get_schema(GArrowRecordBatchReader *reader)
+{
+ auto arrow_reader = garrow_record_batch_reader_get_raw(reader);
+ auto arrow_schema = arrow_reader->schema();
+ return garrow_schema_new_raw(&arrow_schema);
+}
+
+/**
+ * garrow_record_batch_reader_get_next_record_batch:
+ * @reader: A #GArrowRecordBatchReader.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full):
+ * The next record batch in the stream or %NULL on end of stream.
+ *
+ * Since: 0.4.0
+ */
+GArrowRecordBatch *
+garrow_record_batch_reader_get_next_record_batch(GArrowRecordBatchReader *reader,
+ GError **error)
+{
+ auto arrow_reader = garrow_record_batch_reader_get_raw(reader);
+ std::shared_ptr<arrow::RecordBatch> arrow_record_batch;
+ auto status = arrow_reader->GetNextRecordBatch(&arrow_record_batch);
+
+ if (garrow_error_check(error,
+ status,
+ "[record-batch-reader][get-next-record-batch]")) {
+ if (arrow_record_batch == nullptr) {
+ return NULL;
+ } else {
+ return garrow_record_batch_new_raw(&arrow_record_batch);
+ }
+ } else {
+ return NULL;
+ }
+}
+
+
+G_DEFINE_TYPE(GArrowRecordBatchStreamReader,
+ garrow_record_batch_stream_reader,
+ GARROW_TYPE_RECORD_BATCH_READER);
+
+static void
+garrow_record_batch_stream_reader_init(GArrowRecordBatchStreamReader *object)
+{
+}
+
+static void
+garrow_record_batch_stream_reader_class_init(GArrowRecordBatchStreamReaderClass *klass)
+{
+}
+
+/**
+ * garrow_record_batch_stream_reader_new:
+ * @stream: The stream to be read.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GArrowRecordBatchStreamReader
+ * or %NULL on error.
+ *
+ * Since: 0.4.0
+ */
+GArrowRecordBatchStreamReader *
+garrow_record_batch_stream_reader_new(GArrowInputStream *stream,
+ GError **error)
+{
+ auto arrow_input_stream = garrow_input_stream_get_raw(stream);
+ std::shared_ptr<arrow::ipc::RecordBatchStreamReader> arrow_reader;
+ auto status =
+ arrow::ipc::RecordBatchStreamReader::Open(arrow_input_stream, &arrow_reader);
+ if (garrow_error_check(error, status, "[record-batch-stream-reader][open]")) {
+ return garrow_record_batch_stream_reader_new_raw(&arrow_reader);
+ } else {
+ return NULL;
+ }
+}
+
+
+typedef struct GArrowRecordBatchFileReaderPrivate_ {
+ std::shared_ptr<arrow::ipc::RecordBatchFileReader> record_batch_file_reader;
+} GArrowRecordBatchFileReaderPrivate;
+
+enum {
+ PROP_0_,
+ PROP_RECORD_BATCH_FILE_READER
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(GArrowRecordBatchFileReader,
+ garrow_record_batch_file_reader,
+ G_TYPE_OBJECT);
+
+#define GARROW_RECORD_BATCH_FILE_READER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GARROW_TYPE_RECORD_BATCH_FILE_READER, \
+ GArrowRecordBatchFileReaderPrivate))
+
+static void
+garrow_record_batch_file_reader_finalize(GObject *object)
+{
+ GArrowRecordBatchFileReaderPrivate *priv;
+
+ priv = GARROW_RECORD_BATCH_FILE_READER_GET_PRIVATE(object);
+
+ priv->record_batch_file_reader = nullptr;
+
+ G_OBJECT_CLASS(garrow_record_batch_file_reader_parent_class)->finalize(object);
+}
+
+static void
+garrow_record_batch_file_reader_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GArrowRecordBatchFileReaderPrivate *priv;
+
+ priv = GARROW_RECORD_BATCH_FILE_READER_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_RECORD_BATCH_FILE_READER:
+ priv->record_batch_file_reader =
+ *static_cast<std::shared_ptr<arrow::ipc::RecordBatchFileReader> *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_record_batch_file_reader_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_record_batch_file_reader_init(GArrowRecordBatchFileReader *object)
+{
+}
+
+static void
+garrow_record_batch_file_reader_class_init(GArrowRecordBatchFileReaderClass *klass)
+{
+ GObjectClass *gobject_class;
+ GParamSpec *spec;
+
+ gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = garrow_record_batch_file_reader_finalize;
+ gobject_class->set_property = garrow_record_batch_file_reader_set_property;
+ gobject_class->get_property = garrow_record_batch_file_reader_get_property;
+
+ spec = g_param_spec_pointer("record-batch-file-reader",
+ "arrow::ipc::RecordBatchFileReader",
+ "The raw std::shared<arrow::ipc::RecordBatchFileReader> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_RECORD_BATCH_FILE_READER, spec);
+}
+
+
+/**
+ * garrow_record_batch_file_reader_new:
+ * @file: The file to be read.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable): A newly created #GArrowRecordBatchFileReader
+ * or %NULL on error.
+ *
+ * Since: 0.4.0
+ */
+GArrowRecordBatchFileReader *
+garrow_record_batch_file_reader_new(GArrowSeekableInputStream *file,
+ GError **error)
+{
+ auto arrow_random_access_file = garrow_seekable_input_stream_get_raw(file);
+ std::shared_ptr<arrow::ipc::RecordBatchFileReader> arrow_reader;
+ auto status =
+ arrow::ipc::RecordBatchFileReader::Open(arrow_random_access_file,
+ &arrow_reader);
+ if (garrow_error_check(error, status, "[record-batch-file-reader][open]")) {
+ return garrow_record_batch_file_reader_new_raw(&arrow_reader);
+ } else {
+ return NULL;
+ }
+}
+
+/**
+ * garrow_record_batch_file_reader_get_schema:
+ * @reader: A #GArrowRecordBatchFileReader.
+ *
+ * Returns: (transfer full): The schema in the file.
+ *
+ * Since: 0.4.0
+ */
+GArrowSchema *
+garrow_record_batch_file_reader_get_schema(GArrowRecordBatchFileReader *reader)
+{
+ auto arrow_reader = garrow_record_batch_file_reader_get_raw(reader);
+ auto arrow_schema = arrow_reader->schema();
+ return garrow_schema_new_raw(&arrow_schema);
+}
+
+/**
+ * garrow_record_batch_file_reader_get_n_record_batches:
+ * @reader: A #GArrowRecordBatchFileReader.
+ *
+ * Returns: The number of record batches in the file.
+ *
+ * Since: 0.4.0
+ */
+guint
+garrow_record_batch_file_reader_get_n_record_batches(GArrowRecordBatchFileReader *reader)
+{
+ auto arrow_reader = garrow_record_batch_file_reader_get_raw(reader);
+ return arrow_reader->num_record_batches();
+}
+
+/**
+ * garrow_record_batch_file_reader_get_version:
+ * @reader: A #GArrowRecordBatchFileReader.
+ *
+ * Returns: The format version in the file.
+ *
+ * Since: 0.4.0
+ */
+GArrowMetadataVersion
+garrow_record_batch_file_reader_get_version(GArrowRecordBatchFileReader *reader)
+{
+ auto arrow_reader = garrow_record_batch_file_reader_get_raw(reader);
+ auto arrow_version = arrow_reader->version();
+ return garrow_metadata_version_from_raw(arrow_version);
+}
+
+/**
+ * garrow_record_batch_file_reader_get_record_batch:
+ * @reader: A #GArrowRecordBatchFileReader.
+ * @i: The index of the target record batch.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full):
+ * The i-th record batch in the file or %NULL on error.
+ *
+ * Since: 0.4.0
+ */
+GArrowRecordBatch *
+garrow_record_batch_file_reader_get_record_batch(GArrowRecordBatchFileReader *reader,
+ guint i,
+ GError **error)
+{
+ auto arrow_reader = garrow_record_batch_file_reader_get_raw(reader);
+ std::shared_ptr<arrow::RecordBatch> arrow_record_batch;
+ auto status = arrow_reader->GetRecordBatch(i, &arrow_record_batch);
+
+ if (garrow_error_check(error,
+ status,
+ "[record-batch-file-reader][get-record-batch]")) {
+ return garrow_record_batch_new_raw(&arrow_record_batch);
+ } else {
+ return NULL;
+ }
+}
+
+G_END_DECLS
+
+GArrowRecordBatchReader *
+garrow_record_batch_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchReader> *arrow_reader)
+{
+ auto reader =
+ GARROW_RECORD_BATCH_READER(g_object_new(GARROW_TYPE_RECORD_BATCH_READER,
+ "record-batch-reader", arrow_reader,
+ NULL));
+ return reader;
+}
+
+std::shared_ptr<arrow::ipc::RecordBatchReader>
+garrow_record_batch_reader_get_raw(GArrowRecordBatchReader *reader)
+{
+ GArrowRecordBatchReaderPrivate *priv;
+
+ priv = GARROW_RECORD_BATCH_READER_GET_PRIVATE(reader);
+ return priv->record_batch_reader;
+}
+
+GArrowRecordBatchStreamReader *
+garrow_record_batch_stream_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchStreamReader> *arrow_reader)
+{
+ auto reader =
+ GARROW_RECORD_BATCH_STREAM_READER(
+ g_object_new(GARROW_TYPE_RECORD_BATCH_STREAM_READER,
+ "record-batch-reader", arrow_reader,
+ NULL));
+ return reader;
+}
+
+GArrowRecordBatchFileReader *
+garrow_record_batch_file_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchFileReader> *arrow_reader)
+{
+ auto reader =
+ GARROW_RECORD_BATCH_FILE_READER(
+ g_object_new(GARROW_TYPE_RECORD_BATCH_FILE_READER,
+ "record-batch-file-reader", arrow_reader,
+ NULL));
+ return reader;
+}
+
+std::shared_ptr<arrow::ipc::RecordBatchFileReader>
+garrow_record_batch_file_reader_get_raw(GArrowRecordBatchFileReader *reader)
+{
+ GArrowRecordBatchFileReaderPrivate *priv;
+
+ priv = GARROW_RECORD_BATCH_FILE_READER_GET_PRIVATE(reader);
+ return priv->record_batch_file_reader;
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/reader.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/reader.h b/c_glib/arrow-glib/reader.h
new file mode 100644
index 0000000..477204b
--- /dev/null
+++ b/c_glib/arrow-glib/reader.h
@@ -0,0 +1,196 @@
+/*
+ * 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/record-batch.h>
+#include <arrow-glib/schema.h>
+
+#include <arrow-glib/input-stream.h>
+
+#include <arrow-glib/metadata-version.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_RECORD_BATCH_READER \
+ (garrow_record_batch_reader_get_type())
+#define GARROW_RECORD_BATCH_READER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_RECORD_BATCH_READER, \
+ GArrowRecordBatchReader))
+#define GARROW_RECORD_BATCH_READER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_RECORD_BATCH_READER, \
+ GArrowRecordBatchReaderClass))
+#define GARROW_IS_RECORD_BATCH_READER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_RECORD_BATCH_READER))
+#define GARROW_IS_RECORD_BATCH_READER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_RECORD_BATCH_READER))
+#define GARROW_RECORD_BATCH_READER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_RECORD_BATCH_READER, \
+ GArrowRecordBatchReaderClass))
+
+typedef struct _GArrowRecordBatchReader GArrowRecordBatchReader;
+#ifndef __GTK_DOC_IGNORE__
+typedef struct _GArrowRecordBatchReaderClass GArrowRecordBatchReaderClass;
+#endif
+
+/**
+ * GArrowRecordBatchReader:
+ *
+ * It wraps `arrow::ipc::RecordBatchReader`.
+ */
+struct _GArrowRecordBatchReader
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+#ifndef __GTK_DOC_IGNORE__
+struct _GArrowRecordBatchReaderClass
+{
+ GObjectClass parent_class;
+};
+#endif
+
+GType garrow_record_batch_reader_get_type(void) G_GNUC_CONST;
+
+GArrowSchema *garrow_record_batch_reader_get_schema(
+ GArrowRecordBatchReader *reader);
+GArrowRecordBatch *garrow_record_batch_reader_get_next_record_batch(
+ GArrowRecordBatchReader *reader,
+ GError **error);
+
+
+#define GARROW_TYPE_RECORD_BATCH_STREAM_READER \
+ (garrow_record_batch_stream_reader_get_type())
+#define GARROW_RECORD_BATCH_STREAM_READER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_RECORD_BATCH_STREAM_READER, \
+ GArrowRecordBatchStreamReader))
+#define GARROW_RECORD_BATCH_STREAM_READER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_RECORD_BATCH_STREAM_READER, \
+ GArrowRecordBatchStreamReaderClass))
+#define GARROW_IS_RECORD_BATCH_STREAM_READER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_RECORD_BATCH_STREAM_READER))
+#define GARROW_IS_RECORD_BATCH_STREAM_READER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_RECORD_BATCH_STREAM_READER))
+#define GARROW_RECORD_BATCH_STREAM_READER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_RECORD_BATCH_STREAM_READER, \
+ GArrowRecordBatchStreamReaderClass))
+
+typedef struct _GArrowRecordBatchStreamReader GArrowRecordBatchStreamReader;
+#ifndef __GTK_DOC_IGNORE__
+typedef struct _GArrowRecordBatchStreamReaderClass GArrowRecordBatchStreamReaderClass;
+#endif
+
+/**
+ * GArrowRecordBatchStreamReader:
+ *
+ * It wraps `arrow::ipc::RecordBatchStreamReader`.
+ */
+struct _GArrowRecordBatchStreamReader
+{
+ /*< private >*/
+ GArrowRecordBatchReader parent_instance;
+};
+
+#ifndef __GTK_DOC_IGNORE__
+struct _GArrowRecordBatchStreamReaderClass
+{
+ GArrowRecordBatchReaderClass parent_class;
+};
+#endif
+
+GType garrow_record_batch_stream_reader_get_type(void) G_GNUC_CONST;
+
+GArrowRecordBatchStreamReader *garrow_record_batch_stream_reader_new(
+ GArrowInputStream *stream,
+ GError **error);
+
+
+#define GARROW_TYPE_RECORD_BATCH_FILE_READER \
+ (garrow_record_batch_file_reader_get_type())
+#define GARROW_RECORD_BATCH_FILE_READER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_RECORD_BATCH_FILE_READER, \
+ GArrowRecordBatchFileReader))
+#define GARROW_RECORD_BATCH_FILE_READER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_RECORD_BATCH_FILE_READER, \
+ GArrowRecordBatchFileReaderClass))
+#define GARROW_IS_RECORD_BATCH_FILE_READER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_RECORD_BATCH_FILE_READER))
+#define GARROW_IS_RECORD_BATCH_FILE_READER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_RECORD_BATCH_FILE_READER))
+#define GARROW_RECORD_BATCH_FILE_READER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_RECORD_BATCH_FILE_READER, \
+ GArrowRecordBatchFileReaderClass))
+
+typedef struct _GArrowRecordBatchFileReader GArrowRecordBatchFileReader;
+#ifndef __GTK_DOC_IGNORE__
+typedef struct _GArrowRecordBatchFileReaderClass GArrowRecordBatchFileReaderClass;
+#endif
+
+/**
+ * GArrowRecordBatchFileReader:
+ *
+ * It wraps `arrow::ipc::RecordBatchFileReader`.
+ */
+struct _GArrowRecordBatchFileReader
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+#ifndef __GTK_DOC_IGNORE__
+struct _GArrowRecordBatchFileReaderClass
+{
+ GObjectClass parent_class;
+};
+#endif
+
+GType garrow_record_batch_file_reader_get_type(void) G_GNUC_CONST;
+
+GArrowRecordBatchFileReader *garrow_record_batch_file_reader_new(
+ GArrowSeekableInputStream *file,
+ GError **error);
+
+GArrowSchema *garrow_record_batch_file_reader_get_schema(
+ GArrowRecordBatchFileReader *reader);
+guint garrow_record_batch_file_reader_get_n_record_batches(
+ GArrowRecordBatchFileReader *reader);
+GArrowMetadataVersion garrow_record_batch_file_reader_get_version(
+ GArrowRecordBatchFileReader *reader);
+GArrowRecordBatch *garrow_record_batch_file_reader_get_record_batch(
+ GArrowRecordBatchFileReader *reader,
+ guint i,
+ GError **error);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/reader.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/reader.hpp b/c_glib/arrow-glib/reader.hpp
new file mode 100644
index 0000000..7d0b24a
--- /dev/null
+++ b/c_glib/arrow-glib/reader.hpp
@@ -0,0 +1,33 @@
+/*
+ * 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/reader.h>
+
+GArrowRecordBatchReader *garrow_record_batch_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchReader> *arrow_reader);
+std::shared_ptr<arrow::ipc::RecordBatchReader> garrow_record_batch_reader_get_raw(GArrowRecordBatchReader *reader);
+
+GArrowRecordBatchStreamReader *garrow_record_batch_stream_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchStreamReader> *arrow_reader);
+
+GArrowRecordBatchFileReader *garrow_record_batch_file_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchFileReader> *arrow_reader);
+std::shared_ptr<arrow::ipc::RecordBatchFileReader> garrow_record_batch_file_reader_get_raw(GArrowRecordBatchFileReader *reader);
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/stream-reader.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-reader.cpp b/c_glib/arrow-glib/stream-reader.cpp
deleted file mode 100644
index 19c36c2..0000000
--- a/c_glib/arrow-glib/stream-reader.cpp
+++ /dev/null
@@ -1,221 +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/error.hpp>
-#include <arrow-glib/record-batch.hpp>
-#include <arrow-glib/schema.hpp>
-
-#include <arrow-glib/input-stream.hpp>
-
-#include <arrow-glib/metadata-version.hpp>
-#include <arrow-glib/stream-reader.hpp>
-
-G_BEGIN_DECLS
-
-/**
- * SECTION: stream-reader
- * @short_description: Stream reader class
- *
- * #GArrowStreamReader is a class for receiving data by stream
- * based IPC.
- */
-
-typedef struct GArrowStreamReaderPrivate_ {
- std::shared_ptr<arrow::ipc::RecordBatchStreamReader> stream_reader;
-} GArrowStreamReaderPrivate;
-
-enum {
- PROP_0,
- PROP_STREAM_READER
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE(GArrowStreamReader,
- garrow_stream_reader,
- G_TYPE_OBJECT);
-
-#define GARROW_STREAM_READER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
- GARROW_TYPE_STREAM_READER, \
- GArrowStreamReaderPrivate))
-
-static void
-garrow_stream_reader_finalize(GObject *object)
-{
- GArrowStreamReaderPrivate *priv;
-
- priv = GARROW_STREAM_READER_GET_PRIVATE(object);
-
- priv->stream_reader = nullptr;
-
- G_OBJECT_CLASS(garrow_stream_reader_parent_class)->finalize(object);
-}
-
-static void
-garrow_stream_reader_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GArrowStreamReaderPrivate *priv;
-
- priv = GARROW_STREAM_READER_GET_PRIVATE(object);
-
- switch (prop_id) {
- case PROP_STREAM_READER:
- priv->stream_reader =
- *static_cast<std::shared_ptr<arrow::ipc::RecordBatchStreamReader> *>(g_value_get_pointer(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-garrow_stream_reader_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_reader_init(GArrowStreamReader *object)
-{
-}
-
-static void
-garrow_stream_reader_class_init(GArrowStreamReaderClass *klass)
-{
- GObjectClass *gobject_class;
- GParamSpec *spec;
-
- gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->finalize = garrow_stream_reader_finalize;
- gobject_class->set_property = garrow_stream_reader_set_property;
- gobject_class->get_property = garrow_stream_reader_get_property;
-
- spec = g_param_spec_pointer("stream-reader",
- "ipc::RecordBatchStreamReader",
- "The raw std::shared<arrow::ipc::RecordBatchStreamReader> *",
- static_cast<GParamFlags>(G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property(gobject_class, PROP_STREAM_READER, spec);
-}
-
-/**
- * garrow_stream_reader_new:
- * @stream: The stream to be read.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: (nullable): A newly created #GArrowStreamReader or %NULL
- * on error.
- */
-GArrowStreamReader *
-garrow_stream_reader_new(GArrowInputStream *stream,
- GError **error)
-{
- std::shared_ptr<arrow::ipc::RecordBatchStreamReader> arrow_stream_reader;
- auto status =
- arrow::ipc::RecordBatchStreamReader::Open(garrow_input_stream_get_raw(stream),
- &arrow_stream_reader);
- if (garrow_error_check(error, status, "[ipc][stream-reader][open]")) {
- return garrow_stream_reader_new_raw(&arrow_stream_reader);
- } else {
- return NULL;
- }
-}
-
-/**
- * garrow_stream_reader_get_schema:
- * @stream_reader: A #GArrowStreamReader.
- *
- * Returns: (transfer full): The schema in the stream.
- */
-GArrowSchema *
-garrow_stream_reader_get_schema(GArrowStreamReader *stream_reader)
-{
- auto arrow_stream_reader =
- garrow_stream_reader_get_raw(stream_reader);
- auto arrow_schema = arrow_stream_reader->schema();
- return garrow_schema_new_raw(&arrow_schema);
-}
-
-/**
- * garrow_stream_reader_get_next_record_batch:
- * @stream_reader: A #GArrowStreamReader.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: (nullable) (transfer full):
- * The next record batch in the stream or %NULL on end of stream.
- */
-GArrowRecordBatch *
-garrow_stream_reader_get_next_record_batch(GArrowStreamReader *stream_reader,
- GError **error)
-{
- auto arrow_stream_reader =
- garrow_stream_reader_get_raw(stream_reader);
- std::shared_ptr<arrow::RecordBatch> arrow_record_batch;
- auto status = arrow_stream_reader->GetNextRecordBatch(&arrow_record_batch);
-
- if (garrow_error_check(error,
- status,
- "[ipc][stream-reader][get-next-record-batch]")) {
- if (arrow_record_batch == nullptr) {
- return NULL;
- } else {
- return garrow_record_batch_new_raw(&arrow_record_batch);
- }
- } else {
- return NULL;
- }
-}
-
-G_END_DECLS
-
-GArrowStreamReader *
-garrow_stream_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchStreamReader> *arrow_stream_reader)
-{
- auto stream_reader =
- GARROW_STREAM_READER(g_object_new(GARROW_TYPE_STREAM_READER,
- "stream-reader", arrow_stream_reader,
- NULL));
- return stream_reader;
-}
-
-std::shared_ptr<arrow::ipc::RecordBatchStreamReader>
-garrow_stream_reader_get_raw(GArrowStreamReader *stream_reader)
-{
- GArrowStreamReaderPrivate *priv;
-
- priv = GARROW_STREAM_READER_GET_PRIVATE(stream_reader);
- return priv->stream_reader;
-}
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/stream-reader.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-reader.h b/c_glib/arrow-glib/stream-reader.h
deleted file mode 100644
index f6cdaea..0000000
--- a/c_glib/arrow-glib/stream-reader.h
+++ /dev/null
@@ -1,80 +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/record-batch.h>
-#include <arrow-glib/schema.h>
-
-#include <arrow-glib/input-stream.h>
-
-#include <arrow-glib/metadata-version.h>
-
-G_BEGIN_DECLS
-
-#define GARROW_TYPE_STREAM_READER \
- (garrow_stream_reader_get_type())
-#define GARROW_STREAM_READER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GARROW_TYPE_STREAM_READER, \
- GArrowStreamReader))
-#define GARROW_STREAM_READER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- GARROW_TYPE_STREAM_READER, \
- GArrowStreamReaderClass))
-#define GARROW_IS_STREAM_READER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- GARROW_TYPE_STREAM_READER))
-#define GARROW_IS_STREAM_READER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- GARROW_TYPE_STREAM_READER))
-#define GARROW_STREAM_READER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- GARROW_TYPE_STREAM_READER, \
- GArrowStreamReaderClass))
-
-typedef struct _GArrowStreamReader GArrowStreamReader;
-typedef struct _GArrowStreamReaderClass GArrowStreamReaderClass;
-
-/**
- * GArrowStreamReader:
- *
- * It wraps `arrow::ipc::InputStreamReader`.
- */
-struct _GArrowStreamReader
-{
- /*< private >*/
- GObject parent_instance;
-};
-
-struct _GArrowStreamReaderClass
-{
- GObjectClass parent_class;
-};
-
-GType garrow_stream_reader_get_type(void) G_GNUC_CONST;
-
-GArrowStreamReader *garrow_stream_reader_new(GArrowInputStream *stream,
- GError **error);
-
-GArrowSchema *garrow_stream_reader_get_schema(GArrowStreamReader *stream_reader);
-GArrowRecordBatch *garrow_stream_reader_get_next_record_batch(GArrowStreamReader *stream_reader,
- GError **error);
-
-G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/arrow-glib/stream-reader.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/stream-reader.hpp b/c_glib/arrow-glib/stream-reader.hpp
deleted file mode 100644
index 5191b4e..0000000
--- a/c_glib/arrow-glib/stream-reader.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-reader.h>
-
-GArrowStreamReader *garrow_stream_reader_new_raw(std::shared_ptr<arrow::ipc::RecordBatchStreamReader> *arrow_stream_reader);
-std::shared_ptr<arrow::ipc::RecordBatchStreamReader> garrow_stream_reader_get_raw(GArrowStreamReader *stream_reader);
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/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 dae89e2..4fa1b7c 100644
--- a/c_glib/doc/reference/arrow-glib-docs.sgml
+++ b/c_glib/doc/reference/arrow-glib-docs.sgml
@@ -103,8 +103,7 @@
</chapter>
<chapter id="reader">
<title>Reader</title>
- <xi:include href="xml/file-reader.xml"/>
- <xi:include href="xml/stream-reader.xml"/>
+ <xi:include href="xml/reader.xml"/>
</chapter>
<chapter id="writer">
<title>Writer</title>
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/c_glib/example/read-batch.c
----------------------------------------------------------------------
diff --git a/c_glib/example/read-batch.c b/c_glib/example/read-batch.c
index 212b2a7..4461c43 100644
--- a/c_glib/example/read-batch.c
+++ b/c_glib/example/read-batch.c
@@ -101,10 +101,11 @@ main(int argc, char **argv)
}
{
- GArrowFileReader *reader;
+ GArrowRecordBatchFileReader *reader;
- reader = garrow_file_reader_new(GARROW_SEEKABLE_INPUT_STREAM(input),
- &error);
+ reader =
+ garrow_record_batch_file_reader_new(GARROW_SEEKABLE_INPUT_STREAM(input),
+ &error);
if (!reader) {
g_print("failed to open file reader: %s\n", error->message);
g_error_free(error);
@@ -115,12 +116,12 @@ main(int argc, char **argv)
{
guint i, n;
- n = garrow_file_reader_get_n_record_batches(reader);
+ n = garrow_record_batch_file_reader_get_n_record_batches(reader);
for (i = 0; i < n; i++) {
GArrowRecordBatch *record_batch;
record_batch =
- garrow_file_reader_get_record_batch(reader, i, &error);
+ garrow_record_batch_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/8a8e7bb0/c_glib/example/read-stream.c
----------------------------------------------------------------------
diff --git a/c_glib/example/read-stream.c b/c_glib/example/read-stream.c
index 28a3f5e..412be35 100644
--- a/c_glib/example/read-stream.c
+++ b/c_glib/example/read-stream.c
@@ -100,22 +100,25 @@ main(int argc, char **argv)
}
{
- GArrowStreamReader *reader;
+ GArrowRecordBatchReader *reader;
+ GArrowRecordBatchStreamReader *stream_reader;
- reader = garrow_stream_reader_new(GARROW_INPUT_STREAM(input),
- &error);
- if (!reader) {
+ stream_reader =
+ garrow_record_batch_stream_reader_new(GARROW_INPUT_STREAM(input),
+ &error);
+ if (!stream_reader) {
g_print("failed to open stream reader: %s\n", error->message);
g_error_free(error);
g_object_unref(input);
return EXIT_FAILURE;
}
+ reader = GARROW_RECORD_BATCH_READER(stream_reader);
while (TRUE) {
GArrowRecordBatch *record_batch;
record_batch =
- garrow_stream_reader_get_next_record_batch(reader, &error);
+ garrow_record_batch_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/8a8e7bb0/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
index 1d9102b..02b8bd5 100644
--- a/c_glib/test/test-file-writer.rb
+++ b/c_glib/test/test-file-writer.rb
@@ -35,7 +35,7 @@ class TestFileWriter < Test::Unit::TestCase
input = Arrow::MemoryMappedInputStream.new(tempfile.path)
begin
- file_reader = Arrow::FileReader.new(input)
+ file_reader = Arrow::RecordBatchFileReader.new(input)
assert_equal(["enabled"],
file_reader.schema.fields.collect(&:name))
ensure
http://git-wip-us.apache.org/repos/asf/arrow/blob/8a8e7bb0/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
index d27eaa5..da6c2af 100644
--- a/c_glib/test/test-stream-writer.rb
+++ b/c_glib/test/test-stream-writer.rb
@@ -40,7 +40,7 @@ class TestStreamWriter < Test::Unit::TestCase
input = Arrow::MemoryMappedInputStream.new(tempfile.path)
begin
- stream_reader = Arrow::StreamReader.new(input)
+ stream_reader = Arrow::RecordBatchStreamReader.new(input)
assert_equal(["enabled"],
stream_reader.schema.fields.collect(&:name))
assert_equal(true,