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 2022/04/01 19:49:47 UTC

[GitHub] [arrow] save-buffer commented on a change in pull request #12769: ARROW-16076: [R] Bindings for the new TPC-H generator

save-buffer commented on a change in pull request #12769:
URL: https://github.com/apache/arrow/pull/12769#discussion_r840876975



##########
File path: r/R/tpch.R
##########
@@ -0,0 +1,61 @@
+# 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.
+
+tpch_tables <- c("customer", "lineitem", "nation", "orders", "part", "partsupp", "region", "supplier")
+
+
+#' Generate a RecordBatchReader with TPC-H data in it
+#'
+#' @param table the table to generate
+#' @param scale_factor the scale factor to generate
+#'
+#' @return a RecordBatchReader that will contain the generated data
+#' @export
+#'
+#' @keywords internal
+tpch_dbgen <- function(table = tpch_tables, scale_factor) {
+  table <- match.arg(table)
+
+  Tpch_Dbgen(ExecPlan$create(), scale_factor, table)
+}
+
+#' Generate TPC-H data as datasets
+#'
+#' This will generate all of the TPC-H data as a set of datasets for a given
+#' `scale_factor`
+#'
+#' @param scale_factor numeric, scale factor of data to generate
+#' @param path
+#' @param ...
+#'
+#' @return the path to the directory containing the datasets
+#' @export
+#' @keywords internal
+tpch_dbgen_write <- function(scale_factor, path, ...) {
+  path_and_fs <- get_path_and_filesystem(path)
+  folder_name <- paste0("/tpch_", format(scale_factor, scientific = FALSE))
+
+  Tpch_Dbgen_Write(
+    ExecPlan$create(),
+    scale_factor,
+    path_and_fs$fs,
+    path_and_fs$path,
+    folder_name
+  )
+
+  invisible(file.path(path_and_fs$path, folder_name))
+}

Review comment:
       I would like to investigate this a bit more too. I feel like it should be freeing more memory while writing to disk. 




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