Skip to content

Commit 81f2c67

Browse files
committed
Added auto-set headers to filearray load or create function and set the header before on_missing call
1 parent 5f59eb1 commit 81f2c67

4 files changed

Lines changed: 19 additions & 10 deletions

File tree

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 0.1.8
2-
Date: 2024-09-03 17:52:24 UTC
3-
SHA: e4e2f4700fd4b8672305b51dee0f3372b5dedc67
1+
Version: 0.1.9
2+
Date: 2024-11-08 16:38:30 UTC
3+
SHA: 5f59eb137a26b7e2915a36884d8742407ce9fa72

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: filearray
22
Type: Package
33
Title: File-Backed Array for Out-of-Memory Computation
4-
Version: 0.1.9
4+
Version: 0.1.9.1
55
Language: en-US
66
Encoding: UTF-8
77
License: LGPL-3

R/load.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#' @param verbose whether to print out some debug messages
2626
#' @param on_missing function to handle file array (such as initialization)
2727
#' when a new array is created; must take only one argument, the array object
28+
#' @param auto_set_headers whether to automatically set headers if array is
29+
#' missing or to be created; default is true
2830
#' @return A \code{\link{FileArray-class}} instance.
2931
#'
3032
#' @details The file arrays partition out-of-memory array objects and store them
@@ -197,7 +199,8 @@ filearray_checkload <- function(
197199
filearray_load_or_create <- function(
198200
filebase, dimension, on_missing = NULL, type = NA,
199201
..., mode = c("readonly", "readwrite"), symlink_ok = TRUE,
200-
initialize = FALSE, partition_size = NA, verbose = FALSE
202+
initialize = FALSE, partition_size = NA, verbose = FALSE,
203+
auto_set_headers = TRUE
201204
) {
202205
mode <- match.arg(mode)
203206
filebase <- normalizePath(filebase, mustWork = FALSE, winslash = "/")
@@ -275,15 +278,17 @@ filearray_load_or_create <- function(
275278
partition_size = partition_size,
276279
initialize = initialize
277280
)
281+
# seal the header
282+
if( auto_set_headers ) {
283+
for(nm in add_header_names) {
284+
arr$set_header(key = nm, value = additional_headers[[nm]], save = FALSE)
285+
}
286+
}
278287
# run on_missing if the function exists
279288
if(is.function(on_missing)) {
280289
arr$.mode <- "readwrite"
281290
on_missing(arr)
282291
}
283-
# seal the header
284-
for(nm in add_header_names) {
285-
arr$set_header(key = nm, value = additional_headers[[nm]], save = FALSE)
286-
}
287292
arr$.save_header()
288293
arr
289294
}

man/filearray.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)