This class implements a Zarr store in RAM memory. With this class Zarr stores can be read and written to. Obviously, any data is not persisted after the memory store is de-referenced and garbage-collected.
All data is stored in a list. The Zarr array itself has a list with the metadata, its chunks have names like "c.0.0.0" and they have an R array-like value.
This class performs no sanity checks on any of the arguments passed to the methods, for performance reasons. Since this class should be accessed through group and array objects, it is up to that code to ensure that arguments are valid, in particular keys and prefixes.
zarr::zarr_store -> zarr_memorystore
friendlyClassName(read-only) Name of the class for printing.
separator(read-only) The separator of the memory store, always a dot '.'.
keys(read-only) The defined keys in the store.
new()Create an instance of this class.
zarr_memorystore$new()An instance of this class.
exists()Check if a key exists in the store. The key can point to a group, an array (having a metadata list as its value) or a chunk.
zarr_memorystore$exists(key)keyCharacter string. The key that the store will be searched for.
TRUE if argument key is found, FALSE otherwise.
clear()Clear the store. Remove all keys and values from the store. Invoking this method deletes all data and this action can not be undone.
zarr_memorystore$clear()TRUE. This operation always proceeds successfully once invoked.
erase()Remove a key from the store. The key must point to an array or a chunk. If the key points to an array, the key and all of subordinated keys are removed.
zarr_memorystore$erase(key)keyCharacter string. The key to remove from the store.
TRUE. This operation always proceeds successfully once invoked,
even if argument key does not point to an existing key.
erase_prefix()Remove all keys in the store that begin with a given prefix.
zarr_memorystore$erase_prefix(prefix)prefixCharacter string. The prefix to groups or arrays to remove from the store, including in child groups.
TRUE. This operation always proceeds successfully once invoked,
even if argument prefix does not point to any existing keys.
list_dir()Retrieve all keys with a given prefix and which do not contain the character "/" after the given prefix. In other words, this retrieves all the keys in the store below the key indicated by the prefix.
zarr_memorystore$list_dir(prefix)prefixCharacter string. The prefix whose nodes to list.
A character array with all keys found in the store immediately
below the prefix.
list_prefix()Retrieve all keys and prefixes with a given prefix.
zarr_memorystore$list_prefix(prefix)prefixCharacter string. The prefix to nodes to list.
A character vector with all paths found in the store below the
prefix location.
set()Store a (key, value) pair. If the value exists, it will
be overwritten.
zarr_memorystore$set(key, value)keyThe key whose value to set.
valueThe value to set, typically a complete chunk of data, a
raw vector.
Self, invisibly.
set_if_not_exists()Store a (key, value) pair. If the key exists, nothing
will be written.
zarr_memorystore$set_if_not_exists(key, value)keyThe key whose value to set.
valueThe value to set, a complete chunk of data.
Self, invisibly, or an error.
get()Retrieve the value associated with a given key.
zarr_memorystore$get(key, prototype = NULL, byte_range = NULL)keyCharacter string. The key for which to get data.
prototypeIgnored. The only buffer type that is supported maps directly to an R raw vector.
byte_rangeIf NULL, all data associated with the key is
retrieved. If a single positive integer, all bytes starting from a
given byte offset to the end of the object are returned. If a single
negative integer, the final bytes are returned. If an integer vector of
length 2, request a specific range of bytes where the end is exclusive.
If the range ends after the end of the object, the entire remainder of
the object will be returned. If the given range is zero-length or
starts after the end of the object, an error will be returned.
An raw vector of data, or NULL if no data was found.
get_metadata()Retrieve the metadata document at the location indicated by
the prefix argument.
zarr_memorystore$get_metadata(prefix)prefixThe prefix whose metadata document to retrieve.
A list with the metadata, or NULL if the prefix is not pointing
to a Zarr array.
create_group()Create a new group in the store under the specified path.
zarr_memorystore$create_group(path, name)pathThe path to the parent group of the new group. Ignored when creating a root group.
nameThe name of the new group. This may be an empty string ""
to create a root group. It is an error to supply an empty string if a
root group or array already exists.
A list with the metadata of the group, or an error if the group could not be created.
create_array()Create a new array in the store under key constructed from
the specified path to the parent argument and the name. The key may
not already exist in the store.
zarr_memorystore$create_array(parent, name, metadata)parentThe path to the parent group of the new array. This is
ignored if the name argument is the empty string.
nameThe name of the new array.
metadataA list with the metadata for the array. The list has to
be valid for array construction. Use the array_builder class to
create and or test for validity. An element "chunk_key_encoding" will
be added to the metadata if it not already there or contains an invalid
separator.
A list with the metadata of the array, or an error if the array could not be created.