This class implements a Zarr node. The node is an element in the hierarchy of the Zarr object. As per the Zarr specification, the node is either a group or an array. Thus, this class is the ancestor of the zarr_group and zarr_array classes. This class manages common features such as names, key, prefixes and paths, as well as the hierarchy between nodes and the zarr_store for persistent storage.
This class should never have to be instantiated or accessed directly.
Instead, use instances of zarr_group or zarr_array. Function arguments
are largely not checked, the group and array instances should do so prior
to calling methods here. The big exception is checking the validity of node
names.
Active bindings
name(read-only) The name of the node.
parentThe parent of the node. For a root node this returns
NULL, otherwise thiszarr_grouporzarr_arrayinstance. CAUTION: Setting the parent of a node can invalidate the Zarr hierarchy - expert use only.store(read-only) The store of the node.
path(read-only) The path of this node, relative to the root node of the hierarchy.
prefix(read-only) The prefix of this node, relative to the root node of the hierarchy.
metadataThe metadata document of this node, a
list. CAUTION: Setting a list that is not properly describing this object will render the object invalid.attributes(read-only) Retrieve the list of attributes of this object. Attributes can be added or modified with the
set_attribute()method or removed with thedelete_attributes()method.
Methods
zarr_node$new()
Initialize a new node in a Zarr hierarchy.
Usage
zarr_node$new(name, metadata, parent, store)zarr_node$post_open()
This method is called automatically after a Zarr store is opened to allow for operations after the full hierarchy has been established. This is a no-op here, descendant classes with specific requirements should implement this method.
zarr_node$print_attributes()
Print the metadata "attributes" to the console. Usually
called by the zarr_group and zarr_array print() methods.
zarr_node$attribute()
Retrieve a specific attribute by path.
zarr_node$set_attribute()
Add an attribute to the metadata of the object. If an
attribute name already exists, it will be overwritten.
Arguments
nameThe name of the attribute. The name may be a compound path, relative to the "attributes" entry in the metadata, using a slash "/" as path separator. Each of the elements in the path (between slashes) must begin with a letter and be composed of letters, digits, and underscores and can be at most 255 characters long. Missing path elements will be created.
valueThe value of the attribute. This can be of any supported type, including a vector or list of values. In general, an attribute should be a character value, a numeric value, a logical value, or a short vector or list of any of these.
zarr_node$append_array_attribute()
Append an attribute to an array in the metadata of the
object. If an attribute name already exists, it will be overwritten.
Arguments
nameThe name of the attribute. The name may be a compound path, relative to the "attributes" entry in the metadata, using a slash "/" as path separator. Each of the elements in the path (between slashes) must begin with a letter and be composed of letters, digits, and underscores and can be at most 255 characters long. Missing path elements will be created.
valueThe value of the attribute. This can be of any supported type, including a vector or list of values. In general, an attribute should be a character value, a numeric value, a logical value, or a short vector or list of any of these.
afterA subscript, after which
valueis to be appended. The default isNULL, meaning thatvaluewill be placed after the existing values. Specifyingafter = 0Lwill placevaluebefore the existing values.
zarr_node$delete_attribute()
Delete an attribute or array element. If the attribute is not present, this method simply returns.
Arguments
nameCharacter. The name (path) of the attribute to delete, using
/as separator for nested attributes, e.g."first/second/my_att". Thenameis relative to theattributesentry in the metadata of the node. To target an element of a JSON array attribute, append the 1-based index as the path segment, e.g."first/second/my_arr/2"to delete the second element in the array, or"first/second/my_arr/2/description"to delete only thedescriptionfield inside it. This nesting can be arbitrarily deep, including over multiple JSON arrays.