You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/30 21:22:01 UTC

[GitHub] [arrow] kou commented on a change in pull request #12041: ARROW-15203: [GLib] garrow_struct_scalar_get_value() for scalar from C++ returns value

kou commented on a change in pull request #12041:
URL: https://github.com/apache/arrow/pull/12041#discussion_r776869489



##########
File path: c_glib/arrow-glib/scalar.cpp
##########
@@ -2039,6 +2039,16 @@ GList *
 garrow_struct_scalar_get_value(GArrowStructScalar *scalar)
 {
   auto priv = GARROW_STRUCT_SCALAR_GET_PRIVATE(scalar);
+  if (!priv->value) {
+    auto arrow_scalar =
+      std::static_pointer_cast<arrow::StructScalar>(
+        garrow_scalar_get_raw(GARROW_SCALAR(scalar)));
+    for (auto arrow_element : arrow_scalar->value) {
+      priv->value = g_list_prepend(priv->value,
+                                   garrow_scalar_new_raw(&arrow_element));
+    }
+    priv->value = g_list_reverse(priv->value);
+  }

Review comment:
       This is a idiom in GLib. This is for performance but this will not be needed here.
   
   `GList` is a linked list. `g_list_append()` is O(N) (N is the number of elements). `g_list_prepend()` is O(1). `g_list_reverse()` is O(N).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org