You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2019/06/09 20:52:58 UTC
[arrow] branch master updated: ARROW-5534: [GLib] Add
garrow_table_concatenate()
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 2e47488 ARROW-5534: [GLib] Add garrow_table_concatenate()
2e47488 is described below
commit 2e474881f9e29566ab4496a45c925d7fb6dfbdae
Author: Yosuke Shiro <yo...@gmail.com>
AuthorDate: Mon Jun 10 05:52:40 2019 +0900
ARROW-5534: [GLib] Add garrow_table_concatenate()
Author: Yosuke Shiro <yo...@gmail.com>
Closes #4500 from shiro615/glib-table-concatenate and squashes the following commits:
9ecf7b3d7 <Yosuke Shiro> Add a missing version check macro
dfa0b37fd <Yosuke Shiro> Add a missing annotation
214b2d6fb <Yosuke Shiro> Add garrow_table_concatenate()
---
c_glib/arrow-glib/table.cpp | 30 ++++++++++++++++++++++++++++++
c_glib/arrow-glib/table.h | 5 +++++
c_glib/test/test-table.rb | 8 ++++++++
3 files changed, 43 insertions(+)
diff --git a/c_glib/arrow-glib/table.cpp b/c_glib/arrow-glib/table.cpp
index b889eb2..51a5adb 100644
--- a/c_glib/arrow-glib/table.cpp
+++ b/c_glib/arrow-glib/table.cpp
@@ -532,6 +532,36 @@ garrow_table_to_string(GArrowTable *table, GError **error)
}
}
+/**
+ * garrow_table_concatenate:
+ * @table: A #GArrowTable.
+ * @other_tables: (element-type GArrowTable): The tables to be concatenated.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable) (transfer full): The table concatenated vertically.
+ *
+ * Since: 0.14.0
+ */
+GArrowTable *
+garrow_table_concatenate(GArrowTable *table,
+ GList *other_tables,
+ GError **error)
+{
+ auto arrow_table = garrow_table_get_raw(table);
+ std::vector<std::shared_ptr<arrow::Table>> arrow_tables = { arrow_table };
+ for (auto node = other_tables; node; node = g_list_next(node)) {
+ auto arrow_other_table = garrow_table_get_raw(GARROW_TABLE(node->data));
+ arrow_tables.push_back(arrow_other_table);
+ }
+ std::shared_ptr<arrow::Table> arrow_concatenated_table;
+ auto status = arrow::ConcatenateTables(arrow_tables, &arrow_concatenated_table);
+ if (garrow_error_check(error, status, "[table][concatenate]")) {
+ return garrow_table_new_raw(&arrow_concatenated_table);
+ } else {
+ return NULL;
+ }
+}
+
G_END_DECLS
GArrowTable *
diff --git a/c_glib/arrow-glib/table.h b/c_glib/arrow-glib/table.h
index bde2535..763f6d8 100644
--- a/c_glib/arrow-glib/table.h
+++ b/c_glib/arrow-glib/table.h
@@ -89,5 +89,10 @@ GArrowTable *garrow_table_replace_column(GArrowTable *table,
GError **error);
gchar *garrow_table_to_string (GArrowTable *table,
GError **error);
+GARROW_AVAILABLE_IN_0_14
+GArrowTable *
+garrow_table_concatenate(GArrowTable *table,
+ GList *other_tables,
+ GError **error);
G_END_DECLS
diff --git a/c_glib/test/test-table.rb b/c_glib/test/test-table.rb
index 871e0d7..491fb58 100644
--- a/c_glib/test/test-table.rb
+++ b/c_glib/test/test-table.rb
@@ -175,5 +175,13 @@ valid:
]
TABLE
end
+
+ def test_concatenate
+ table = build_table("visible" => build_boolean_array([true, false, true, false]))
+ table1 = build_table("visible" => build_boolean_array([true]))
+ table2 = build_table("visible" => build_boolean_array([false, true]))
+ table3 = build_table("visible" => build_boolean_array([false]))
+ assert_equal(table, table1.concatenate([table2, table3]))
+ end
end
end