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/04/12 14:54:50 UTC
[2/4] arrow git commit: ARROW-810: [GLib] Remove io/ipc prefix
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-file-writer.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-file-writer.hpp b/c_glib/arrow-glib/ipc-file-writer.hpp
deleted file mode 100644
index b8ae113..0000000
--- a/c_glib/arrow-glib/ipc-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/ipc-file-writer.h>
-
-GArrowIPCFileWriter *garrow_ipc_file_writer_new_raw(std::shared_ptr<arrow::ipc::FileWriter> *arrow_file_writer);
-arrow::ipc::FileWriter *garrow_ipc_file_writer_get_raw(GArrowIPCFileWriter *file_writer);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-metadata-version.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-metadata-version.cpp b/c_glib/arrow-glib/ipc-metadata-version.cpp
deleted file mode 100644
index f591f29..0000000
--- a/c_glib/arrow-glib/ipc-metadata-version.cpp
+++ /dev/null
@@ -1,63 +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-glib/ipc-metadata-version.hpp>
-
-/**
- * SECTION: ipc-metadata-version
- * @title: GArrowIPCMetadataVersion
- * @short_description: Metadata version mapgging between Arrow and arrow-glib
- *
- * #GArrowIPCMetadataVersion provides metadata versions corresponding
- * to `arrow::ipc::MetadataVersion` values.
- */
-
-GArrowIPCMetadataVersion
-garrow_ipc_metadata_version_from_raw(arrow::ipc::MetadataVersion version)
-{
- switch (version) {
- case arrow::ipc::MetadataVersion::V1:
- return GARROW_IPC_METADATA_VERSION_V1;
- case arrow::ipc::MetadataVersion::V2:
- return GARROW_IPC_METADATA_VERSION_V2;
- case arrow::ipc::MetadataVersion::V3:
- return GARROW_IPC_METADATA_VERSION_V3;
- default:
- return GARROW_IPC_METADATA_VERSION_V3;
- }
-}
-
-arrow::ipc::MetadataVersion
-garrow_ipc_metadata_version_to_raw(GArrowIPCMetadataVersion version)
-{
- switch (version) {
- case GARROW_IPC_METADATA_VERSION_V1:
- return arrow::ipc::MetadataVersion::V1;
- case GARROW_IPC_METADATA_VERSION_V2:
- return arrow::ipc::MetadataVersion::V2;
- case GARROW_IPC_METADATA_VERSION_V3:
- return arrow::ipc::MetadataVersion::V3;
- default:
- return arrow::ipc::MetadataVersion::V3;
- }
-}
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-metadata-version.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-metadata-version.h b/c_glib/arrow-glib/ipc-metadata-version.h
deleted file mode 100644
index 20defdb..0000000
--- a/c_glib/arrow-glib/ipc-metadata-version.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#pragma once
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/**
- * GArrowIPCMetadataVersion:
- * @GARROW_IPC_METADATA_VERSION_V1: Version 1.
- * @GARROW_IPC_METADATA_VERSION_V2: Version 2.
- * @GARROW_IPC_METADATA_VERSION_V3: Version 3.
- *
- * They are corresponding to `arrow::ipc::MetadataVersion::type`
- * values.
- */
-typedef enum {
- GARROW_IPC_METADATA_VERSION_V1,
- GARROW_IPC_METADATA_VERSION_V2,
- GARROW_IPC_METADATA_VERSION_V3
-} GArrowIPCMetadataVersion;
-
-G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-metadata-version.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-metadata-version.hpp b/c_glib/arrow-glib/ipc-metadata-version.hpp
deleted file mode 100644
index 229565f..0000000
--- a/c_glib/arrow-glib/ipc-metadata-version.hpp
+++ /dev/null
@@ -1,27 +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/ipc/api.h>
-
-#include <arrow-glib/ipc-metadata-version.h>
-
-GArrowIPCMetadataVersion garrow_ipc_metadata_version_from_raw(arrow::ipc::MetadataVersion version);
-arrow::ipc::MetadataVersion garrow_ipc_metadata_version_to_raw(GArrowIPCMetadataVersion version);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-stream-reader.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-stream-reader.cpp b/c_glib/arrow-glib/ipc-stream-reader.cpp
deleted file mode 100644
index 4804784..0000000
--- a/c_glib/arrow-glib/ipc-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/io-input-stream.hpp>
-
-#include <arrow-glib/ipc-metadata-version.hpp>
-#include <arrow-glib/ipc-stream-reader.hpp>
-
-G_BEGIN_DECLS
-
-/**
- * SECTION: ipc-stream-reader
- * @short_description: Stream reader class
- *
- * #GArrowIPCStreamReader is a class for receiving data by stream
- * based IPC.
- */
-
-typedef struct GArrowIPCStreamReaderPrivate_ {
- std::shared_ptr<arrow::ipc::StreamReader> stream_reader;
-} GArrowIPCStreamReaderPrivate;
-
-enum {
- PROP_0,
- PROP_STREAM_READER
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE(GArrowIPCStreamReader,
- garrow_ipc_stream_reader,
- G_TYPE_OBJECT);
-
-#define GARROW_IPC_STREAM_READER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
- GARROW_IPC_TYPE_STREAM_READER, \
- GArrowIPCStreamReaderPrivate))
-
-static void
-garrow_ipc_stream_reader_finalize(GObject *object)
-{
- GArrowIPCStreamReaderPrivate *priv;
-
- priv = GARROW_IPC_STREAM_READER_GET_PRIVATE(object);
-
- priv->stream_reader = nullptr;
-
- G_OBJECT_CLASS(garrow_ipc_stream_reader_parent_class)->finalize(object);
-}
-
-static void
-garrow_ipc_stream_reader_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GArrowIPCStreamReaderPrivate *priv;
-
- priv = GARROW_IPC_STREAM_READER_GET_PRIVATE(object);
-
- switch (prop_id) {
- case PROP_STREAM_READER:
- priv->stream_reader =
- *static_cast<std::shared_ptr<arrow::ipc::StreamReader> *>(g_value_get_pointer(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-garrow_ipc_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_ipc_stream_reader_init(GArrowIPCStreamReader *object)
-{
-}
-
-static void
-garrow_ipc_stream_reader_class_init(GArrowIPCStreamReaderClass *klass)
-{
- GObjectClass *gobject_class;
- GParamSpec *spec;
-
- gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->finalize = garrow_ipc_stream_reader_finalize;
- gobject_class->set_property = garrow_ipc_stream_reader_set_property;
- gobject_class->get_property = garrow_ipc_stream_reader_get_property;
-
- spec = g_param_spec_pointer("stream-reader",
- "ipc::StreamReader",
- "The raw std::shared<arrow::ipc::StreamReader> *",
- static_cast<GParamFlags>(G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property(gobject_class, PROP_STREAM_READER, spec);
-}
-
-/**
- * garrow_ipc_stream_reader_open:
- * @stream: The stream to be read.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: (nullable) (transfer full): A newly opened
- * #GArrowIPCStreamReader or %NULL on error.
- */
-GArrowIPCStreamReader *
-garrow_ipc_stream_reader_open(GArrowIOInputStream *stream,
- GError **error)
-{
- std::shared_ptr<arrow::ipc::StreamReader> arrow_stream_reader;
- auto status =
- arrow::ipc::StreamReader::Open(garrow_io_input_stream_get_raw(stream),
- &arrow_stream_reader);
- if (status.ok()) {
- return garrow_ipc_stream_reader_new_raw(&arrow_stream_reader);
- } else {
- garrow_error_set(error, status, "[ipc][stream-reader][open]");
- return NULL;
- }
-}
-
-/**
- * garrow_ipc_stream_reader_get_schema:
- * @stream_reader: A #GArrowIPCStreamReader.
- *
- * Returns: (transfer full): The schema in the stream.
- */
-GArrowSchema *
-garrow_ipc_stream_reader_get_schema(GArrowIPCStreamReader *stream_reader)
-{
- auto arrow_stream_reader =
- garrow_ipc_stream_reader_get_raw(stream_reader);
- auto arrow_schema = arrow_stream_reader->schema();
- return garrow_schema_new_raw(&arrow_schema);
-}
-
-/**
- * garrow_ipc_stream_reader_get_next_record_batch:
- * @stream_reader: A #GArrowIPCStreamReader.
- * @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_ipc_stream_reader_get_next_record_batch(GArrowIPCStreamReader *stream_reader,
- GError **error)
-{
- auto arrow_stream_reader =
- garrow_ipc_stream_reader_get_raw(stream_reader);
- std::shared_ptr<arrow::RecordBatch> arrow_record_batch;
- auto status = arrow_stream_reader->GetNextRecordBatch(&arrow_record_batch);
-
- if (status.ok()) {
- if (arrow_record_batch == nullptr) {
- return NULL;
- } else {
- return garrow_record_batch_new_raw(&arrow_record_batch);
- }
- } else {
- garrow_error_set(error, status, "[ipc][stream-reader][get-next-record-batch]");
- return NULL;
- }
-}
-
-G_END_DECLS
-
-GArrowIPCStreamReader *
-garrow_ipc_stream_reader_new_raw(std::shared_ptr<arrow::ipc::StreamReader> *arrow_stream_reader)
-{
- auto stream_reader =
- GARROW_IPC_STREAM_READER(g_object_new(GARROW_IPC_TYPE_STREAM_READER,
- "stream-reader", arrow_stream_reader,
- NULL));
- return stream_reader;
-}
-
-std::shared_ptr<arrow::ipc::StreamReader>
-garrow_ipc_stream_reader_get_raw(GArrowIPCStreamReader *stream_reader)
-{
- GArrowIPCStreamReaderPrivate *priv;
-
- priv = GARROW_IPC_STREAM_READER_GET_PRIVATE(stream_reader);
- return priv->stream_reader;
-}
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-stream-reader.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-stream-reader.h b/c_glib/arrow-glib/ipc-stream-reader.h
deleted file mode 100644
index 993cd85..0000000
--- a/c_glib/arrow-glib/ipc-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/io-input-stream.h>
-
-#include <arrow-glib/ipc-metadata-version.h>
-
-G_BEGIN_DECLS
-
-#define GARROW_IPC_TYPE_STREAM_READER \
- (garrow_ipc_stream_reader_get_type())
-#define GARROW_IPC_STREAM_READER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GARROW_IPC_TYPE_STREAM_READER, \
- GArrowIPCStreamReader))
-#define GARROW_IPC_STREAM_READER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- GARROW_IPC_TYPE_STREAM_READER, \
- GArrowIPCStreamReaderClass))
-#define GARROW_IPC_IS_STREAM_READER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- GARROW_IPC_TYPE_STREAM_READER))
-#define GARROW_IPC_IS_STREAM_READER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- GARROW_IPC_TYPE_STREAM_READER))
-#define GARROW_IPC_STREAM_READER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- GARROW_IPC_TYPE_STREAM_READER, \
- GArrowIPCStreamReaderClass))
-
-typedef struct _GArrowIPCStreamReader GArrowIPCStreamReader;
-typedef struct _GArrowIPCStreamReaderClass GArrowIPCStreamReaderClass;
-
-/**
- * GArrowIPCStreamReader:
- *
- * It wraps `arrow::ipc::StreamReader`.
- */
-struct _GArrowIPCStreamReader
-{
- /*< private >*/
- GObject parent_instance;
-};
-
-struct _GArrowIPCStreamReaderClass
-{
- GObjectClass parent_class;
-};
-
-GType garrow_ipc_stream_reader_get_type(void) G_GNUC_CONST;
-
-GArrowIPCStreamReader *garrow_ipc_stream_reader_open(GArrowIOInputStream *stream,
- GError **error);
-
-GArrowSchema *garrow_ipc_stream_reader_get_schema(GArrowIPCStreamReader *stream_reader);
-GArrowRecordBatch *garrow_ipc_stream_reader_get_next_record_batch(GArrowIPCStreamReader *stream_reader,
- GError **error);
-
-G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-stream-reader.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-stream-reader.hpp b/c_glib/arrow-glib/ipc-stream-reader.hpp
deleted file mode 100644
index a35bdab..0000000
--- a/c_glib/arrow-glib/ipc-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/ipc-stream-reader.h>
-
-GArrowIPCStreamReader *garrow_ipc_stream_reader_new_raw(std::shared_ptr<arrow::ipc::StreamReader> *arrow_stream_reader);
-std::shared_ptr<arrow::ipc::StreamReader> garrow_ipc_stream_reader_get_raw(GArrowIPCStreamReader *stream_reader);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-stream-writer.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-stream-writer.cpp b/c_glib/arrow-glib/ipc-stream-writer.cpp
deleted file mode 100644
index e2455a4..0000000
--- a/c_glib/arrow-glib/ipc-stream-writer.cpp
+++ /dev/null
@@ -1,232 +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/io-output-stream.hpp>
-
-#include <arrow-glib/ipc-stream-writer.hpp>
-
-G_BEGIN_DECLS
-
-/**
- * SECTION: ipc-stream-writer
- * @short_description: Stream writer class
- *
- * #GArrowIPCStreamWriter is a class for sending data by stream based
- * IPC.
- */
-
-typedef struct GArrowIPCStreamWriterPrivate_ {
- std::shared_ptr<arrow::ipc::StreamWriter> stream_writer;
-} GArrowIPCStreamWriterPrivate;
-
-enum {
- PROP_0,
- PROP_STREAM_WRITER
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE(GArrowIPCStreamWriter,
- garrow_ipc_stream_writer,
- G_TYPE_OBJECT);
-
-#define GARROW_IPC_STREAM_WRITER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
- GARROW_IPC_TYPE_STREAM_WRITER, \
- GArrowIPCStreamWriterPrivate))
-
-static void
-garrow_ipc_stream_writer_finalize(GObject *object)
-{
- GArrowIPCStreamWriterPrivate *priv;
-
- priv = GARROW_IPC_STREAM_WRITER_GET_PRIVATE(object);
-
- priv->stream_writer = nullptr;
-
- G_OBJECT_CLASS(garrow_ipc_stream_writer_parent_class)->finalize(object);
-}
-
-static void
-garrow_ipc_stream_writer_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GArrowIPCStreamWriterPrivate *priv;
-
- priv = GARROW_IPC_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_ipc_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_ipc_stream_writer_init(GArrowIPCStreamWriter *object)
-{
-}
-
-static void
-garrow_ipc_stream_writer_class_init(GArrowIPCStreamWriterClass *klass)
-{
- GObjectClass *gobject_class;
- GParamSpec *spec;
-
- gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->finalize = garrow_ipc_stream_writer_finalize;
- gobject_class->set_property = garrow_ipc_stream_writer_set_property;
- gobject_class->get_property = garrow_ipc_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_ipc_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
- * #GArrowIPCStreamWriter or %NULL on error.
- */
-GArrowIPCStreamWriter *
-garrow_ipc_stream_writer_open(GArrowIOOutputStream *sink,
- GArrowSchema *schema,
- GError **error)
-{
- std::shared_ptr<arrow::ipc::StreamWriter> arrow_stream_writer;
- auto status =
- arrow::ipc::StreamWriter::Open(garrow_io_output_stream_get_raw(sink).get(),
- garrow_schema_get_raw(schema),
- &arrow_stream_writer);
- if (status.ok()) {
- return garrow_ipc_stream_writer_new_raw(&arrow_stream_writer);
- } else {
- garrow_error_set(error, status, "[ipc][stream-writer][open]");
- return NULL;
- }
-}
-
-/**
- * garrow_ipc_stream_writer_write_record_batch:
- * @stream_writer: A #GArrowIPCStreamWriter.
- * @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_ipc_stream_writer_write_record_batch(GArrowIPCStreamWriter *stream_writer,
- GArrowRecordBatch *record_batch,
- GError **error)
-{
- auto arrow_stream_writer =
- garrow_ipc_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_ipc_stream_writer_close:
- * @stream_writer: A #GArrowIPCStreamWriter.
- * @error: (nullable): Return locatipcn for a #GError or %NULL.
- *
- * Returns: %TRUE on success, %FALSE if there was an error.
- */
-gboolean
-garrow_ipc_stream_writer_close(GArrowIPCStreamWriter *stream_writer,
- GError **error)
-{
- auto arrow_stream_writer =
- garrow_ipc_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
-
-GArrowIPCStreamWriter *
-garrow_ipc_stream_writer_new_raw(std::shared_ptr<arrow::ipc::StreamWriter> *arrow_stream_writer)
-{
- auto stream_writer =
- GARROW_IPC_STREAM_WRITER(g_object_new(GARROW_IPC_TYPE_STREAM_WRITER,
- "stream-writer", arrow_stream_writer,
- NULL));
- return stream_writer;
-}
-
-std::shared_ptr<arrow::ipc::StreamWriter>
-garrow_ipc_stream_writer_get_raw(GArrowIPCStreamWriter *stream_writer)
-{
- GArrowIPCStreamWriterPrivate *priv;
-
- priv = GARROW_IPC_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/ipc-stream-writer.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-stream-writer.h b/c_glib/arrow-glib/ipc-stream-writer.h
deleted file mode 100644
index 4488204..0000000
--- a/c_glib/arrow-glib/ipc-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/io-output-stream.h>
-
-G_BEGIN_DECLS
-
-#define GARROW_IPC_TYPE_STREAM_WRITER \
- (garrow_ipc_stream_writer_get_type())
-#define GARROW_IPC_STREAM_WRITER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- GARROW_IPC_TYPE_STREAM_WRITER, \
- GArrowIPCStreamWriter))
-#define GARROW_IPC_STREAM_WRITER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- GARROW_IPC_TYPE_STREAM_WRITER, \
- GArrowIPCStreamWriterClass))
-#define GARROW_IPC_IS_STREAM_WRITER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- GARROW_IPC_TYPE_STREAM_WRITER))
-#define GARROW_IPC_IS_STREAM_WRITER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- GARROW_IPC_TYPE_STREAM_WRITER))
-#define GARROW_IPC_STREAM_WRITER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- GARROW_IPC_TYPE_STREAM_WRITER, \
- GArrowIPCStreamWriterClass))
-
-typedef struct _GArrowIPCStreamWriter GArrowIPCStreamWriter;
-typedef struct _GArrowIPCStreamWriterClass GArrowIPCStreamWriterClass;
-
-/**
- * GArrowIPCStreamWriter:
- *
- * It wraps `arrow::ipc::StreamWriter`.
- */
-struct _GArrowIPCStreamWriter
-{
- /*< private >*/
- GObject parent_instance;
-};
-
-struct _GArrowIPCStreamWriterClass
-{
- GObjectClass parent_class;
-};
-
-GType garrow_ipc_stream_writer_get_type(void) G_GNUC_CONST;
-
-GArrowIPCStreamWriter *garrow_ipc_stream_writer_open(GArrowIOOutputStream *sink,
- GArrowSchema *schema,
- GError **error);
-
-gboolean garrow_ipc_stream_writer_write_record_batch(GArrowIPCStreamWriter *stream_writer,
- GArrowRecordBatch *record_batch,
- GError **error);
-gboolean garrow_ipc_stream_writer_close(GArrowIPCStreamWriter *stream_writer,
- GError **error);
-
-G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/ipc-stream-writer.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/ipc-stream-writer.hpp b/c_glib/arrow-glib/ipc-stream-writer.hpp
deleted file mode 100644
index 9d09740..0000000
--- a/c_glib/arrow-glib/ipc-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/ipc-stream-writer.h>
-
-GArrowIPCStreamWriter *garrow_ipc_stream_writer_new_raw(std::shared_ptr<arrow::ipc::StreamWriter> *arrow_stream_writer);
-std::shared_ptr<arrow::ipc::StreamWriter> garrow_ipc_stream_writer_get_raw(GArrowIPCStreamWriter *stream_writer);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/memory-mapped-file.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/memory-mapped-file.cpp b/c_glib/arrow-glib/memory-mapped-file.cpp
new file mode 100644
index 0000000..a3e1d0c
--- /dev/null
+++ b/c_glib/arrow-glib/memory-mapped-file.cpp
@@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <arrow/io/file.h>
+
+#include <arrow-glib/error.hpp>
+#include <arrow-glib/file.hpp>
+#include <arrow-glib/file-mode.hpp>
+#include <arrow-glib/input-stream.hpp>
+#include <arrow-glib/memory-mapped-file.hpp>
+#include <arrow-glib/readable.hpp>
+#include <arrow-glib/random-access-file.hpp>
+#include <arrow-glib/writeable.hpp>
+#include <arrow-glib/writeable-file.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: memory-mapped-file
+ * @short_description: Memory mapped file class
+ *
+ * #GArrowMemoryMappedFile is a class for memory mapped file. It's
+ * readable and writeable. It supports zero copy.
+ */
+
+typedef struct GArrowMemoryMappedFilePrivate_ {
+ std::shared_ptr<arrow::io::MemoryMappedFile> memory_mapped_file;
+} GArrowMemoryMappedFilePrivate;
+
+enum {
+ PROP_0,
+ PROP_MEMORY_MAPPED_FILE
+};
+
+static std::shared_ptr<arrow::io::FileInterface>
+garrow_memory_mapped_file_get_raw_file_interface(GArrowFile *file)
+{
+ auto memory_mapped_file = GARROW_MEMORY_MAPPED_FILE(file);
+ auto arrow_memory_mapped_file =
+ garrow_memory_mapped_file_get_raw(memory_mapped_file);
+ return arrow_memory_mapped_file;
+}
+
+static void
+garrow_file_interface_init(GArrowFileInterface *iface)
+{
+ iface->get_raw = garrow_memory_mapped_file_get_raw_file_interface;
+}
+
+static std::shared_ptr<arrow::io::Readable>
+garrow_memory_mapped_file_get_raw_readable_interface(GArrowReadable *readable)
+{
+ auto memory_mapped_file = GARROW_MEMORY_MAPPED_FILE(readable);
+ auto arrow_memory_mapped_file =
+ garrow_memory_mapped_file_get_raw(memory_mapped_file);
+ return arrow_memory_mapped_file;
+}
+
+static void
+garrow_readable_interface_init(GArrowReadableInterface *iface)
+{
+ iface->get_raw = garrow_memory_mapped_file_get_raw_readable_interface;
+}
+
+static std::shared_ptr<arrow::io::InputStream>
+garrow_memory_mapped_file_get_raw_input_stream_interface(GArrowInputStream *input_stream)
+{
+ auto memory_mapped_file = GARROW_MEMORY_MAPPED_FILE(input_stream);
+ auto arrow_memory_mapped_file =
+ garrow_memory_mapped_file_get_raw(memory_mapped_file);
+ return arrow_memory_mapped_file;
+}
+
+static void
+garrow_input_stream_interface_init(GArrowInputStreamInterface *iface)
+{
+ iface->get_raw = garrow_memory_mapped_file_get_raw_input_stream_interface;
+}
+
+static std::shared_ptr<arrow::io::RandomAccessFile>
+garrow_memory_mapped_file_get_raw_random_access_file_interface(GArrowRandomAccessFile *file)
+{
+ auto memory_mapped_file = GARROW_MEMORY_MAPPED_FILE(file);
+ auto arrow_memory_mapped_file =
+ garrow_memory_mapped_file_get_raw(memory_mapped_file);
+ return arrow_memory_mapped_file;
+}
+
+static void
+garrow_random_access_file_interface_init(GArrowRandomAccessFileInterface *iface)
+{
+ iface->get_raw = garrow_memory_mapped_file_get_raw_random_access_file_interface;
+}
+
+static std::shared_ptr<arrow::io::Writeable>
+garrow_memory_mapped_file_get_raw_writeable_interface(GArrowWriteable *writeable)
+{
+ auto memory_mapped_file = GARROW_MEMORY_MAPPED_FILE(writeable);
+ auto arrow_memory_mapped_file =
+ garrow_memory_mapped_file_get_raw(memory_mapped_file);
+ return arrow_memory_mapped_file;
+}
+
+static void
+garrow_writeable_interface_init(GArrowWriteableInterface *iface)
+{
+ iface->get_raw = garrow_memory_mapped_file_get_raw_writeable_interface;
+}
+
+static std::shared_ptr<arrow::io::WriteableFile>
+garrow_memory_mapped_file_get_raw_writeable_file_interface(GArrowWriteableFile *file)
+{
+ auto memory_mapped_file = GARROW_MEMORY_MAPPED_FILE(file);
+ auto arrow_memory_mapped_file =
+ garrow_memory_mapped_file_get_raw(memory_mapped_file);
+ return arrow_memory_mapped_file;
+}
+
+static void
+garrow_writeable_file_interface_init(GArrowWriteableFileInterface *iface)
+{
+ iface->get_raw = garrow_memory_mapped_file_get_raw_writeable_file_interface;
+}
+
+G_DEFINE_TYPE_WITH_CODE(GArrowMemoryMappedFile,
+ garrow_memory_mapped_file,
+ G_TYPE_OBJECT,
+ G_ADD_PRIVATE(GArrowMemoryMappedFile)
+ G_IMPLEMENT_INTERFACE(GARROW_TYPE_FILE,
+ garrow_file_interface_init)
+ G_IMPLEMENT_INTERFACE(GARROW_TYPE_READABLE,
+ garrow_readable_interface_init)
+ G_IMPLEMENT_INTERFACE(GARROW_TYPE_INPUT_STREAM,
+ garrow_input_stream_interface_init)
+ G_IMPLEMENT_INTERFACE(GARROW_TYPE_RANDOM_ACCESS_FILE,
+ garrow_random_access_file_interface_init)
+ G_IMPLEMENT_INTERFACE(GARROW_TYPE_WRITEABLE,
+ garrow_writeable_interface_init)
+ G_IMPLEMENT_INTERFACE(GARROW_TYPE_WRITEABLE_FILE,
+ garrow_writeable_file_interface_init));
+
+#define GARROW_MEMORY_MAPPED_FILE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GARROW_TYPE_MEMORY_MAPPED_FILE, \
+ GArrowMemoryMappedFilePrivate))
+
+static void
+garrow_memory_mapped_file_finalize(GObject *object)
+{
+ GArrowMemoryMappedFilePrivate *priv;
+
+ priv = GARROW_MEMORY_MAPPED_FILE_GET_PRIVATE(object);
+
+ priv->memory_mapped_file = nullptr;
+
+ G_OBJECT_CLASS(garrow_memory_mapped_file_parent_class)->finalize(object);
+}
+
+static void
+garrow_memory_mapped_file_set_property(GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GArrowMemoryMappedFilePrivate *priv;
+
+ priv = GARROW_MEMORY_MAPPED_FILE_GET_PRIVATE(object);
+
+ switch (prop_id) {
+ case PROP_MEMORY_MAPPED_FILE:
+ priv->memory_mapped_file =
+ *static_cast<std::shared_ptr<arrow::io::MemoryMappedFile> *>(g_value_get_pointer(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+garrow_memory_mapped_file_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_memory_mapped_file_init(GArrowMemoryMappedFile *object)
+{
+}
+
+static void
+garrow_memory_mapped_file_class_init(GArrowMemoryMappedFileClass *klass)
+{
+ GObjectClass *gobject_class;
+ GParamSpec *spec;
+
+ gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->finalize = garrow_memory_mapped_file_finalize;
+ gobject_class->set_property = garrow_memory_mapped_file_set_property;
+ gobject_class->get_property = garrow_memory_mapped_file_get_property;
+
+ spec = g_param_spec_pointer("memory-mapped-file",
+ "io::MemoryMappedFile",
+ "The raw std::shared<arrow::io::MemoryMappedFile> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_MEMORY_MAPPED_FILE, spec);
+}
+
+/**
+ * garrow_memory_mapped_file_open:
+ * @path: The path of the memory mapped file.
+ * @mode: The mode of the memory mapped file.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full): A newly opened
+ * #GArrowMemoryMappedFile or %NULL on error.
+ */
+GArrowMemoryMappedFile *
+garrow_memory_mapped_file_open(const gchar *path,
+ GArrowFileMode mode,
+ GError **error)
+{
+ std::shared_ptr<arrow::io::MemoryMappedFile> arrow_memory_mapped_file;
+ auto status =
+ arrow::io::MemoryMappedFile::Open(std::string(path),
+ garrow_file_mode_to_raw(mode),
+ &arrow_memory_mapped_file);
+ if (status.ok()) {
+ return garrow_memory_mapped_file_new_raw(&arrow_memory_mapped_file);
+ } else {
+ std::string context("[io][memory-mapped-file][open]: <");
+ context += path;
+ context += ">";
+ garrow_error_set(error, status, context.c_str());
+ return NULL;
+ }
+}
+
+G_END_DECLS
+
+GArrowMemoryMappedFile *
+garrow_memory_mapped_file_new_raw(std::shared_ptr<arrow::io::MemoryMappedFile> *arrow_memory_mapped_file)
+{
+ auto memory_mapped_file =
+ GARROW_MEMORY_MAPPED_FILE(g_object_new(GARROW_TYPE_MEMORY_MAPPED_FILE,
+ "memory-mapped-file", arrow_memory_mapped_file,
+ NULL));
+ return memory_mapped_file;
+}
+
+std::shared_ptr<arrow::io::MemoryMappedFile>
+garrow_memory_mapped_file_get_raw(GArrowMemoryMappedFile *memory_mapped_file)
+{
+ GArrowMemoryMappedFilePrivate *priv;
+
+ priv = GARROW_MEMORY_MAPPED_FILE_GET_PRIVATE(memory_mapped_file);
+ return priv->memory_mapped_file;
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/memory-mapped-file.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/memory-mapped-file.h b/c_glib/arrow-glib/memory-mapped-file.h
new file mode 100644
index 0000000..40b8de0
--- /dev/null
+++ b/c_glib/arrow-glib/memory-mapped-file.h
@@ -0,0 +1,72 @@
+/*
+ * 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/file-mode.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_MEMORY_MAPPED_FILE \
+ (garrow_memory_mapped_file_get_type())
+#define GARROW_MEMORY_MAPPED_FILE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_MEMORY_MAPPED_FILE, \
+ GArrowMemoryMappedFile))
+#define GARROW_MEMORY_MAPPED_FILE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GARROW_TYPE_MEMORY_MAPPED_FILE, \
+ GArrowMemoryMappedFileClass))
+#define GARROW_IS_MEMORY_MAPPED_FILE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_MEMORY_MAPPED_FILE))
+#define GARROW_IS_MEMORY_MAPPED_FILE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), \
+ GARROW_TYPE_MEMORY_MAPPED_FILE))
+#define GARROW_MEMORY_MAPPED_FILE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj), \
+ GARROW_TYPE_MEMORY_MAPPED_FILE, \
+ GArrowMemoryMappedFileClass))
+
+typedef struct _GArrowMemoryMappedFile GArrowMemoryMappedFile;
+typedef struct _GArrowMemoryMappedFileClass GArrowMemoryMappedFileClass;
+
+/**
+ * GArrowMemoryMappedFile:
+ *
+ * It wraps `arrow::io::MemoryMappedFile`.
+ */
+struct _GArrowMemoryMappedFile
+{
+ /*< private >*/
+ GObject parent_instance;
+};
+
+struct _GArrowMemoryMappedFileClass
+{
+ GObjectClass parent_class;
+};
+
+GType garrow_memory_mapped_file_get_type(void) G_GNUC_CONST;
+
+GArrowMemoryMappedFile *garrow_memory_mapped_file_open(const gchar *path,
+ GArrowFileMode mode,
+ GError **error);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/memory-mapped-file.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/memory-mapped-file.hpp b/c_glib/arrow-glib/memory-mapped-file.hpp
new file mode 100644
index 0000000..522e43d
--- /dev/null
+++ b/c_glib/arrow-glib/memory-mapped-file.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/io/file.h>
+
+#include <arrow-glib/memory-mapped-file.h>
+
+GArrowMemoryMappedFile *garrow_memory_mapped_file_new_raw(std::shared_ptr<arrow::io::MemoryMappedFile> *arrow_memory_mapped_file);
+std::shared_ptr<arrow::io::MemoryMappedFile> garrow_memory_mapped_file_get_raw(GArrowMemoryMappedFile *memory_mapped_file);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/metadata-version.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/metadata-version.cpp b/c_glib/arrow-glib/metadata-version.cpp
new file mode 100644
index 0000000..ee458eb
--- /dev/null
+++ b/c_glib/arrow-glib/metadata-version.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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-glib/metadata-version.hpp>
+
+/**
+ * SECTION: metadata-version
+ * @title: GArrowMetadataVersion
+ * @short_description: Metadata version mapgging between Arrow and arrow-glib
+ *
+ * #GArrowMetadataVersion provides metadata versions corresponding
+ * to `arrow::ipc::MetadataVersion` values.
+ */
+
+GArrowMetadataVersion
+garrow_metadata_version_from_raw(arrow::ipc::MetadataVersion version)
+{
+ switch (version) {
+ case arrow::ipc::MetadataVersion::V1:
+ return GARROW_METADATA_VERSION_V1;
+ case arrow::ipc::MetadataVersion::V2:
+ return GARROW_METADATA_VERSION_V2;
+ case arrow::ipc::MetadataVersion::V3:
+ return GARROW_METADATA_VERSION_V3;
+ default:
+ return GARROW_METADATA_VERSION_V3;
+ }
+}
+
+arrow::ipc::MetadataVersion
+garrow_metadata_version_to_raw(GArrowMetadataVersion version)
+{
+ switch (version) {
+ case GARROW_METADATA_VERSION_V1:
+ return arrow::ipc::MetadataVersion::V1;
+ case GARROW_METADATA_VERSION_V2:
+ return arrow::ipc::MetadataVersion::V2;
+ case GARROW_METADATA_VERSION_V3:
+ return arrow::ipc::MetadataVersion::V3;
+ default:
+ return arrow::ipc::MetadataVersion::V3;
+ }
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/metadata-version.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/metadata-version.h b/c_glib/arrow-glib/metadata-version.h
new file mode 100644
index 0000000..d902a39
--- /dev/null
+++ b/c_glib/arrow-glib/metadata-version.h
@@ -0,0 +1,41 @@
+/*
+ * 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
+
+/**
+ * GArrowMetadataVersion:
+ * @GARROW_METADATA_VERSION_V1: Version 1.
+ * @GARROW_METADATA_VERSION_V2: Version 2.
+ * @GARROW_METADATA_VERSION_V3: Version 3.
+ *
+ * They are corresponding to `arrow::ipc::MetadataVersion::type`
+ * values.
+ */
+typedef enum {
+ GARROW_METADATA_VERSION_V1,
+ GARROW_METADATA_VERSION_V2,
+ GARROW_METADATA_VERSION_V3
+} GArrowMetadataVersion;
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/metadata-version.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/metadata-version.hpp b/c_glib/arrow-glib/metadata-version.hpp
new file mode 100644
index 0000000..7b3865e
--- /dev/null
+++ b/c_glib/arrow-glib/metadata-version.hpp
@@ -0,0 +1,27 @@
+/*
+ * 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/ipc/api.h>
+
+#include <arrow-glib/metadata-version.h>
+
+GArrowMetadataVersion garrow_metadata_version_from_raw(arrow::ipc::MetadataVersion version);
+arrow::ipc::MetadataVersion garrow_metadata_version_to_raw(GArrowMetadataVersion version);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/output-stream.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/output-stream.cpp b/c_glib/arrow-glib/output-stream.cpp
new file mode 100644
index 0000000..bbc29b7
--- /dev/null
+++ b/c_glib/arrow-glib/output-stream.cpp
@@ -0,0 +1,56 @@
+/*
+ * 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/output-stream.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: output-stream
+ * @title: GArrowOutputStream
+ * @short_description: Stream output interface
+ *
+ * #GArrowOutputStream is an interface for stream output. Stream
+ * output is file based and writeable
+ */
+
+G_DEFINE_INTERFACE(GArrowOutputStream,
+ garrow_output_stream,
+ G_TYPE_OBJECT)
+
+static void
+garrow_output_stream_default_init (GArrowOutputStreamInterface *iface)
+{
+}
+
+G_END_DECLS
+
+std::shared_ptr<arrow::io::OutputStream>
+garrow_output_stream_get_raw(GArrowOutputStream *output_stream)
+{
+ auto *iface = GARROW_OUTPUT_STREAM_GET_IFACE(output_stream);
+ return iface->get_raw(output_stream);
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/output-stream.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/output-stream.h b/c_glib/arrow-glib/output-stream.h
new file mode 100644
index 0000000..3481072
--- /dev/null
+++ b/c_glib/arrow-glib/output-stream.h
@@ -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.
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GARROW_TYPE_OUTPUT_STREAM \
+ (garrow_output_stream_get_type())
+#define GARROW_OUTPUT_STREAM(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_OUTPUT_STREAM, \
+ GArrowOutputStream))
+#define GARROW_IS_OUTPUT_STREAM(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_OUTPUT_STREAM))
+#define GARROW_OUTPUT_STREAM_GET_IFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE((obj), \
+ GARROW_TYPE_OUTPUT_STREAM, \
+ GArrowOutputStreamInterface))
+
+typedef struct _GArrowOutputStream GArrowOutputStream;
+typedef struct _GArrowOutputStreamInterface GArrowOutputStreamInterface;
+
+GType garrow_output_stream_get_type(void) G_GNUC_CONST;
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/output-stream.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/output-stream.hpp b/c_glib/arrow-glib/output-stream.hpp
new file mode 100644
index 0000000..635da10
--- /dev/null
+++ b/c_glib/arrow-glib/output-stream.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/output-stream.h>
+
+/**
+ * GArrowOutputStreamInterface:
+ *
+ * It wraps `arrow::io::OutputStream`.
+ */
+struct _GArrowOutputStreamInterface
+{
+ GTypeInterface parent_iface;
+
+ std::shared_ptr<arrow::io::OutputStream> (*get_raw)(GArrowOutputStream *file);
+};
+
+std::shared_ptr<arrow::io::OutputStream> garrow_output_stream_get_raw(GArrowOutputStream *output_stream);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/random-access-file.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/random-access-file.cpp b/c_glib/arrow-glib/random-access-file.cpp
new file mode 100644
index 0000000..71f315e
--- /dev/null
+++ b/c_glib/arrow-glib/random-access-file.cpp
@@ -0,0 +1,128 @@
+/*
+ * 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/random-access-file.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: random-access-file
+ * @title: GArrowRandomAccessFile
+ * @short_description: File input interface
+ *
+ * #GArrowRandomAccessFile is an interface for file input.
+ */
+
+G_DEFINE_INTERFACE(GArrowRandomAccessFile,
+ garrow_random_access_file,
+ G_TYPE_OBJECT)
+
+static void
+garrow_random_access_file_default_init (GArrowRandomAccessFileInterface *iface)
+{
+}
+
+/**
+ * garrow_random_access_file_get_size:
+ * @file: A #GArrowRandomAccessFile.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: The size of the file.
+ */
+guint64
+garrow_random_access_file_get_size(GArrowRandomAccessFile *file,
+ GError **error)
+{
+ auto *iface = GARROW_RANDOM_ACCESS_FILE_GET_IFACE(file);
+ auto arrow_random_access_file = iface->get_raw(file);
+ int64_t size;
+
+ auto status = arrow_random_access_file->GetSize(&size);
+ if (status.ok()) {
+ return size;
+ } else {
+ garrow_error_set(error, status, "[io][random-access-file][get-size]");
+ return 0;
+ }
+}
+
+/**
+ * garrow_random_access_file_get_support_zero_copy:
+ * @file: A #GArrowRandomAccessFile.
+ *
+ * Returns: Whether zero copy read is supported or not.
+ */
+gboolean
+garrow_random_access_file_get_support_zero_copy(GArrowRandomAccessFile *file)
+{
+ auto *iface = GARROW_RANDOM_ACCESS_FILE_GET_IFACE(file);
+ auto arrow_random_access_file = iface->get_raw(file);
+
+ return arrow_random_access_file->supports_zero_copy();
+}
+
+/**
+ * garrow_random_access_file_read_at:
+ * @file: A #GArrowRandomAccessFile.
+ * @position: The read start position.
+ * @n_bytes: The number of bytes to be read.
+ * @n_read_bytes: (out): The read number of bytes.
+ * @buffer: (array length=n_bytes): The buffer to be read data.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_random_access_file_read_at(GArrowRandomAccessFile *file,
+ gint64 position,
+ gint64 n_bytes,
+ gint64 *n_read_bytes,
+ guint8 *buffer,
+ GError **error)
+{
+ const auto arrow_random_access_file =
+ garrow_random_access_file_get_raw(file);
+
+ auto status = arrow_random_access_file->ReadAt(position,
+ n_bytes,
+ n_read_bytes,
+ buffer);
+ if (status.ok()) {
+ return TRUE;
+ } else {
+ garrow_error_set(error, status, "[io][random-access-file][read-at]");
+ return FALSE;
+ }
+}
+
+G_END_DECLS
+
+std::shared_ptr<arrow::io::RandomAccessFile>
+garrow_random_access_file_get_raw(GArrowRandomAccessFile *random_access_file)
+{
+ auto *iface = GARROW_RANDOM_ACCESS_FILE_GET_IFACE(random_access_file);
+ return iface->get_raw(random_access_file);
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/random-access-file.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/random-access-file.h b/c_glib/arrow-glib/random-access-file.h
new file mode 100644
index 0000000..8a7f6b4
--- /dev/null
+++ b/c_glib/arrow-glib/random-access-file.h
@@ -0,0 +1,55 @@
+/*
+ * 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_RANDOM_ACCESS_FILE \
+ (garrow_random_access_file_get_type())
+#define GARROW_RANDOM_ACCESS_FILE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_RANDOM_ACCESS_FILE, \
+ GArrowRandomAccessFile))
+#define GARROW_IS_RANDOM_ACCESS_FILE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_RANDOM_ACCESS_FILE))
+#define GARROW_RANDOM_ACCESS_FILE_GET_IFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE((obj), \
+ GARROW_TYPE_RANDOM_ACCESS_FILE, \
+ GArrowRandomAccessFileInterface))
+
+typedef struct _GArrowRandomAccessFile GArrowRandomAccessFile;
+typedef struct _GArrowRandomAccessFileInterface GArrowRandomAccessFileInterface;
+
+GType garrow_random_access_file_get_type(void) G_GNUC_CONST;
+
+guint64 garrow_random_access_file_get_size(GArrowRandomAccessFile *file,
+ GError **error);
+gboolean garrow_random_access_file_get_support_zero_copy(GArrowRandomAccessFile *file);
+gboolean garrow_random_access_file_read_at(GArrowRandomAccessFile *file,
+ gint64 position,
+ gint64 n_bytes,
+ gint64 *n_read_bytes,
+ guint8 *buffer,
+ GError **error);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/random-access-file.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/random-access-file.hpp b/c_glib/arrow-glib/random-access-file.hpp
new file mode 100644
index 0000000..6d6fed7
--- /dev/null
+++ b/c_glib/arrow-glib/random-access-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/random-access-file.h>
+
+/**
+ * GArrowRandomAccessFileInterface:
+ *
+ * It wraps `arrow::io::RandomAccessFile`.
+ */
+struct _GArrowRandomAccessFileInterface
+{
+ GTypeInterface parent_iface;
+
+ std::shared_ptr<arrow::io::RandomAccessFile> (*get_raw)(GArrowRandomAccessFile *file);
+};
+
+std::shared_ptr<arrow::io::RandomAccessFile> garrow_random_access_file_get_raw(GArrowRandomAccessFile *random_access_file);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/readable.cpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/readable.cpp b/c_glib/arrow-glib/readable.cpp
new file mode 100644
index 0000000..b8c0cd9
--- /dev/null
+++ b/c_glib/arrow-glib/readable.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/readable.hpp>
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION: readable
+ * @title: GArrowReadable
+ * @short_description: Input interface
+ *
+ * #GArrowReadable is an interface for input. Input must be
+ * readable.
+ */
+
+G_DEFINE_INTERFACE(GArrowReadable,
+ garrow_readable,
+ G_TYPE_OBJECT)
+
+static void
+garrow_readable_default_init (GArrowReadableInterface *iface)
+{
+}
+
+/**
+ * garrow_readable_read:
+ * @readable: A #GArrowReadable.
+ * @n_bytes: The number of bytes to be read.
+ * @n_read_bytes: (out): The read number of bytes.
+ * @buffer: (array length=n_bytes): The buffer to be read data.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ */
+gboolean
+garrow_readable_read(GArrowReadable *readable,
+ gint64 n_bytes,
+ gint64 *n_read_bytes,
+ guint8 *buffer,
+ GError **error)
+{
+ const auto arrow_readable = garrow_readable_get_raw(readable);
+
+ auto status = arrow_readable->Read(n_bytes, n_read_bytes, buffer);
+ if (status.ok()) {
+ return TRUE;
+ } else {
+ garrow_error_set(error, status, "[io][readable][read]");
+ return FALSE;
+ }
+}
+
+G_END_DECLS
+
+std::shared_ptr<arrow::io::Readable>
+garrow_readable_get_raw(GArrowReadable *readable)
+{
+ auto *iface = GARROW_READABLE_GET_IFACE(readable);
+ return iface->get_raw(readable);
+}
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/readable.h
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/readable.h b/c_glib/arrow-glib/readable.h
new file mode 100644
index 0000000..bde4b01
--- /dev/null
+++ b/c_glib/arrow-glib/readable.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_READABLE \
+ (garrow_readable_get_type())
+#define GARROW_READABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GARROW_TYPE_READABLE, \
+ GArrowReadable))
+#define GARROW_IS_READABLE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
+ GARROW_TYPE_READABLE))
+#define GARROW_READABLE_GET_IFACE(obj) \
+ (G_TYPE_INSTANCE_GET_INTERFACE((obj), \
+ GARROW_TYPE_READABLE, \
+ GArrowReadableInterface))
+
+typedef struct _GArrowReadable GArrowReadable;
+typedef struct _GArrowReadableInterface GArrowReadableInterface;
+
+GType garrow_readable_get_type(void) G_GNUC_CONST;
+
+gboolean garrow_readable_read(GArrowReadable *readable,
+ gint64 n_bytes,
+ gint64 *n_read_bytes,
+ guint8 *buffer,
+ GError **error);
+
+G_END_DECLS
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/c_glib/arrow-glib/readable.hpp
----------------------------------------------------------------------
diff --git a/c_glib/arrow-glib/readable.hpp b/c_glib/arrow-glib/readable.hpp
new file mode 100644
index 0000000..c241c77
--- /dev/null
+++ b/c_glib/arrow-glib/readable.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/readable.h>
+
+/**
+ * GArrowReadableInterface:
+ *
+ * It wraps `arrow::io::Readable`.
+ */
+struct _GArrowReadableInterface
+{
+ GTypeInterface parent_iface;
+
+ std::shared_ptr<arrow::io::Readable> (*get_raw)(GArrowReadable *file);
+};
+
+std::shared_ptr<arrow::io::Readable> garrow_readable_get_raw(GArrowReadable *readable);
http://git-wip-us.apache.org/repos/asf/arrow/blob/6443b828/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
new file mode 100644
index 0000000..c4ccebe
--- /dev/null
+++ b/c_glib/arrow-glib/stream-reader.cpp
@@ -0,0 +1,221 @@
+/*
+ * 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::StreamReader> 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::StreamReader> *>(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::StreamReader",
+ "The raw std::shared<arrow::ipc::StreamReader> *",
+ static_cast<GParamFlags>(G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property(gobject_class, PROP_STREAM_READER, spec);
+}
+
+/**
+ * garrow_stream_reader_open:
+ * @stream: The stream to be read.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full): A newly opened
+ * #GArrowStreamReader or %NULL on error.
+ */
+GArrowStreamReader *
+garrow_stream_reader_open(GArrowInputStream *stream,
+ GError **error)
+{
+ std::shared_ptr<arrow::ipc::StreamReader> arrow_stream_reader;
+ auto status =
+ arrow::ipc::StreamReader::Open(garrow_input_stream_get_raw(stream),
+ &arrow_stream_reader);
+ if (status.ok()) {
+ return garrow_stream_reader_new_raw(&arrow_stream_reader);
+ } else {
+ garrow_error_set(error, status, "[ipc][stream-reader][open]");
+ 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 (status.ok()) {
+ if (arrow_record_batch == nullptr) {
+ return NULL;
+ } else {
+ return garrow_record_batch_new_raw(&arrow_record_batch);
+ }
+ } else {
+ garrow_error_set(error, status, "[ipc][stream-reader][get-next-record-batch]");
+ return NULL;
+ }
+}
+
+G_END_DECLS
+
+GArrowStreamReader *
+garrow_stream_reader_new_raw(std::shared_ptr<arrow::ipc::StreamReader> *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::StreamReader>
+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/6443b828/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
new file mode 100644
index 0000000..16a7f57
--- /dev/null
+++ b/c_glib/arrow-glib/stream-reader.h
@@ -0,0 +1,80 @@
+/*
+ * 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::StreamReader`.
+ */
+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_open(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/6443b828/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
new file mode 100644
index 0000000..ca8e689
--- /dev/null
+++ b/c_glib/arrow-glib/stream-reader.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-reader.h>
+
+GArrowStreamReader *garrow_stream_reader_new_raw(std::shared_ptr<arrow::ipc::StreamReader> *arrow_stream_reader);
+std::shared_ptr<arrow::ipc::StreamReader> garrow_stream_reader_get_raw(GArrowStreamReader *stream_reader);