|
25 | 25 | #' @param verbose whether to print out some debug messages |
26 | 26 | #' @param on_missing function to handle file array (such as initialization) |
27 | 27 | #' 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 |
28 | 30 | #' @return A \code{\link{FileArray-class}} instance. |
29 | 31 | #' |
30 | 32 | #' @details The file arrays partition out-of-memory array objects and store them |
@@ -197,7 +199,8 @@ filearray_checkload <- function( |
197 | 199 | filearray_load_or_create <- function( |
198 | 200 | filebase, dimension, on_missing = NULL, type = NA, |
199 | 201 | ..., 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 |
201 | 204 | ) { |
202 | 205 | mode <- match.arg(mode) |
203 | 206 | filebase <- normalizePath(filebase, mustWork = FALSE, winslash = "/") |
@@ -275,15 +278,17 @@ filearray_load_or_create <- function( |
275 | 278 | partition_size = partition_size, |
276 | 279 | initialize = initialize |
277 | 280 | ) |
| 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 | + } |
278 | 287 | # run on_missing if the function exists |
279 | 288 | if(is.function(on_missing)) { |
280 | 289 | arr$.mode <- "readwrite" |
281 | 290 | on_missing(arr) |
282 | 291 | } |
283 | | - # seal the header |
284 | | - for(nm in add_header_names) { |
285 | | - arr$set_header(key = nm, value = additional_headers[[nm]], save = FALSE) |
286 | | - } |
287 | 292 | arr$.save_header() |
288 | 293 | arr |
289 | 294 | } |
|
0 commit comments