You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2023/06/08 12:34:26 UTC

[arrow-adbc] branch main updated: refactor(r/adbcdrivermanager): Early exit (#740)

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

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c5a57b3 refactor(r/adbcdrivermanager): Early exit (#740)
9c5a57b3 is described below

commit 9c5a57b3575b2592df0e2d1fbbe0f91f157c2923
Author: Kirill Müller <kr...@users.noreply.github.com>
AuthorDate: Thu Jun 8 14:34:21 2023 +0200

    refactor(r/adbcdrivermanager): Early exit (#740)
    
    to keep happy path on a normal indent level.
---
 r/adbcdrivermanager/R/helpers.R | 52 ++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/r/adbcdrivermanager/R/helpers.R b/r/adbcdrivermanager/R/helpers.R
index a157d371..2d8b9b38 100644
--- a/r/adbcdrivermanager/R/helpers.R
+++ b/r/adbcdrivermanager/R/helpers.R
@@ -259,32 +259,32 @@ adbc_statement_join <- function(statement, connection) {
 #' @rdname adbc_connection_join
 #' @export
 adbc_stream_join <- function(stream, x) {
-  if (utils::packageVersion("nanoarrow") >= "0.1.0.9000") {
-    assert_adbc(stream, "nanoarrow_array_stream")
-    assert_adbc(x)
-
-    self_contained_finalizer <- function() {
-      try(adbc_release_non_null(x))
-    }
-
-    # Make sure we don't keep any variables around that aren't needed
-    # for the finalizer and make sure we invalidate the original statement
-    self_contained_finalizer_env <- as.environment(
-      list(x = adbc_xptr_move(x))
-    )
-    parent.env(self_contained_finalizer_env) <- asNamespace("adbcdrivermanager")
-    environment(self_contained_finalizer) <- self_contained_finalizer_env
-
-    # This finalizer will run immediately on release (if released explicitly
-    # on the main R thread) or on garbage collection otherwise.
-
-    # Until the release version of nanoarrow contains this we will get a check
-    # warning for nanoarrow::array_stream_set_finalizer()
-    set_finalizer <- asNamespace("nanoarrow")[["array_stream_set_finalizer"]]
-    set_finalizer(stream, self_contained_finalizer)
-
-    invisible(stream)
-  } else {
+  if (utils::packageVersion("nanoarrow") < "0.1.0.9000") {
     stop("adbc_stream_join_statement() requires nanoarrow >= 0.2.0")
   }
+
+  assert_adbc(stream, "nanoarrow_array_stream")
+  assert_adbc(x)
+
+  self_contained_finalizer <- function() {
+    try(adbc_release_non_null(x))
+  }
+
+  # Make sure we don't keep any variables around that aren't needed
+  # for the finalizer and make sure we invalidate the original statement
+  self_contained_finalizer_env <- as.environment(
+    list(x = adbc_xptr_move(x))
+  )
+  parent.env(self_contained_finalizer_env) <- asNamespace("adbcdrivermanager")
+  environment(self_contained_finalizer) <- self_contained_finalizer_env
+
+  # This finalizer will run immediately on release (if released explicitly
+  # on the main R thread) or on garbage collection otherwise.
+
+  # Until the release version of nanoarrow contains this we will get a check
+  # warning for nanoarrow::array_stream_set_finalizer()
+  set_finalizer <- asNamespace("nanoarrow")[["array_stream_set_finalizer"]]
+  set_finalizer(stream, self_contained_finalizer)
+
+  invisible(stream)
 }