save_hashmap: Save Hashmaps

Description Usage Arguments Details Value See Also Examples

Description

save_hashmap writes a Hashmap's data to the specified file, which can be passed to load_hashmap at a later point in time to recreate the object.

Usage

1
save_hashmap(x, file, overwrite = TRUE, compress = FALSE)

Arguments

x

an object created by a call to hashmap.

file

a filename where the object's data will be saved.

overwrite

if TRUE (default) and file exists, it will be overwritten. If FALSE and file exists, an error is thrown.

compress

a logical value or the type of file compression to use; defaults to FALSE for better performance. See ?saveRDS for details.

Details

Saving is done by calling base::saveRDS on the object's data.frame representation, x$data.frame(). Attempting to save an empty Hashmap results in an error.

Value

Nothing on success; an error on failure.

See Also

load_hashmap, saveRDS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
H <- hashmap(sample(letters[1:10]), sample(1:10))
tf <- tempfile()

save_hashmap(H, tf)

inherits(
    try(save_hashmap(H, tf, FALSE), silent = TRUE),
    "try-error"
)

H$insert("zzzzz", 123L)
save_hashmap(H, tf)

load_hashmap(tf)

Example output

[1] TRUE
## (character) => (integer)
##         [e] => [2]      
##         [h] => [8]      
##         [c] => [4]      
##         [f] => [3]      
##         [b] => [1]      
##         [d] => [6]      
##       [...] => [...]    

hashmap documentation built on May 1, 2019, 10:13 p.m.