Skip to contents

This class implements a Zarr group. A Zarr group is a node in the hierarchy of a Zarr object. A group is a container for other groups and arrays.

A Zarr group is identified by a JSON file having required metadata, specifically the attribute "node_type": "group".

Super class

zarr_node -> zarr_group

Active bindings

children

(read-only) The children of the group. This is a list of zarr_group and zarr_array instances, or the empty list if the group has no children.

groups

(read-only) Retrieve the paths to the sub-groups of the hierarchy starting from the current group, as a character vector.

arrays

(read-only) Retrieve the paths to the arrays of the hierarchy starting from the current group, as a character vector.

Methods

Inherited methods


zarr_group$new()

Open a group in a Zarr hierarchy. The group must already exist in the store.

Usage

zarr_group$new(name, metadata, parent, store)

Arguments

name

The name of the group. For a root group, this is the empty string "".

metadata

List with the metadata of the group.

parent

The parent zarr_group instance of this new group, can be missing or NULL for the root group.

store

The zarr_store instance to persist data in.

Returns

An instance of zarr_group.


zarr_group$post_open()

This method is called automatically after a Zarr store is opened to allow for operations after the full hierarchy has been established. All contained children will be called similarly.

Usage

zarr_group$post_open()

Returns

Self, invisibly.


zarr_group$print()

Print a summary of the group to the console.

Usage

zarr_group$print()


zarr_group$hierarchy_nodes()

Collects the hierarchy of the group and its subgroups and arrays in a character vector. Usually called from the Zarr object or a group to display the full group hierarchy.

Usage

zarr_group$hierarchy_nodes(idx = 1L, total = 1L)

Arguments

idx, total

Arguments to control indentation. Should both be 1 (the default) when called interactively. The values will be updated during recursion when there are groups below the current group.


zarr_group$hierarchy()

Print the Zarr hierarchy to the console from the current group.

Usage

zarr_group$hierarchy()


zarr_group$build_hierarchy()

Return the hierarchy contained in the store as a tree of group and array nodes. This method only has to be called after opening an existing Zarr store - this is done automatically by user-facing code. After that, users can access the children property of this class.

Usage

zarr_group$build_hierarchy()

Returns

This zarr_group instance with all of its children linked.


zarr_group$get_node()

Retrieve the group or array represented by the node located at the path relative from the current group.

Usage

zarr_group$get_node(path)

Arguments

path

The path to the node to retrieve. The path is relative to the group, it must not start with a slash "/". The path may start with any number of double dots ".." separated by slashes "/" to denote groups higher up in the hierarchy.

Returns

The zarr_group or zarr_array instance located at path, or NULL if the path was not found.


zarr_group$set_node()

Set a group or array in the current group. CAUTION: The node must have been persisted to the store for a reliable functioning. All that this method does is update the in-memory representation of the Zarr hierarchy.

Usage

zarr_group$set_node(node)

Arguments

node

The group or array to insert in this group. CAUTION: If a node with an identical name already exists in this group it will be replaced by the object in this argument.

Returns

The node object.


zarr_group$count_arrays()

Count the number of arrays in this group, optionally including arrays in sub-groups.

Usage

zarr_group$count_arrays(recursive = TRUE)

Arguments

recursive

Logical flag that indicates if arrays in sub-groups should be included in the count. Default is TRUE.


zarr_group$add_group()

Add a group to the Zarr hierarchy under the current group.

Usage

zarr_group$add_group(name)

Arguments

name

The name of the new group.

Returns

The newly created zarr_group instance, or NULL if the group could not be created.


zarr_group$add_array()

Add an array to the Zarr hierarchy in the current group.

Usage

zarr_group$add_array(name, metadata)

Arguments

name

The name of the new array.

metadata

A list with the metadata for the new array, or an instance of class array_builder whose data make a valid array definition.

Returns

The newly created zarr_array instance, or NULL if the array could not be created.


zarr_group$delete()

Delete a group or an array contained by this group. When deleting a group it cannot contain other groups or arrays. Warning: this operation is irreversible for many stores!

Usage

zarr_group$delete(name)

Arguments

name

The name of the group or array to delete. This will also accept a path to a group or array but the group or array must be a node directly under this group.

Returns

Self, invisibly.


zarr_group$delete_all()

Delete all the groups and arrays contained by this group, including any sub-groups and arrays. Any specific metadata attached to this group is deleted as well - only a basic metadata document is maintained. Warning: this operation is irreversible for many stores!

Usage

zarr_group$delete_all()

Returns

Self, invisibly.