setHdd_extract.cap: Sets/gets the size cap when extracting hdd data

View source: R/misc.R

setHdd_extract.capR Documentation

Sets/gets the size cap when extracting hdd data

Description

Sets/gets the default size cap when extracting HDD variables with cash-.hdd or when importing full HDD data sets with readfst.

Usage

setHdd_extract.cap(sizeMB = 3000)

getHdd_extract.cap

Arguments

sizeMB

Size cap in MB. Default is 3000.

Format

An object of class function of length 1.

Details

In readfst, if the expected size of the data set exceeds the cap then, in interactive mode, a confirmation is asked. When not in interactive mode, no confirmation is asked. This can also be bypassed by using the argument confirm.

Value

The size cap, a numeric scalar.

Examples


# Toy example with iris data
# We first create a hdd dataset with approx. 100KB
hdd_path = tempfile() # => folder where the data will be saved
write_hdd(iris, hdd_path)
for(i in 1:10) write_hdd(iris, hdd_path, add = TRUE)

base_hdd = hdd(hdd_path)
summary(base_hdd) # => 11 files

# we can extract the data from the 11 files with '$':
pl = base_hdd$Sepal.Length

#
# Illustration of the protection mechanism:
#

# By default when extracting a variable with '$'
# and the size exceeds the cap (default is greater than 3GB)
# a confirmation is needed.
# You can set the cap with setHdd_extract.cap.

# Following code asks a confirmation:
setHdd_extract.cap(sizeMB = 0.005) # new cap of 5KB
try(pl <- base_hdd$Sepal.Length)

# To extract the variable without changing the cap:
pl = base_hdd[, Sepal.Length] # => no size control is performed

# Resetting the default cap
setHdd_extract.cap()



hdd documentation built on Aug. 25, 2023, 5:19 p.m.