provides hybrid data structure for 'HDF5' file
Value
none
self instance
self instance
subset of data
dimension of the array
data type, currently only character, integer, raw, double, and complex are available, all other types will yield "unknown"
Methods
Method save()
save data to a 'HDF5' file
Usage
LazyH5$save(
x,
chunk = "auto",
level = 7,
replace = TRUE,
new_file = FALSE,
force = TRUE,
ctype = NULL,
size = NULL,
...
)
Arguments
x
vector, matrix, or array
chunk
chunk size, length should matches with data dimension
level
compress level, from 1 to 9
replace
if the data exists in the file, replace the file or not
new_file
remove the whole file if exists before writing?
force
if you open the file in read-only mode, then saving objects to the file will raise error. Use
force=TRUE
to force write datactype
data type, see
mode
, usually the data type ofx
. Trymode(x)
orstorage.mode(x)
as hints.size
deprecated, for compatibility issues
...
passed to self
open()
method
Method open()
open connection
Method close()
close connection
Method subset()
subset data
Usage
LazyH5$subset(..., drop = FALSE, stream = FALSE, envir = parent.frame())
Arguments
drop
whether to apply
drop
the subsetstream
whether to read partial data at a time
envir
if
i,j,...
are expressions, where should the expression be evaluatedi, j, ...
index along each dimension
Examples
# Data to save
x <- array(rnorm(1000), c(10,10,10))
# Save to local disk
f <- tempfile()
save_h5(x, file = f, name = 'x', chunk = c(10,10,10), level = 0)
#> /var/folders/95/0ydz4d79163427j3k5crp3fh0000gn/T//RtmpN1XDVO/file17ff798e4160 => x (Dataset Created)
#> /var/folders/95/0ydz4d79163427j3k5crp3fh0000gn/T//RtmpN1XDVO/file17ff798e4160 => x (Dataset Removed)
#> /var/folders/95/0ydz4d79163427j3k5crp3fh0000gn/T//RtmpN1XDVO/file17ff798e4160 => x (Dataset Created)
# Load via LazyFST
dat <- LazyH5$new(file_path = f, data_name = 'x', read_only = TRUE)
dat
# Check whether the data is identical
range(dat - x)
#> [1] 0 0
# Read a slice of the data
system.time(dat[,10,])
#> user system elapsed
#> 0.080 0.000 0.082