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/05/12 18:28:13 UTC

[GitHub] [arrow] jonkeane commented on a change in pull request #10191: ARROW-12731: [R] Use InMemoryDataset for Table/RecordBatch in dplyr code

jonkeane commented on a change in pull request #10191:
URL: https://github.com/apache/arrow/pull/10191#discussion_r631302181



##########
File path: r/R/dplyr-functions.R
##########
@@ -0,0 +1,352 @@
+# 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.
+
+
+#' @include expression.R
+NULL
+
+# This environment is an internal cache for things including data mask functions
+# We'll populate it at package load time.
+.cache <- NULL
+init_env <- function () {
+  .cache <<- new.env(hash = TRUE)
+}
+init_env()

Review comment:
       I haven't installed this and tested if there is any issue here (the only circumstance I could imagine is if someone has `.cache` in their global environment already, would this assign to that or would it assign to the .cache that's in arrow's namespace?
   
   For {dittodb} I create the environment when the package is compiled and then populate it at run time. I haven't (yet) found where I found this pattern, but I've seen it used elsewhere too (and found someone I trusted explaining this is the best way to do something like this). https://github.com/ropensci/dittodb/blob/51d8f9e50585f7a4791fce7d8da5fea3f5c7bc5f/R/dittodb-env.R#L8




-- 
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.

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