This class implements a Zarr object. A Zarr object is a set of objects that make up an instance of a Zarr data set, irrespective of where it is located. The Zarr object manages the hierarchy as well as the underlying store.
A Zarr object may contain multiple Zarr arrays in a hierarchy. The main
class for managing Zarr arrays is zarr_array. The hierarchy is made up of
zarr_group instances. Each zarr_array is located in a zarr_group.
Active bindings
version(read-only) The version of the Zarr object.
rootThe root node of the Zarr object, usually a zarr_group instance but it could also be a zarr_array instance. CAUTION: When setting the root node, the entire existing hierarchy is deleted. The hierarchy will likely be out of sync with the store after setting the root node.
store(read-only) The store of the Zarr object.
domain(read-only) The
zarr_domaininstance managing the data in thiszarrobject.groups(read-only) Retrieve the paths to the groups of the Zarr object, starting from the root group, as a character vector.
arrays(read-only) Retrieve the paths to the arrays of the Zarr object, starting from the root group, as a character vector.
Methods
zarr$new()
Create a new Zarr instance. The Zarr instance manages the groups and arrays in the Zarr store that it refers to. This instance provides access to all objects in the Zarr store.
This method can open any Zarr store located on systems with a supported protocol ('local', 's3', 'http').
This method can also create a new Zarr store on a local file system or
in memory. It is not possible to create a new store on S3 or an a web
server. The newly created store is uninitialised, it is an empty
directory. Either assign a zarr_array to the root field, or create
a root zarr_group to make the store valid and usable.
Usage
zarr$new(store, read_only = NULL, protocol = NULL, ...)Arguments
storeOptional. Either an instance of a zarr_store descendant class where the Zarr objects are located, or character string that indicates a location on a file system or a HTTP or S3 server where the Zarr store is to be found. The character string may contain UTF-8 characters and/or use a file URI format. On a local file system the Zarr store will be created if it does not exist. If omitted, an in-memory Zarr store will be created.
read_onlyOptional. Logical that indicates if the store is to be opened in read-only mode. Default is
NULL, which impliesFALSEfor a local file system and memory store,TRUEotherwise.protocolOptional, character string. Override automatic protocol detection ('local', 'http', or 's3'). Needed for S3-compatible endpoints that aren't AWS and don't follow AWS's hostname conventions (MinIO, EMBASSY Cloud, Ceph RGW, etc.) - there's no reliable way to recognize these from the URL alone, you have to indicate so explicitly rather than have this method parse the location.
...Additional protocol-specific parameters passed through to the underlying store constructor. For
s3://and S3https://locations, this includesregion,profile,access_key/secret_key/session_token,endpoint, andanonymous— see zarr_s3store. Ignored for memory, local and plain HTTP locations.
zarr$print()
Print a summary of the Zarr object to the console.
zarr$get_node()
Retrieve the group or array represented by the node located at the path.
Returns
The zarr_group or zarr_array instance located at path, or
NULL if the path was not found.
zarr$add_group()
Add a group below a given path.
Arguments
pathThe path to the parent group of the new group, a single character string.
nameThe name for the new group, a single character string.
Returns
The newly created zarr_group, or NULL if the group could not
be created.
zarr$add_array()
Add an array to the store.
Arguments
pathOptional. The path to the group of the new array, a single character string. If omitted, a single-array store is assumed and the store must be uninitialised (meaning that it cannot already hold any groups or arrays).
nameThe name for the new array, a single character string.
metadataA
listwith the metadata for the new array, or a valid array_builder instance.
Returns
The newly created zarr_array, or NULL if the array could not
be created.
zarr$delete_group()
Delete a group from the Zarr object. This will also delete
the group from the Zarr store. The root group cannot be deleted but it
can be specified through path = "/" in which case the root group
loses any specific group metadata (with only the basic parameters
remaining), as well as any arrays and sub-groups if recursive = TRUE.
Warning: this operation is irreversible for many stores!
zarr$delete_array()
Delete an array from the Zarr object. If the array is the root of the Zarr object, the Zarr object will become uninitialised. Warning: this operation is irreversible for many stores!
zarr$save_to()
This method can be used to save a Zarr store to a different location. The entire store is persisted to the new location.
Note that saving a Zarr store on a local file system to another location on the same local file system is usually much faster with disk management tools of the operating system (e.g. copy/paste).
The new Zarr store is always written as Zarr version 3. This method can thus be used to quickly convert from Zarr version 2 to version 3 stores.
Arguments
locationCharacter string that indicates a location where to save this Zarr object to. Any writable location may be used, such as a directory on a local file system or a bucket on a S3 server. The character string may contain UTF-8 characters and/or use a file URI format. The Zarr specification recommends that the location use the ".zarr" extension to identify the location as a Zarr store.
verboseShould feedback be provided? Default is
FALSE. WhenTRUEand in interactive mode and theclipackage is installed then that package will be used, otherwise standard text messages will be printed to the console.