You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by mr...@apache.org on 2020/01/08 11:28:09 UTC

[arrow] branch ARROW-7444 created (now b67317a)

This is an automated email from the ASF dual-hosted git repository.

mrkn pushed a change to branch ARROW-7444
in repository https://gitbox.apache.org/repos/asf/arrow.git.


      at b67317a  Stop using unique_ptr to keep FileStats and FileSelector in a GObject

This branch includes the following new commits:

     new 438fa08  Return the result of garrow::check
     new b67317a  Stop using unique_ptr to keep FileStats and FileSelector in a GObject

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[arrow] 01/02: Return the result of garrow::check

Posted by mr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mrkn pushed a commit to branch ARROW-7444
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit 438fa08bffc71130f04bf5e8a176465be894f916
Author: Kenta Murata <mr...@mrkn.jp>
AuthorDate: Wed Jan 8 18:09:56 2020 +0900

    Return the result of garrow::check
---
 c_glib/arrow-glib/file-system.cpp | 28 +++++++++++-----------
 c_glib/arrow-glib/file-system.h   | 50 +++++++++++++++++++--------------------
 2 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/c_glib/arrow-glib/file-system.cpp b/c_glib/arrow-glib/file-system.cpp
index d68595d..73e0f7b 100644
--- a/c_glib/arrow-glib/file-system.cpp
+++ b/c_glib/arrow-glib/file-system.cpp
@@ -609,7 +609,7 @@ garrow_file_system_get_target_stats_selector(GArrowFileSystem *file_system,
  *
  * Since: 1.0.0
  */
-void
+gboolean
 garrow_file_system_create_dir(GArrowFileSystem *file_system,
                               const gchar *path,
                               gboolean recursive,
@@ -617,7 +617,7 @@ garrow_file_system_create_dir(GArrowFileSystem *file_system,
 {
   auto arrow_file_system = garrow_file_system_get_raw(file_system);
   auto status = arrow_file_system->CreateDir(path, recursive);
-  (void)garrow::check(error, status, "[filesystem][create-dir]");
+  return garrow::check(error, status, "[filesystem][create-dir]");
 }
 
 /**
@@ -630,14 +630,14 @@ garrow_file_system_create_dir(GArrowFileSystem *file_system,
  *
  * Since: 1.0.0
  */
-void
+gboolean
 garrow_file_system_delete_dir(GArrowFileSystem *file_system,
                               const gchar *path,
                               GError **error)
 {
   auto arrow_file_system = garrow_file_system_get_raw(file_system);
   auto status = arrow_file_system->DeleteDir(path);
-  (void)garrow::check(error, status, "[filesystem][delete-dir]");
+  return garrow::check(error, status, "[filesystem][delete-dir]");
 }
 
 /**
@@ -652,14 +652,14 @@ garrow_file_system_delete_dir(GArrowFileSystem *file_system,
  *
  * Since: 1.0.0
  */
-void
+gboolean
 garrow_file_system_delete_dir_contents(GArrowFileSystem *file_system,
                                        const gchar *path,
                                        GError **error)
 {
   auto arrow_file_system = garrow_file_system_get_raw(file_system);
   auto status = arrow_file_system->DeleteDirContents(path);
-  (void)garrow::check(error, status, "[filesystem][delete-dir-contents]");
+  return garrow::check(error, status, "[filesystem][delete-dir-contents]");
 }
 
 /**
@@ -672,14 +672,14 @@ garrow_file_system_delete_dir_contents(GArrowFileSystem *file_system,
  *
  * Since: 1.0.0
  */
-void
+gboolean
 garrow_file_system_delete_file(GArrowFileSystem *file_system,
                                const gchar *path,
                                GError **error)
 {
   auto arrow_file_system = garrow_file_system_get_raw(file_system);
   auto status = arrow_file_system->DeleteFile(path);
-  (void)garrow::check(error, status, "[filesystem][delete-file]");
+  return garrow::check(error, status, "[filesystem][delete-file]");
 }
 
 /**
@@ -693,7 +693,7 @@ garrow_file_system_delete_file(GArrowFileSystem *file_system,
  *
  * Since: 1.0.0
  */
-void
+gboolean
 garrow_file_system_delete_files(GArrowFileSystem *file_system,
                                 const gchar **paths,
                                 gsize n_paths,
@@ -706,7 +706,7 @@ garrow_file_system_delete_files(GArrowFileSystem *file_system,
     arrow_paths.emplace_back(paths[i]);
   }
   auto status = arrow_file_system->DeleteFiles(arrow_paths);
-  (void)garrow::check(error, status, "[filesystem][delete-files]");
+  return garrow::check(error, status, "[filesystem][delete-files]");
 }
 
 /**
@@ -724,7 +724,7 @@ garrow_file_system_delete_files(GArrowFileSystem *file_system,
  *
  * Since: 1.0.0
  */
-void
+gboolean
 garrow_file_system_move(GArrowFileSystem *file_system,
                         const gchar *src,
                         const gchar *dest,
@@ -732,7 +732,7 @@ garrow_file_system_move(GArrowFileSystem *file_system,
 {
   auto arrow_file_system = garrow_file_system_get_raw(file_system);
   auto status = arrow_file_system->Move(src, dest);
-  (void)garrow::check(error, status, "[filesystem][move]");
+  return garrow::check(error, status, "[filesystem][move]");
 }
 
 /**
@@ -748,7 +748,7 @@ garrow_file_system_move(GArrowFileSystem *file_system,
  *
  * Since: 1.0.0
  */
-void
+gboolean
 garrow_file_system_copy_file(GArrowFileSystem *file_system,
                              const gchar *src,
                              const gchar *dest,
@@ -756,7 +756,7 @@ garrow_file_system_copy_file(GArrowFileSystem *file_system,
 {
   auto arrow_file_system = garrow_file_system_get_raw(file_system);
   auto status = arrow_file_system->CopyFile(src, dest);
-  (void)garrow::check(error, status, "[filesystem][copy-file]");
+  return garrow::check(error, status, "[filesystem][copy-file]");
 }
 
 /**
diff --git a/c_glib/arrow-glib/file-system.h b/c_glib/arrow-glib/file-system.h
index 49ef122..4d4dec0 100644
--- a/c_glib/arrow-glib/file-system.h
+++ b/c_glib/arrow-glib/file-system.h
@@ -171,43 +171,43 @@ GList *garrow_file_system_get_target_stats_selector(GArrowFileSystem *file_syste
                                                     GError **error);
 
 GARROW_AVAILABLE_IN_1_0
-void garrow_file_system_create_dir(GArrowFileSystem *file_system,
-                                   const gchar *path,
-                                   gboolean recursive,
-                                   GError **error);
+gboolean garrow_file_system_create_dir(GArrowFileSystem *file_system,
+                                       const gchar *path,
+                                       gboolean recursive,
+                                       GError **error);
 
 GARROW_AVAILABLE_IN_1_0
-void garrow_file_system_delete_dir(GArrowFileSystem *file_system,
-                                   const gchar *path,
-                                   GError **error);
+gboolean garrow_file_system_delete_dir(GArrowFileSystem *file_system,
+                                       const gchar *path,
+                                       GError **error);
 
 GARROW_AVAILABLE_IN_1_0
-void garrow_file_system_delete_dir_contents(GArrowFileSystem *file_system,
-                                            const gchar *path,
-                                            GError **error);
+gboolean garrow_file_system_delete_dir_contents(GArrowFileSystem *file_system,
+                                                const gchar *path,
+                                                GError **error);
 
 GARROW_AVAILABLE_IN_1_0
-void garrow_file_system_delete_file(GArrowFileSystem *file_system,
-                                    const gchar *path,
-                                    GError **error);
+gboolean garrow_file_system_delete_file(GArrowFileSystem *file_system,
+                                        const gchar *path,
+                                        GError **error);
 
 GARROW_AVAILABLE_IN_1_0
-void garrow_file_system_delete_files(GArrowFileSystem *file_system,
-                                     const gchar **paths,
-                                     gsize n_paths,
-                                     GError **error);
+gboolean garrow_file_system_delete_files(GArrowFileSystem *file_system,
+                                        const gchar **paths,
+                                        gsize n_paths,
+                                        GError **error);
 
 GARROW_AVAILABLE_IN_1_0
-void garrow_file_system_move(GArrowFileSystem *file_system,
-                             const gchar *src,
-                             const gchar *dest,
-                             GError **error);
+gboolean garrow_file_system_move(GArrowFileSystem *file_system,
+                                 const gchar *src,
+                                 const gchar *dest,
+                                 GError **error);
 
 GARROW_AVAILABLE_IN_1_0
-void garrow_file_system_copy_file(GArrowFileSystem *file_system,
-                                  const gchar *src,
-                                  const gchar *dest,
-                                  GError **error);
+gboolean garrow_file_system_copy_file(GArrowFileSystem *file_system,
+                                      const gchar *src,
+                                      const gchar *dest,
+                                      GError **error);
 
 GARROW_AVAILABLE_IN_1_0
 GArrowInputStream *


[arrow] 02/02: Stop using unique_ptr to keep FileStats and FileSelector in a GObject

Posted by mr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mrkn pushed a commit to branch ARROW-7444
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit b67317aa5adb65c1274865f9e6d4615f8372c904
Author: Kenta Murata <mr...@mrkn.jp>
AuthorDate: Wed Jan 8 20:27:46 2020 +0900

    Stop using unique_ptr to keep FileStats and FileSelector in a GObject
---
 c_glib/arrow-glib/file-system.cpp | 60 +++++++++++++++++++--------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/c_glib/arrow-glib/file-system.cpp b/c_glib/arrow-glib/file-system.cpp
index 73e0f7b..b2d70d8 100644
--- a/c_glib/arrow-glib/file-system.cpp
+++ b/c_glib/arrow-glib/file-system.cpp
@@ -50,7 +50,7 @@ G_BEGIN_DECLS
 /* arrow::fs::FileStats */
 
 typedef struct GArrowFileStatsPrivate_ {
-  std::unique_ptr<arrow::fs::FileStats> file_stats;
+  arrow::fs::FileStats file_stats;
 } GArrowFileStatsPrivate;
 
 enum {
@@ -69,7 +69,7 @@ garrow_file_stats_finalize(GObject *object)
 {
   auto priv = GARROW_FILE_STATS_GET_PRIVATE(object);
 
-  priv->file_stats = nullptr;
+  priv->file_stats.~FileStats();
 
   G_OBJECT_CLASS(garrow_file_stats_parent_class)->finalize(object);
 }
@@ -78,7 +78,7 @@ static void
 garrow_file_stats_init(GArrowFileStats *object)
 {
   auto priv = GARROW_FILE_STATS_GET_PRIVATE(object);
-  new(&priv->file_stats) std::unique_ptr<arrow::fs::FileStats>;
+  new(&priv->file_stats) arrow::fs::FileStats;
 }
 
 static void
@@ -121,7 +121,7 @@ garrow_file_stats_equal(GArrowFileStats *file_stats,
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
   const auto& arrow_other_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(other_file_stats)->file_stats;
-  return arrow_file_stats->Equals(*arrow_other_file_stats);
+  return arrow_file_stats.Equals(arrow_other_file_stats);
 }
 
 GArrowFileType
@@ -129,7 +129,7 @@ garrow_file_stats_get_file_type(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  return static_cast<GArrowFileType>(arrow_file_stats->type());
+  return static_cast<GArrowFileType>(arrow_file_stats.type());
 }
 
 void
@@ -138,7 +138,7 @@ garrow_file_stats_set_file_type(GArrowFileStats *file_stats,
 {
   auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  arrow_file_stats->set_type(arrow::fs::FileType(file_type));
+  arrow_file_stats.set_type(arrow::fs::FileType(file_type));
 }
 
 gboolean
@@ -146,7 +146,7 @@ garrow_file_stats_is_file(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  return arrow_file_stats->IsFile();
+  return arrow_file_stats.IsFile();
 }
 
 gboolean
@@ -154,7 +154,7 @@ garrow_file_stats_is_directory(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  return arrow_file_stats->IsDirectory();
+  return arrow_file_stats.IsDirectory();
 }
 
 const gchar *
@@ -162,7 +162,7 @@ garrow_file_stats_get_path(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  return arrow_file_stats->path().c_str();
+  return arrow_file_stats.path().c_str();
 }
 
 void
@@ -171,7 +171,7 @@ garrow_file_stats_set_path(GArrowFileStats *file_stats,
 {
   auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  arrow_file_stats->set_path(path);
+  arrow_file_stats.set_path(path);
 }
 
 gchar *
@@ -179,7 +179,7 @@ garrow_file_stats_get_base_name(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  auto base_name = std::move(arrow_file_stats->base_name());
+  auto base_name = std::move(arrow_file_stats.base_name());
   return g_strndup(base_name.c_str(), base_name.size());
 }
 
@@ -188,7 +188,7 @@ garrow_file_stats_get_dir_name(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  auto dir_name = std::move(arrow_file_stats->dir_name());
+  auto dir_name = std::move(arrow_file_stats.dir_name());
   return g_strndup(dir_name.c_str(), dir_name.size());
 }
 
@@ -197,7 +197,7 @@ garrow_file_stats_get_extension(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  auto extension = std::move(arrow_file_stats->extension());
+  auto extension = std::move(arrow_file_stats.extension());
   return g_strndup(extension.c_str(), extension.size());
 }
 
@@ -206,7 +206,7 @@ garrow_file_stats_get_size(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  return arrow_file_stats->size();
+  return arrow_file_stats.size();
 }
 
 void
@@ -215,7 +215,7 @@ garrow_file_stats_set_size(GArrowFileStats *file_stats,
 {
   auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  arrow_file_stats->set_size(size);
+  arrow_file_stats.set_size(size);
 }
 
 GArrowTimePoint
@@ -223,7 +223,7 @@ garrow_file_stats_get_mtime(GArrowFileStats *file_stats)
 {
   const auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
-  auto mtime = arrow_file_stats->mtime();
+  auto mtime = arrow_file_stats.mtime();
   return mtime.time_since_epoch().count();
 }
 
@@ -234,13 +234,13 @@ garrow_file_stats_set_mtime(GArrowFileStats *file_stats,
   auto& arrow_file_stats =
     GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats;
   arrow::fs::TimePoint::duration duration(mtime);
-  arrow_file_stats->set_mtime(arrow::fs::TimePoint(duration));
+  arrow_file_stats.set_mtime(arrow::fs::TimePoint(duration));
 }
 
 /* arrow::fs::FileSelector */
 
 typedef struct GArrowFileSelectorPrivate_ {
-  std::unique_ptr<arrow::fs::FileSelector> file_selector;
+  arrow::fs::FileSelector file_selector;
 } GArrowFileSelectorPrivate;
 
 enum {
@@ -267,16 +267,16 @@ garrow_file_selector_set_property(GObject *object,
 
   switch (prop_id) {
   case PROP_FILE_SELECTOR_BASE_DIR:
-    priv->file_selector->base_dir = g_value_get_string(value);
+    priv->file_selector.base_dir = g_value_get_string(value);
     break;
   case PROP_FILE_SELECTOR_ALLOW_NON_EXISTENT:
-    priv->file_selector->allow_non_existent = g_value_get_boolean(value);
+    priv->file_selector.allow_non_existent = g_value_get_boolean(value);
     break;
   case PROP_FILE_SELECTOR_RECURSIVE:
-    priv->file_selector->recursive = g_value_get_boolean(value);
+    priv->file_selector.recursive = g_value_get_boolean(value);
     break;
   case PROP_FILE_SELECTOR_MAX_RECURSION:
-    priv->file_selector->max_recursion = g_value_get_int(value);
+    priv->file_selector.max_recursion = g_value_get_int(value);
     break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -294,16 +294,16 @@ garrow_file_selector_get_property(GObject *object,
 
   switch (prop_id) {
   case PROP_FILE_SELECTOR_BASE_DIR:
-    g_value_set_string(value, priv->file_selector->base_dir.c_str());
+    g_value_set_string(value, priv->file_selector.base_dir.c_str());
     break;
   case PROP_FILE_SELECTOR_ALLOW_NON_EXISTENT:
-    g_value_set_boolean(value, priv->file_selector->allow_non_existent);
+    g_value_set_boolean(value, priv->file_selector.allow_non_existent);
     break;
   case PROP_FILE_SELECTOR_RECURSIVE:
-    g_value_set_boolean(value, priv->file_selector->recursive);
+    g_value_set_boolean(value, priv->file_selector.recursive);
     break;
   case PROP_FILE_SELECTOR_MAX_RECURSION:
-    g_value_set_int(value, priv->file_selector->max_recursion);
+    g_value_set_int(value, priv->file_selector.max_recursion);
     break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -315,7 +315,7 @@ static void
 garrow_file_selector_init(GArrowFileSelector *object)
 {
   auto priv = GARROW_FILE_SELECTOR_GET_PRIVATE(object);
-  new(&priv->file_selector) std::unique_ptr<arrow::fs::FileSelector>;
+  new(&priv->file_selector) arrow::fs::FileSelector;
 }
 
 static void
@@ -323,7 +323,7 @@ garrow_file_selector_finalize(GObject *object)
 {
   auto priv = GARROW_FILE_SELECTOR_GET_PRIVATE(object);
 
-  priv->file_selector = nullptr;
+  priv->file_selector.~FileSelector();
 
   G_OBJECT_CLASS(garrow_file_selector_parent_class)->finalize(object);
 }
@@ -594,7 +594,7 @@ garrow_file_system_get_target_stats_selector(GArrowFileSystem *file_system,
   auto arrow_file_system = garrow_file_system_get_raw(file_system);
   const auto& arrow_file_selector =
     GARROW_FILE_SELECTOR_GET_PRIVATE(file_selector)->file_selector;
-  return garrow_file_stats_list_from_result(arrow_file_system->GetTargetStats(*arrow_file_selector),
+  return garrow_file_stats_list_from_result(arrow_file_system->GetTargetStats(arrow_file_selector),
                                             error, "[filesystem][get-target-stats-list]");
 }
 
@@ -972,7 +972,7 @@ GArrowFileStats *
 garrow_file_stats_new_raw(const arrow::fs::FileStats& arrow_file_stats)
 {
   auto file_stats = garrow_file_stats_new();
-  *GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats = arrow_file_stats;
+  GARROW_FILE_STATS_GET_PRIVATE(file_stats)->file_stats = arrow_file_stats;
   return file_stats;
 }