Skip to contents

Class providing access to user attributes on an array or group.

Format

R6::R6Class

Details

The Zarr Attributes class.

Public fields

store

Attributes store, already initialized.

key

The key under which the attributes will be stored.

read_only

If True, attributes cannot be modified.

cache

If True (default), attributes will be cached locally.

synchronizer

Only necessary if attributes may be modified from multiple threads or processes.

Methods


Method new()

Create a new Attributes instance.

Usage

Attributes$new(
  store,
  key = NA,
  read_only = FALSE,
  cache = TRUE,
  synchronizer = NA,
  zarr_format = NULL
)

Arguments

store

(Store)
Attributes store, already initialized.

key

(character(1))
Key to use for attributes (.zattrs is default).

read_only

(logical(1))
Whether the attributes are read-only.

cache

(logical(1))
Whether to cache attributes.

synchronizer

(ANY or NA)
Synchronizer object.

zarr_format

(integer(1) or NULL)
Zarr format version: 2L for V2 (.zattrs), 3L for V3 (zarr.json).

Returns

An Attributes instance.


Method to_list()

convert attributes to list

Usage

Attributes$to_list()

Returns

list().


Method refresh()

refresh attributes

Usage

Attributes$refresh()

Returns

NULL (called for side effects).


Method contains()

check if object contains item

Usage

Attributes$contains(x)

Arguments

x

Object to test.

Returns

logical(1).


Method get_item()

get attribute

Usage

Attributes$get_item(item)

Arguments

item

Character attribute name.

Returns

The attribute value.


Method set_item()

set attribute

Usage

Attributes$set_item(item, value)

Arguments

item

Character attribute name.

value

Value to add or update.

Returns

NULL (called for side effects).


Method del_item()

delete attribute

Usage

Attributes$del_item(item)

Arguments

item

Character attribute name.

Returns

NULL (called for side effects).


Method set_cached_v3_attrs()

Set cached attributes from V3 embedded metadata. In V3, attributes are part of zarr.json rather than a separate .zattrs file. This method pre-populates the cache so the normal .zattrs read path is skipped.

Usage

Attributes$set_cached_v3_attrs(attrs_list)

Arguments

attrs_list

A named list of attributes from V3 zarr.json.

Returns

NULL (modifies cache in place).


Method clone()

The objects of this class are cloneable with this method.

Usage

Attributes$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.