| Type: | Package |
| Title: | Slice into 'Zarr' Arrays |
| Version: | 0.1.0 |
| Description: | An implementation of chunked, compressed, N-dimensional arrays for R following the 'Zarr' specification. Provides array and group creation, reading and writing with configurable chunk shapes, compression codecs, and storage backends including in-memory, local directory, and HTTP stores. Supports both 'Zarr' spec V2 (2024) <doi:10.5281/zenodo.11320255> and V3, enabling interoperable access to large array data commonly used in scientific computing and geospatial applications. |
| Language: | en-US |
| License: | MIT + file LICENSE |
| BugReports: | https://github.com/zarr-developers/pizzarr/issues |
| URL: | https://zarr.dev/pizzarr/ |
| Depends: | R (≥ 4.1.0) |
| Imports: | jsonlite, stats, R6, qs2, stringr, memoise, utils |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Suggests: | testthat, knitr, covr, bslib, pkgdown, rmarkdown, crul, blosc, vcr (≥ 0.6.0), pbapply, parallel, future, future.apply, bench, bit64, withr |
| Config/testthat/parallel: | false |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-03-20 15:09:07 UTC; dblodgett |
| Author: | David Blodgett |
| Maintainer: | David Blodgett <dblodgett@usgs.gov> |
| Repository: | CRAN |
| Date/Publication: | 2026-03-24 10:40:08 UTC |
Attributes Class
Description
Class providing access to user attributes on an array or group.
Format
Details
The Zarr Attributes class.
Public fields
storeAttributes store, already initialized.
keyThe key under which the attributes will be stored.
read_onlyIf True, attributes cannot be modified.
cacheIf True (default), attributes will be cached locally.
synchronizerOnly necessary if attributes may be modified from multiple threads or processes.
Methods
Public 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 (.zattrsis default).read_only(
logical(1))
Whether the attributes are read-only.cache(
logical(1))
Whether to cache attributes.synchronizer(
ANYorNA)
Synchronizer object.zarr_format(
integer(1)orNULL)
Zarr format version:2Lfor V2 (.zattrs),3Lfor 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
xObject to test.
Returns
logical(1).
Method get_item()
get attribute
Usage
Attributes$get_item(item)
Arguments
itemCharacter attribute name.
Returns
The attribute value.
Method set_item()
set attribute
Usage
Attributes$set_item(item, value)
Arguments
itemCharacter attribute name.
valueValue to add or update.
Returns
NULL (called for side effects).
Method del_item()
delete attribute
Usage
Attributes$del_item(item)
Arguments
itemCharacter 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_listA 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
deepWhether to make a deep clone.
BasicIndexer Class
Description
An indexer class to normalize a selection of an array and provide an iterator of indexes over the dimensions of an array.
Details
The Zarr BasicIndexer class.
Super class
pizzarr::Indexer -> BasicIndexer
Public fields
dim_indexersList of per-dimension indexers (IntDimIndexer or SliceDimIndexer).
Methods
Public methods
Method new()
Create a new BasicIndexer instance.
Usage
BasicIndexer$new(selection, array)
Arguments
selectionSelection as with ZarrArray: scalar, string, or Slice.
arrayZarrArray object that will be indexed.
Returns
A BasicIndexer instance.
Method iter()
An iterator over the dimensions of an array
Usage
BasicIndexer$iter()
Returns
A list of ChunkProjection objects
Method clone()
The objects of this class are cloneable with this method.
Usage
BasicIndexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
BloscCodec Class
Description
Class representing a Blosc compressor
Format
R6::R6Class inheriting from Codec.
Details
Blosc compressor for Zarr
Super class
pizzarr::Codec -> BloscCodec
Public fields
cname(
character(1))
The compression algorithm to use.clevel(
integer(1))
The compression level.shuffle(
logical(1)|integer(1))
The shuffle filter to use.blocksize(
integer(1)|NA)
The block size.
Methods
Public methods
Method new()
Create a new Blosc compressor.
Usage
BloscCodec$new(cname = "lz4", clevel = 5, shuffle = TRUE, blocksize = NA, ...)
Arguments
cname(
character(1))
The compression algorithm to use.clevel(
integer(1))
The compression level.shuffle(
logical(1)|integer(1))
The shuffle filter to use.blocksize(
integer(1)|NA)
The block size....Not used.
Returns
A new BloscCodec object.
Method encode()
Compress data.
Usage
BloscCodec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
BloscCodec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
BloscCodec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
BloscCodec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
BoolArrayDimIndexer Class
Description
Indexer for a boolean array selection along one dimension, selecting elements where the mask is TRUE.
Details
The Zarr BoolArrayDimIndexer class.
Super class
pizzarr::DimIndexer -> BoolArrayDimIndexer
Public fields
dim_selSelection on dimension.
dim_lenDimension length.
dim_chunk_lenDimension chunk length.
num_chunksNumber of chunks.
chunk_nitemsNumber of items per chunk.
chunk_nitems_cumsumOffsets into the output array.
dim_chunk_ixsChunks that should be visited.
dim_out_selOutput array indices for the selected elements.
Methods
Public methods
Method new()
Create a new BoolArrayDimIndexer instance.
Usage
BoolArrayDimIndexer$new(dim_sel, dim_len, dim_chunk_len)
Arguments
dim_selInteger dimension selection.
dim_lenInteger dimension length.
dim_chunk_lenInteger dimension chunk length.
Returns
A BoolArrayDimIndexer instance.
Method iter()
An iterator over the dimensions of an array
Usage
BoolArrayDimIndexer$iter()
Returns
A list of ChunkProjection objects
Method clone()
The objects of this class are cloneable with this method.
Usage
BoolArrayDimIndexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Bz2Codec Class
Description
Class representing a bz2 compressor
Format
R6::R6Class inheriting from Codec.
Details
Bz2 compressor for Zarr
Super class
pizzarr::Codec -> Bz2Codec
Public fields
levelThe compression level.
Methods
Public methods
Method new()
Create a new Bz2 compressor.
Usage
Bz2Codec$new(level = 6, ...)
Arguments
levelThe compression level, between 1 and 22.
...Not used.
Returns
A new Bz2Codec object.
Method encode()
Compress data.
Usage
Bz2Codec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
Bz2Codec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
Bz2Codec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
Bz2Codec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Chunk Dimension Projection
Description
A mapping from chunk to output array for a single dimension. Used internally to track which items within a single chunk dimension correspond to which items in the target output array.
Format
R6::R6Class object.
Public fields
dim_chunk_index(
integer(1))
Index of chunk.dim_chunk_sel(
integer()|list())
Selection of items from chunk array.dim_out_sel(
integer()|list())
Selection of items in target (output) array.
Methods
Public methods
Method new()
Creates a new instance of this R6 class.
Usage
ChunkDimProjection$new(dim_chunk_index, dim_chunk_sel, dim_out_sel)
Arguments
dim_chunk_index(
integer(1))
Index of chunk.dim_chunk_sel(
integer()|list())
Selection of items from chunk array.dim_out_sel(
integer()|list())
Selection of items in target (output) array.
Method clone()
The objects of this class are cloneable with this method.
Usage
ChunkDimProjection$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Indexing classes:
ChunkProjection,
DimIndexer,
Indexer
Chunk Projection
Description
A mapping of items from chunk to output array. Can be used to extract items from the chunk array for loading into an output array. Can also be used to extract items from a value array for setting/updating in a chunk array.
Format
R6::R6Class object.
Public fields
chunk_coords(
integer())
Indices of chunk.chunk_sel(
list())
Selection of items from chunk array.out_sel(
list())
Selection of items in target (output) array.
Methods
Public methods
Method new()
Creates a new instance of this R6 class.
Usage
ChunkProjection$new(chunk_coords, chunk_sel, out_sel)
Arguments
chunk_coords(
integer())
Indices of chunk.chunk_sel(
list())
Selection of items from chunk array.out_sel(
list())
Selection of items in target (output) array.
Method clone()
The objects of this class are cloneable with this method.
Usage
ChunkProjection$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Indexing classes:
ChunkDimProjection,
DimIndexer,
Indexer
Codec Class
Description
Abstract class representing a compressor.
Format
Details
Abstract compressor for Zarr
Methods
Public methods
Method encode()
Compress data.
Usage
Codec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
Codec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
Codec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
Codec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Bz2Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Dimension Indexer
Description
Abstract base class for per-dimension chunk indexers. A dimension indexer maps a selection on a single array dimension to a sequence of ChunkDimProjection objects. Concrete subclasses include IntDimIndexer, SliceDimIndexer, IntArrayDimIndexer, and BoolArrayDimIndexer.
Format
R6::R6Class object.
Public fields
num_items(
integer(1))
Number of items in the selection.
Methods
Public methods
Method iter()
Iterate over ChunkDimProjection objects for this dimension.
Usage
DimIndexer$iter()
Returns
list() of ChunkDimProjection objects.
Method clone()
The objects of this class are cloneable with this method.
Usage
DimIndexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Indexing classes:
ChunkDimProjection,
ChunkProjection,
Indexer
DirectoryStore Class
Description
Store class using directories and files on a standard file system.
Format
R6::R6Class inheriting from Store.
Details
DirectoryStore for Zarr
Super class
pizzarr::Store -> DirectoryStore
Public fields
rootThe path to the root of the store.
Methods
Public methods
Inherited methods
Method new()
Create a new file system store.
Usage
DirectoryStore$new(root)
Arguments
rootThe path to the root of the store.
Returns
A new DirectoryStore object.
Method get_item()
Get an item from the store.
Usage
DirectoryStore$get_item(key)
Arguments
keyThe item key.
Returns
The item data in a vector of type raw.
Method set_item()
Set an item in the store.
Usage
DirectoryStore$set_item(key, value)
Arguments
keyThe item key.
valueThe item value as a vector of type raw.
Returns
NULL (called for side effects).
Method contains_item()
Determine whether the store contains an item.
Usage
DirectoryStore$contains_item(key)
Arguments
keyThe item key.
Returns
A boolean value.
Method delete_item()
Delete an item from the store.
Usage
DirectoryStore$delete_item(key)
Arguments
keyThe item key.
Returns
NULL (called for side effects).
Method rmdir()
Remove a path within a Store.
Usage
DirectoryStore$rmdir(path = NA)
Arguments
pathCharacter path.
Returns
NULL (called for side effects).
Method listdir()
List the store directory.
Usage
DirectoryStore$listdir(key = NA)
Arguments
keyCharacter key.
Returns
character() vector of entries.
Method print()
Print a human-readable summary of the store.
Usage
DirectoryStore$print(...)
Arguments
...Ignored.
Returns
self (invisibly).
Method clone()
The objects of this class are cloneable with this method.
Usage
DirectoryStore$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Store classes:
HttpStore,
MemoryStore,
Store
Dtype Class
Description
A data type object (an instance of Dtype class) describes how the bytes in the fixed-size block of memory corresponding to an array item should be interpreted.
Format
Details
The Zarr Dtype class.
Public fields
dtypeThe original dtype string, like "<f4".
byte_orderThe byte order of the dtype, either "little", "big", or "nr".
basic_typeThe basic type of the dtype, like "f".
num_bytesThe number of bytes of the dtype.
num_itemsThe number of items of the dtype.
is_signedWhether the dtype is signed. Logical/boolean.
is_structuredWhether the dtype is structured. Logical/boolean.
is_objectWhether the dtype is an object. Logical/boolean.
object_codecThe object codec instance.
Methods
Public methods
Method new()
Create a new Dtype instance.
Usage
Dtype$new(dtype, object_codec = NA)
Arguments
dtypeThe original dtype string, like "<f4".
object_codecThe object codec instance.
Returns
A Dtype instance.
Method get_asrtype()
Get the R coercion function name for this dtype.
Usage
Dtype$get_asrtype()
Returns
Character string (e.g., "as.double").
Method get_rtype()
Get the R base type for this dtype.
Usage
Dtype$get_rtype()
Returns
An R prototype value (e.g., integer(), double(), or bit64::integer64()).
Method get_typed_array_ctr()
Get a constructor function for typed arrays of this dtype.
Usage
Dtype$get_typed_array_ctr()
Returns
A function that takes dim and returns an array.
Method clone()
The objects of this class are cloneable with this method.
Usage
Dtype$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
https://numpy.org/doc/stable/reference/arrays.dtypes.html
GzipCodec Class
Description
Class representing a gzip compressor.
Gzip encoding uses temporary files because R's memCompress() produces
zlib framing rather than gzip framing. This makes GzipCodec slower than
ZstdCodec for writes. Prefer ZstdCodec when performance matters.
Format
R6::R6Class inheriting from Codec.
Details
Gzip compressor for Zarr
Super class
pizzarr::Codec -> GzipCodec
Public fields
levelThe compression level.
Methods
Public methods
Method new()
Create a new Gzip compressor.
Usage
GzipCodec$new(level = 6, ...)
Arguments
levelThe compression level, between 1 and 22.
...Not used.
Returns
A new GzipCodec object.
Method encode()
Compress data.
Usage
GzipCodec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
GzipCodec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
GzipCodec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
GzipCodec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
HttpStore Class
Description
Store class that uses HTTP requests.
Read-only. Depends on the crul package.
Format
R6::R6Class inheriting from Store.
Details
For parallel operation, set the "pizzarr.parallel_backend" option to one of:
-
"future"if a future plan has been set up -
integerif you would like a one-time use cluster created per call -
clusterobject created withparallel::make_cluster()if you want to reuse a cluster
Set the option "pizzarr.progress_bar" to TRUE to get a progress bar for long running reads.
For more, see vignette("parallel").
Super class
pizzarr::Store -> HttpStore
Methods
Public methods
Inherited methods
Method new()
Create a HttpStore object
Usage
HttpStore$new(url, options = NA, headers = NA)
Arguments
url(
character(1))
URL of the store.options(
list()orNA)
Options passed to crul.headers(
list()orNA)
Headers passed to crul.
Returns
A new HttpStore object.
Method get_item()
Get an item from the store.
Usage
HttpStore$get_item(item)
Arguments
itemThe item key.
Returns
The item data in a vector of type raw.
Method contains_item()
Determine whether the store contains an item.
Usage
HttpStore$contains_item(item)
Arguments
itemThe item key.
Returns
A boolean value.
Method listdir()
Fetches .zmetadata from the store evaluates its names
Usage
HttpStore$listdir()
Returns
Character vector of unique keys that do not start with a ..
Method get_cache_time_seconds()
Get cache time of http requests.
Usage
HttpStore$get_cache_time_seconds()
Returns
numeric(1).
Method set_cache_time_seconds()
Set cache time of http requests.
Usage
HttpStore$set_cache_time_seconds(seconds)
Arguments
secondsNumber of seconds until cache is invalid – 0 for no cache.
Returns
NULL (called for side effects).
Method print()
Print a human-readable summary of the store.
Usage
HttpStore$print(...)
Arguments
...Ignored.
Returns
self (invisibly).
Method clone()
The objects of this class are cloneable with this method.
Usage
HttpStore$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Store classes:
DirectoryStore,
MemoryStore,
Store
Indexer
Description
Abstract base class for chunk indexers. An indexer maps a user-level array selection to a sequence of ChunkProjection objects, each describing which items to read or write within a single chunk. Concrete subclasses include BasicIndexer and OrthogonalIndexer.
Format
R6::R6Class object.
Public fields
shape(
integer())
Shape of the selection.drop_axes(
integer()|NULL)
Axes to drop from the result.
Methods
Public methods
Method iter()
Iterate over ChunkProjection objects for the selection.
Usage
Indexer$iter()
Returns
list() of ChunkProjection objects.
Method clone()
The objects of this class are cloneable with this method.
Usage
Indexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Indexing classes:
ChunkDimProjection,
ChunkProjection,
DimIndexer
IntArrayDimIndexer Class
Description
Indexer for an integer array selection along one dimension, supporting fancy/advanced indexing.
Details
The Zarr IntArrayDimIndexer class.
Super class
pizzarr::DimIndexer -> IntArrayDimIndexer
Public fields
dim_lenDimension length.
dim_chunk_lenDimension chunk length.
num_chunksNumber of chunks.
dim_selSelection on dimension.
dim_out_selOutput array indices corresponding to each selected element, reordered when selection is not increasing.
orderMemory order.
chunk_nitemsNumber of items per chunk.
dim_chunk_ixsChunks that should be visited.
chunk_nitems_cumsumOffsets into the output array.
Methods
Public methods
Method new()
Create a new IntArrayDimIndexer instance.
Usage
IntArrayDimIndexer$new( dim_sel, dim_len, dim_chunk_len, sel_order = Order$public_fields$UNKNOWN )
Arguments
dim_selInteger dimension selection.
dim_lenInteger dimension length.
dim_chunk_lenInteger dimension chunk length.
sel_orderorder
Returns
A IntArrayDimIndexer instance.
Method iter()
An iterator over the dimensions of an array
Usage
IntArrayDimIndexer$iter()
Returns
A list of ChunkProjection objects
Method clone()
The objects of this class are cloneable with this method.
Usage
IntArrayDimIndexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
IntDimIndexer Class
Description
Indexer for a single integer selection along one dimension.
Details
The Zarr IntDimIndexer class.
Super class
pizzarr::DimIndexer -> IntDimIndexer
Public fields
dim_selNormalized integer index for this dimension.
dim_lenLength of the array along this dimension.
dim_chunk_lenLength of a chunk along this dimension.
Methods
Public methods
Method new()
Create a new IntDimIndexer instance.
Usage
IntDimIndexer$new(dim_sel, dim_len, dim_chunk_len)
Arguments
dim_selInteger dimension selection.
dim_lenInteger dimension length.
dim_chunk_lenInteger dimension chunk length.
Returns
A IntDimIndexer instance.
Method iter()
Compute the chunk dimension projection for the single selected index.
Usage
IntDimIndexer$iter()
Returns
a ChunkDimProjection instance
Method clone()
The objects of this class are cloneable with this method.
Usage
IntDimIndexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Lz4Codec Class
Description
Class representing a LZ4 compressor
Format
R6::R6Class inheriting from Codec.
Details
LZ4 compressor for Zarr
Deprecation Notice
This codec is deprecated because the underlying qs package was archived on CRAN.
For LZ4 compression, use BloscCodec$new(cname = "lz4") instead.
This class will be removed in a future version.
Super class
pizzarr::Codec -> Lz4Codec
Public fields
accelerationThe compression level.
Methods
Public methods
Method new()
Create a new LZ4 compressor.
Usage
Lz4Codec$new(acceleration = 1, ...)
Arguments
accelerationThe compression level.
...Not used.
Returns
A new Lz4Codec object.
Method encode()
Compress data.
Usage
Lz4Codec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
Lz4Codec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
Lz4Codec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
Lz4Codec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
LzmaCodec Class
Description
Class representing a lzma compressor
Format
R6::R6Class inheriting from Codec.
Details
Lzma compressor for Zarr
Super class
pizzarr::Codec -> LzmaCodec
Public fields
levelThe compression level.
formatThe compression format.
Methods
Public methods
Method new()
Create a new lzma compressor.
Usage
LzmaCodec$new(level = 9, format = 1, ...)
Arguments
levelThe compression level, between 1 and 22.
format(
integer(1))
Only 1 is supported....Not used.
Returns
A new LzmaCodec object.
Method encode()
Compress data.
Usage
LzmaCodec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
LzmaCodec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
LzmaCodec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
LzmaCodec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
MemoryStore Class
Description
Store class that uses a hierarchy of list objects, thus all data will be held in main memory.
Format
R6::R6Class inheriting from Store.
Details
MemoryStore for Zarr
Super class
pizzarr::Store -> MemoryStore
Public fields
rootThe root list for the store.
Methods
Public methods
Inherited methods
Method new()
Create a new memory store.
Usage
MemoryStore$new()
Returns
A new MemoryStore object.
Method get_parent()
Get the parent of an item.
Usage
MemoryStore$get_parent(item)
Arguments
itemThe item key.
Returns
A list with the keys parent and key.
Method get_item()
Get an item from the store.
Usage
MemoryStore$get_item(item = NA)
Arguments
itemThe item key.
Returns
The item data in a vector of type raw.
Method set_item()
Set an item in the store.
Usage
MemoryStore$set_item(item, value)
Arguments
itemThe item key.
valueThe item value as a vector of type raw.
Returns
NULL (called for side effects).
Method contains_item()
Determine whether the store contains an item.
Usage
MemoryStore$contains_item(item)
Arguments
itemThe item key.
Returns
A boolean value.
Method listdir()
List the store directory.
Usage
MemoryStore$listdir(key = NA)
Arguments
keyCharacter key.
Returns
character() vector of entries.
Method delete_item()
Delete an item from the store.
Usage
MemoryStore$delete_item(key)
Arguments
keyThe item key.
Returns
NULL (called for side effects).
Method rmdir()
Remove a path within a Store.
Usage
MemoryStore$rmdir(item)
Arguments
itemCharacter item.
Returns
NULL (called for side effects).
Method print()
Print a human-readable summary of the store.
Usage
MemoryStore$print(...)
Arguments
...Ignored.
Returns
self (invisibly).
Method clone()
The objects of this class are cloneable with this method.
Usage
MemoryStore$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Store classes:
DirectoryStore,
HttpStore,
Store
Zarr V2 Metadata Codec
Description
Handles encoding and decoding of Zarr V2 metadata. Provides methods to parse raw JSON bytes into R lists and to serialize metadata back to JSON bytes, for both array and group nodes. Array metadata includes shape, chunks, dtype, compressor, fill_value, order, and filters. Group metadata contains only the zarr_format field.
Format
R6::R6Class object.
Methods
Public methods
Method decode_metadata()
Parse metadata from raw bytes or return as-is if already a list.
Usage
Metadata2$decode_metadata(s, auto_unbox = FALSE)
Arguments
s(
raw()|list()|NULL)
Raw JSON bytes, a pre-parsed list, orNULL.auto_unbox(
logical(1))
Passed tojsonlite::toJSON(). DefaultFALSE.
Returns
list() or NULL.
Method encode_metadata()
Encode metadata list to raw JSON bytes.
Usage
Metadata2$encode_metadata(meta, auto_unbox = FALSE)
Arguments
meta(
list())
Metadata to encode.auto_unbox(
logical(1))
Passed tojsonlite::toJSON(). DefaultFALSE.
Returns
raw().
Method decode_array_metadata()
Decode and validate V2 array metadata.
Usage
Metadata2$decode_array_metadata(s)
Arguments
s(
raw()|list()|NULL)
Raw JSON bytes or pre-parsed list.
Returns
list() or NULL.
Method decode_group_metadata()
Decode and validate V2 group metadata.
Usage
Metadata2$decode_group_metadata(s)
Arguments
s(
raw()|list()|NULL)
Raw JSON bytes or pre-parsed list.
Returns
list() or NULL.
Method encode_array_metadata()
Encode array metadata to raw JSON bytes, setting zarr_format to 2.
Usage
Metadata2$encode_array_metadata(meta)
Arguments
meta(
list())
Array metadata list.
Returns
raw().
Method encode_group_metadata()
Encode group metadata to raw JSON bytes, setting zarr_format to 2.
Usage
Metadata2$encode_group_metadata(meta = NA)
Arguments
meta(
list()|NA)
Ignored; a fresh group metadata list is created.
Returns
raw().
Method clone()
The objects of this class are cloneable with this method.
Usage
Metadata2$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Metadata classes:
Metadata3
Zarr V3 Metadata Codec
Description
Handles decoding of Zarr V3 metadata. In V3, each node has a single
zarr.json file containing zarr_format, node_type, and all
metadata (shape, data_type, codecs, chunk_grid, chunk_key_encoding,
fill_value, attributes, etc.). This class is read-only; no encode
methods are provided.
Format
R6::R6Class object.
Methods
Public methods
Method decode_metadata()
Parse metadata from raw bytes or return as-is if already a list.
Usage
Metadata3$decode_metadata(s)
Arguments
s(
raw()|list()|NULL)
Raw JSON bytes, a pre-parsed list, orNULL.
Returns
list() or NULL.
Method decode_array_metadata()
Decode and validate V3 array metadata from zarr.json.
V3 arrays have node_type = "array" and contain shape, data_type,
chunk_grid, chunk_key_encoding, codecs, fill_value, and attributes.
Usage
Metadata3$decode_array_metadata(s)
Arguments
s(
raw()|list()|NULL)
Raw JSON bytes or pre-parsed list.
Returns
list() or NULL.
Method decode_group_metadata()
Decode and validate V3 group metadata from zarr.json.
V3 groups have node_type = "group" and may contain attributes.
Usage
Metadata3$decode_group_metadata(s)
Arguments
s(
raw()|list()|NULL)
Raw JSON bytes or pre-parsed list.
Returns
list() or NULL.
Method encode_array_metadata()
Encode V3 array metadata to raw JSON bytes.
Expects a list built by create_v3_array_meta() with all scalars
already wrapped in jsonlite::unbox().
Usage
Metadata3$encode_array_metadata(meta)
Arguments
meta(
list())
V3 array metadata list.
Returns
raw().
Method encode_group_metadata()
Encode V3 group metadata to raw JSON bytes.
Produces {"zarr_format":3,"node_type":"group","attributes":{}}.
Usage
Metadata3$encode_group_metadata(meta = NA, attributes = NULL)
Arguments
meta(
list()|NA)
Ignored; a fresh group metadata list is created.attributes(
list())
Attributes to embed in zarr.json. Default empty.
Returns
raw().
Method clone()
The objects of this class are cloneable with this method.
Usage
Metadata3$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Metadata classes:
Metadata2
NestedArray Class
Description
Represents a multi-dimensional array that can be accessed and subsetted via list of Slice instances.
Format
Details
The Zarr NestedArray class.
Public fields
shapeThe shape of the array.
dtypeThe Zarr dtype of the array, as a string like ">f8".
dtype_objThe Zarr dtype of the array, as a Dtype instance.
dataThe array contents as a base R array.
Methods
Public methods
Method new()
Create a new NestedArray instance.
Usage
NestedArray$new(data, shape = NA, dtype = NA, order = NA)
Arguments
dataThe data to initialize the array with. Either NULL, base R array, base R vector (numeric/logical), scalar, or raw vector.
shapeThe shape of the array.
dtypeThe Zarr dtype of the array, as a string like ">f8".
orderThe order of the array, either "C" or "F". Only used when
datais a raw vector. Optional.
Returns
A NestedArray instance.
Method get()
Subset the array.
Usage
NestedArray$get(selection)
Arguments
selectionA list of slices.
Returns
A new NestedArray (potentially a subset) representing the selection.
Method set()
Set a subset of the array.
Usage
NestedArray$set(selection, value)
Arguments
selectionA list of slices.
valueA NestedArray or a base R array.
Returns
NULL (called for side effects, modifies self$data in place).
Method flatten()
Flatten the array contents.
Usage
NestedArray$flatten(order = NA)
Arguments
orderEither "C", "F", or NA.
Returns
The data as a flat vector.
Method flatten_to_raw()
Flatten the array contents and convert to a raw vector.
Usage
NestedArray$flatten_to_raw(order = NA)
Arguments
orderEither "C", "F", or NA.
Returns
The data as a flat raw() vector (or plain vector for object dtypes).
Method as.array()
Convert NestedArray to a base R array.
Usage
NestedArray$as.array()
Returns
array().
Method clone()
The objects of this class are cloneable with this method.
Usage
NestedArray$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
OIndex Class
Description
Orthogonal index class
Details
The Zarr OIndex class.
Public fields
arrayThe array instance.
Methods
Public methods
Method new()
Create a new OIndex instance.
Usage
OIndex$new(array)
Arguments
arrayThe array instance.
Returns
An OIndex instance.
Method get_item()
get method for the Oindex instance
Usage
OIndex$get_item(selection)
Arguments
selectionSelection to apply.
Returns
An OIndex instance.
Method clone()
The objects of this class are cloneable with this method.
Usage
OIndex$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Order Class
Description
Determines the sort order of an integer array selection (increasing, decreasing, or unordered).
Details
The Order class.
Public fields
UNKNOWNUNKNOWN
INCREASINGINCREASING
DECREASINGDECREASING
UNORDEREDUNORDERED
Methods
Public methods
Method check()
checking order of numbers
Usage
Order$check(a)
Arguments
aVector of numbers.
Method clone()
The objects of this class are cloneable with this method.
Usage
Order$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
OrthogonalIndexer Class
Description
An indexer class to normalize a selection of an array and provide an iterator of indexes over the dimensions of an array.
Details
The Zarr OrthogonalIndexer class.
Super class
pizzarr::Indexer -> OrthogonalIndexer
Public fields
dim_indexersList of per-dimension indexers (IntDimIndexer, SliceDimIndexer, IntArrayDimIndexer, or BoolArrayDimIndexer).
Methods
Public methods
Method new()
Create a new OrthogonalIndexer instance.
Usage
OrthogonalIndexer$new(selection, array)
Arguments
selectionSelection as with ZarrArray: scalar, string, or Slice.
arrayZarrArray object that will be indexed.
Returns
An OrthogonalIndexer instance.
Method iter()
An iterator over the dimensions of an array
Usage
OrthogonalIndexer$iter()
Returns
A list of ChunkProjection objects
Method clone()
The objects of this class are cloneable with this method.
Usage
OrthogonalIndexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
RawArray Class
Description
TODO: Add export annotation / remove keywords internal annotation once implemented.
Details
The Zarr RawArray class.
Methods
Public methods
Method new()
Create a new RawArray instance.
Usage
RawArray$new()
Returns
A RawArray instance.
Method clone()
The objects of this class are cloneable with this method.
Usage
RawArray$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
SliceDimIndexer Class
Description
Indexer for a slice selection along one dimension.
Details
The Zarr SliceDimIndexer class.
Super class
pizzarr::DimIndexer -> SliceDimIndexer
Public fields
dim_lenDimension length.
dim_chunk_lenDimension chunk length.
num_chunksNumber of chunks.
startStart index.
stopStop index.
stepStep size.
Methods
Public methods
Method new()
Create a new SliceDimIndexer instance.
Usage
SliceDimIndexer$new(dim_sel, dim_len, dim_chunk_len)
Arguments
dim_selInteger dimension selection.
dim_lenInteger dimension length.
dim_chunk_lenInteger dimension chunk length.
Returns
A SliceDimIndexer instance.
Method iter()
Iterate over chunks that overlap the slice, yielding a ChunkDimProjection for each.
Usage
SliceDimIndexer$iter()
Returns
A list of ChunkDimProjection objects.
Method clone()
The objects of this class are cloneable with this method.
Usage
SliceDimIndexer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Store Class
Description
Class representing an abstract store
Format
Details
Abstract store for Zarr
Public fields
metadata_classThe metadata encoder/decoder for this store.
Methods
Public methods
Method new()
Create a Store object
Usage
Store$new()
Method is_readable()
Test if Store is readable.
Usage
Store$is_readable()
Returns
Logical.
Method is_writeable()
Test if Store is writeable.
Usage
Store$is_writeable()
Returns
Logical.
Method is_erasable()
Test if Store is eraseable.
Usage
Store$is_erasable()
Returns
Logical.
Method is_listable()
Test if Store is listable.
Usage
Store$is_listable()
Returns
Logical.
Method close()
Close the store.
Usage
Store$close()
Returns
NULL.
Method listdir()
List the store directory.
Usage
Store$listdir(path = NA)
Arguments
pathcharacter path.
Returns
Character vector of keys.
Method rename()
Rename a Store path.
Usage
Store$rename(src_path, dst_path)
Arguments
src_pathcharacter source path.
dst_pathcharacter destination path.
Returns
NULL (called for side effects).
Method rmdir()
Remove a path within a Store.
Usage
Store$rmdir(path)
Arguments
pathcharacter path.
Returns
NULL (called for side effects).
Method get_item()
Get an item from the store.
Usage
Store$get_item(key)
Arguments
keyThe item key.
Returns
The item data in a vector of type raw.
Method set_item()
Set an item in the store.
Usage
Store$set_item(key, value)
Arguments
keyThe item key.
valueThe item value as a vector of type raw.
Returns
NULL (called for side effects).
Method contains_item()
Determine whether the store contains an item.
Usage
Store$contains_item(key)
Arguments
keyThe item key.
Returns
A boolean value.
Method delete_item()
Delete an item from the store.
Usage
Store$delete_item(key)
Arguments
keyThe item key.
Returns
NULL (called for side effects).
Method get_consolidated_metadata()
Get consolidated metadata if it exists.
Usage
Store$get_consolidated_metadata()
Returns
A list or NULL.
Method print()
Print a human-readable summary of the store.
Usage
Store$print(...)
Arguments
...Ignored.
Returns
self (invisibly).
Method clone()
The objects of this class are cloneable with this method.
Usage
Store$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Store classes:
DirectoryStore,
HttpStore,
MemoryStore
VIndex Class
Description
Vectorized index class
Details
The Zarr VIndex class.
Public fields
arrayThe array instance.
Methods
Public methods
Method new()
Create a new VIndex instance.
Usage
VIndex$new(array)
Arguments
arrayThe array instance.
Returns
A VIndex instance.
Method clone()
The objects of this class are cloneable with this method.
Usage
VIndex$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
VLenUtf8Codec Class
Description
Class representing a VLenUtf8 compressor
Format
R6::R6Class inheriting from Codec.
Details
Variable-length UTF-8 codec for Zarr
Super class
pizzarr::Codec -> VLenUtf8Codec
Methods
Public methods
Method encode()
Compress data.
Usage
VLenUtf8Codec$encode(buf, zarr_arr)
Arguments
buf(
character())
The un-compressed data (character vector).zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
VLenUtf8Codec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
VLenUtf8Codec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
VLenUtf8Codec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
ZlibCodec,
ZstdCodec
ZarrArray Class
Description
Instantiate an array from an initialized store.
Format
Details
The Zarr Array class.
Methods
Public methods
Method new()
Create a new ZarrArray instance.
Usage
ZarrArray$new( store, path = NA, read_only = FALSE, chunk_store = NA, synchronizer = NA, cache_metadata = TRUE, cache_attrs = TRUE, write_empty_chunks = TRUE )
Arguments
store(Store)
Array store, already initialized.path(
character(1))
Storage path.read_only(
logical(1))
Whether the array is read-only.chunk_store(Store or
NA)
Separate storage for chunks. If not provided,storewill be used for both chunks and metadata.synchronizer(
ANYorNA)
Object used to synchronize write access to the array.cache_metadata(
logical(1))
Whether to cache metadata.cache_attrs(
logical(1))
Whether to cache attributes.write_empty_chunks(
logical(1))
Whether to write empty chunks.
Returns
A ZarrArray instance.
Method get_store()
get store from array.
Usage
ZarrArray$get_store()
Returns
Method get_path()
get array path
Usage
ZarrArray$get_path()
Returns
character(1) or NA.
Method get_name()
get full array name
Usage
ZarrArray$get_name()
Returns
character(1) or NA.
Method get_basename()
get the basename of an array
Usage
ZarrArray$get_basename()
Returns
character(1) or NA.
Method get_read_only()
get the read only property of an array (TRUE/FALSE)
Usage
ZarrArray$get_read_only()
Returns
logical(1).
Method set_read_only()
set the read only property of an array
Usage
ZarrArray$set_read_only(val)
Arguments
val(
logical(1))
Value to set.
Returns
NULL (called for side effects).
Method get_chunk_store()
get the chunk store for an array
Usage
ZarrArray$get_chunk_store()
Returns
Method get_shape()
get the shape of an array
Usage
ZarrArray$get_shape()
Returns
integer().
Method set_shape()
set or reset the size of an array
Usage
ZarrArray$set_shape(value)
Arguments
value(
integer())
Numeric size to set.
Returns
NULL (called for side effects).
Method resize()
Change the shape of the array by growing or shrinking one or more dimensions.
Usage
ZarrArray$resize(...)
Arguments
...Arguments for do.call.
Returns
NULL (called for side effects).
Method get_chunks()
get the chunk metadata of an array
Usage
ZarrArray$get_chunks()
Returns
integer().
Method get_dtype()
get the Dtype of an array
Usage
ZarrArray$get_dtype()
Returns
Method get_compressor()
get the compressor of an array
Usage
ZarrArray$get_compressor()
Returns
Codec or NA.
Method get_fill_value()
get the fill value of an array
Usage
ZarrArray$get_fill_value()
Returns
Scalar fill value.
Method set_fill_value()
set the fill value of an array
Usage
ZarrArray$set_fill_value(val)
Arguments
valFill value to use.
Returns
NULL (called for side effects).
Method get_order()
get the storage order metadata of an array.
Usage
ZarrArray$get_order()
Returns
character(1), "C" or "F".
Method get_filters()
get the filters metadata of an array
Usage
ZarrArray$get_filters()
Returns
list() of Codec objects or NA.
Method get_synchronizer()
Get the synchronizer used to coordinate write access to the array.
Usage
ZarrArray$get_synchronizer()
Returns
Synchronizer object or NA.
Method get_attrs()
get attributes of array
Usage
ZarrArray$get_attrs()
Returns
Method get_ndim()
get number of dimensions of array
Usage
ZarrArray$get_ndim()
Returns
integer(1).
Method get_size()
Get the total number of elements in the array.
Usage
ZarrArray$get_size()
Returns
numeric(1).
Method get_itemsize()
Get the size in bytes of each item in the array.
Usage
ZarrArray$get_itemsize()
Returns
integer(1).
Method get_nbytes()
get number of bytes of an array
Usage
ZarrArray$get_nbytes()
Returns
numeric(1).
Method get_nbytes_stored()
Get the total number of stored bytes for the array, including metadata and compressed chunk data.
Usage
ZarrArray$get_nbytes_stored()
Returns
numeric(1).
Method get_cdata_shape()
Get the number of chunks along each dimension of the array.
Usage
ZarrArray$get_cdata_shape()
Returns
numeric().
Method get_nchunks()
Get the total number of chunks in the array.
Usage
ZarrArray$get_nchunks()
Returns
integer(1).
Method get_nchunks_initialized()
Get the number of chunks that have been initialized with data.
Usage
ZarrArray$get_nchunks_initialized()
Returns
integer(1).
Method get_is_view()
get is_view metadata of array
Usage
ZarrArray$get_is_view()
Returns
logical(1).
Method get_oindex()
get orthogonal index of array
Usage
ZarrArray$get_oindex()
Returns
Method get_vindex()
get vectorized index of array
Usage
ZarrArray$get_vindex()
Returns
Method get_write_empty_chunks()
get write empty chunks setting of array
Usage
ZarrArray$get_write_empty_chunks()
Returns
logical(1).
Method equals()
check if another object refers to the same array. does not check array data
Usage
ZarrArray$equals(other)
Arguments
otherOther object to check.
Returns
logical(1).
Method print()
Print a human-readable summary of the array.
Usage
ZarrArray$print(...)
Arguments
...Ignored.
Returns
self (invisibly).
Method islice()
Iterate over the array or a range of it, yielding successive slices along the first dimension. Uses chunk caching for efficient sequential access.
Usage
ZarrArray$islice(start = NA, end = NA)
Arguments
startStart index of the iteration range (1-based, inclusive).
endEnd index of the iteration range (1-based, inclusive).
Returns
list() of NestedArray slices.
Method length()
Return the length of the first dimension. Raises an error for zero-dimensional arrays.
Usage
ZarrArray$length()
Returns
integer(1).
Method get_item()
Subset the array.
Usage
ZarrArray$get_item(selection)
Arguments
selectionSelection specifying the subset to retrieve.
Returns
Method get_basic_selection()
Get a selection of an array based on a "basic" list of slices.
Usage
ZarrArray$get_basic_selection(selection = NA, out = NA, fields = NA)
Arguments
selectionSelection specifying the subset to retrieve.
outNot yet implemented.
fieldsNot yet implemented.
Returns
Method get_orthogonal_selection()
Retrieve data using orthogonal (outer) indexing.
Usage
ZarrArray$get_orthogonal_selection(selection = NA, out = NA, fields = NA)
Arguments
selectionSelection specifying the subset to retrieve.
outNot yet implemented.
fieldsNot yet implemented.
Returns
Method get_coordinate_selection()
Retrieve data using coordinate (point) indexing. Not yet implemented.
Usage
ZarrArray$get_coordinate_selection(selection = NA, out = NA, fields = NA)
Arguments
selectionSelection specifying the subset to retrieve.
outNot yet implemented.
fieldsNot yet implemented.
Returns
Method get_mask_selection()
Retrieve data using a boolean mask. Not yet implemented.
Usage
ZarrArray$get_mask_selection(selection = NA, out = NA, fields = NA)
Arguments
selectionSelection specifying the subset to retrieve.
outNot yet implemented.
fieldsNot yet implemented.
Returns
Method set_item()
Set a subset of the array.
Usage
ZarrArray$set_item(selection, value)
Arguments
selectionSelection specifying the subset to set.
valueThe value to set, as an R array() or a Zarr NestedArray instance.
Returns
NULL (called for side effects).
Method set_basic_selection()
Set a selection of the array using basic (integer/slice) indexing.
Usage
ZarrArray$set_basic_selection(selection, value, fields = NA)
Arguments
selectionSelection specifying the subset to set.
valueThe value to set.
fieldsNot yet implemented.
Returns
NULL (called for side effects).
Method set_orthogonal_selection()
Set data using orthogonal (outer) indexing. Not yet implemented.
Usage
ZarrArray$set_orthogonal_selection(selection, value, fields = NA)
Arguments
selectionSelection specifying the subset to set.
valueNot yet implemented.
fieldsNot yet implemented.
Returns
NULL (called for side effects).
Method set_coordinate_selection()
Set data using coordinate (point) indexing. Not yet implemented.
Usage
ZarrArray$set_coordinate_selection(selection, value, fields = NA)
Arguments
selectionSelection specifying the subset to set.
valueNot yet implemented.
fieldsNot yet implemented.
Returns
NULL (called for side effects).
Method set_mask_selection()
Set data using a boolean mask. Not yet implemented.
Usage
ZarrArray$set_mask_selection(selection, value, fields = NA)
Arguments
selectionSelection specifying the subset to set.
valueNot yet implemented.
fieldsNot yet implemented.
Returns
NULL (called for side effects).
Method get_info()
Get array diagnostic info. Not yet implemented.
Usage
ZarrArray$get_info()
Returns
character(1).
Method get_digest()
Compute a checksum digest of the array data. Not yet implemented.
Usage
ZarrArray$get_digest(hashname = "sha1")
Arguments
hashnameName of hash.
Returns
character(1).
Method get_hexdigest()
Compute a hex-string checksum digest. Not yet implemented.
Usage
ZarrArray$get_hexdigest(hashname = "sha1")
Arguments
hashnameName of hash.
Returns
character(1).
Method append()
Append data to the array along the specified axis.
Usage
ZarrArray$append(data, axis = 1)
Arguments
dataData to append. Will be coerced to array if needed.
axisAxis to append along (1-indexed, R convention). Default 1.
Returns
NULL (called for side effects).
Method view()
Return a view on the array with modified interpretation. Not yet implemented.
Usage
ZarrArray$view( shape = NA, chunks = NA, dtype = NA, fill_value = NA, filters = NA, read_only = NA, synchronizer = NA )
Arguments
shapeNot yet implemented.
chunksNot yet implemented.
dtypeNot yet implemented.
fill_valueNot yet implemented.
filtersNot yet implemented.
read_onlyNot yet implemented.
synchronizerNot yet implemented.
Returns
Method astype()
Return a view with a different dtype. Not yet implemented.
Usage
ZarrArray$astype(dtype)
Arguments
dtypeNot yet implemented.
Returns
Method get_dimension_separator()
Get the dimension separator used in chunk keys.
Usage
ZarrArray$get_dimension_separator()
Returns
character(1).
Method as.array()
Convert Zarr object to R array (for S3 method). Note that this loads all data into memory.
Usage
ZarrArray$as.array()
Returns
An R array.
Method clone()
The objects of this class are cloneable with this method.
Usage
ZarrArray$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
ZarrGroup Class
Description
Instantiate a group from an initialized store.
Format
Details
The Zarr Group class.
Methods
Public methods
Method new()
Create a new ZarrGroup instance.
Usage
ZarrGroup$new( store, path = NA, read_only = FALSE, chunk_store = NA, cache_attrs = TRUE, synchronizer = NA )
Arguments
store(Store)
Group store, already initialized.path(
character(1))
Storage path.read_only(
logical(1))
Whether the group is read-only.chunk_store(Store or
NA)
Separate storage for chunks.cache_attrs(
logical(1))
Whether to cache attributes.synchronizer(
ANYorNA)
Object used to synchronize write access.
Returns
A ZarrGroup instance.
Method get_store()
Get group store
Usage
ZarrGroup$get_store()
Returns
Method get_path()
Get group path
Usage
ZarrGroup$get_path()
Returns
character(1).
Method get_meta()
Get group metadata
Usage
ZarrGroup$get_meta()
Returns
list() or NULL.
Method get_name()
Get group name
Usage
ZarrGroup$get_name()
Returns
character(1).
Method get_read_only()
Is store read only?
Usage
ZarrGroup$get_read_only()
Returns
logical(1).
Method get_chunk_store()
Get group chunk store
Usage
ZarrGroup$get_chunk_store()
Returns
Method get_synchronizer()
Get group synchronizer
Usage
ZarrGroup$get_synchronizer()
Returns
Synchronizer object or NA.
Method get_attrs()
Get group attributes
Usage
ZarrGroup$get_attrs()
Returns
Method contains_item()
Test for group membership.
Usage
ZarrGroup$contains_item(item)
Arguments
itemCharacter item to test for.
Returns
logical(1).
Method get_item()
Obtain a group member.
Usage
ZarrGroup$get_item(item)
Arguments
itemCharacter item to retrieve.
Returns
Method create_group()
create a group
Usage
ZarrGroup$create_group(name, overwrite = FALSE)
Arguments
nameCharacter group name.
overwriteLogical overwrite.
Returns
Method create_dataset()
Create a dataset (array) within this group.
Usage
ZarrGroup$create_dataset(name, data = NA, ...)
Arguments
nameCharacter dataset name.
dataData to add to group.
...Extra arguments to pass to
zarr_create()orarray().
Returns
Method print()
Print a human-readable summary of the group.
Usage
ZarrGroup$print(...)
Arguments
...Ignored.
Returns
self (invisibly).
Method tree()
Print an ASCII tree showing the group hierarchy.
Usage
ZarrGroup$tree(level = NA)
Arguments
levelMaximum depth to display.
NA(default) shows all levels.
Returns
self (invisibly).
Method clone()
The objects of this class are cloneable with this method.
Usage
ZarrGroup$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
ZlibCodec Class
Description
Class representing a zlib compressor
Format
R6::R6Class inheriting from Codec.
Details
Zlib compressor for Zarr
Super class
pizzarr::Codec -> ZlibCodec
Public fields
levelThe compression level.
Methods
Public methods
Method new()
Create a new Zlib compressor.
Usage
ZlibCodec$new(level = 6, ...)
Arguments
levelThe compression level, between 1 and 22.
...Not used.
Returns
A new ZlibCodec object.
Method encode()
Compress data.
Usage
ZlibCodec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
ZlibCodec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
ZlibCodec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
ZlibCodec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZstdCodec
ZstdCodec Class
Description
Class representing a ZSTD compressor
Format
R6::R6Class inheriting from Codec.
Details
ZSTD compressor for Zarr
Super class
pizzarr::Codec -> ZstdCodec
Public fields
levelThe compression level.
Methods
Public methods
Method new()
Create a new ZSTD compressor.
Usage
ZstdCodec$new(level = 1, ...)
Arguments
levelThe compression level, between 1 and 22.
...Not used.
Returns
A new ZstdCodec object.
Method encode()
Compress data.
Usage
ZstdCodec$encode(buf, zarr_arr)
Arguments
buf(
raw())
The un-compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Compressed data.
Method decode()
Decompress data.
Usage
ZstdCodec$decode(buf, zarr_arr)
Arguments
buf(
raw())
The compressed data.zarr_arr(ZarrArray)
The ZarrArray instance.
Returns
Un-compressed data.
Method get_config()
Get codec configuration as a list.
Usage
ZstdCodec$get_config()
Returns
A named list.
Method clone()
The objects of this class are cloneable with this method.
Usage
ZstdCodec$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec
S3 method for custom bracket assignment
Description
S3 method for custom bracket assignment
Usage
## S3 replacement method for class 'ZarrArray'
obj[...] <- value
Arguments
obj |
Object. |
... |
Dots. |
value |
Array or ZarrArray. |
S3 method for custom bracket subsetting
Description
S3 method for custom bracket subsetting
Usage
## S3 method for class 'ZarrArray'
obj[...]
Arguments
obj |
Object. |
... |
Dots. |
S3 method for as.array
Description
S3 method for as.array
Usage
## S3 method for class 'NestedArray'
as.array(x, ...)
Arguments
x |
Object. |
... |
Not used. |
S3 method for as.array
Description
S3 method for as.array
Usage
## S3 method for class 'ZarrArray'
as.array(x, ...)
Arguments
x |
Object. |
... |
Not used. |
Convert a value to a scalar to opt-out of R default vector casting behavior.
This uses the jsonlite::unbox function to "tag" the value as a scalar.
Description
Convert a value to a scalar to opt-out of R default vector casting behavior.
This uses the jsonlite::unbox function to "tag" the value as a scalar.
Usage
as_scalar(obj)
Arguments
obj |
The value to convert. |
Value
The value wrapped as a scalar.
Fill in an R array with a single scalar value.
Description
Fill in an R array with a single scalar value.
Usage
chunk_fill(chunk, value)
Arguments
chunk |
The R array to fill. |
value |
The scalar value (after is_scalar() check). |
Compute Size
Description
Compute Size
Usage
compute_size(shape)
Arguments
shape |
A shape vector |
Value
The product of shape elements.
Create a V3 array metadata list. Parallel to create_zarray_meta() for V2. Builds the zarr.json metadata for a V3 array node. All scalar values are wrapped with jsonlite::unbox() so the result can be encoded with toJSON(auto_unbox = FALSE).
Description
Create a V3 array metadata list. Parallel to create_zarray_meta() for V2. Builds the zarr.json metadata for a V3 array node. All scalar values are wrapped with jsonlite::unbox() so the result can be encoded with toJSON(auto_unbox = FALSE).
Usage
create_v3_array_meta(
shape,
chunks,
dtype,
compressor,
fill_value,
order,
filters,
chunk_key_encoding = NULL,
attributes = NULL,
dimension_names = NULL
)
Arguments
shape |
Integer vector. Array shape. |
chunks |
Integer vector. Chunk shape. |
dtype |
Character. V2-style dtype string (e.g., "<f8", "|b1"). |
compressor |
Codec object or NA. |
fill_value |
Fill value (numeric, logical, or NA). |
order |
Character. "C" or "F" (unused in V3 codec pipeline but stored). |
filters |
List of Codec objects or NA. |
chunk_key_encoding |
List or NULL. If NULL, defaults to default "/" encoding. |
attributes |
List or NULL. Embedded attributes. Default empty. |
dimension_names |
Character vector or NULL. Omitted from zarr.json if NULL. |
Value
A list ready for jsonlite::toJSON encoding.
Create a list of zarray metadata.
Description
Create a list of zarray metadata.
Usage
create_zarray_meta(
shape = NA,
chunks = NA,
dtype = NA,
compressor = NA,
fill_value = NA,
order = NA,
filters = NA,
dimension_separator = NA
)
Arguments
shape |
: int or tuple of ints Array shape. |
chunks |
: int or tuple of ints, optional
Chunk shape. If True, will be guessed from |
dtype |
: string or dtype, optional NumPy dtype. |
compressor |
: Codec, optional Primary compressor. |
fill_value |
: object Default value to use for uninitialized portions of the array. |
order |
: |
filters |
: sequence, optional Sequence of filters to use to encode chunk data prior to compression. |
dimension_separator |
: |
Value
A list.
Encode a fill_value for V3 zarr.json. V3 requires special float values as JSON strings: NaN, Infinity, -Infinity. Normal numeric values are returned as unboxed scalars.
Description
Encode a fill_value for V3 zarr.json. V3 requires special float values as JSON strings: NaN, Infinity, -Infinity. Normal numeric values are returned as unboxed scalars.
Usage
decode_fill_value_v3(fill_value)
Arguments
fill_value |
The fill value to encode. |
Value
A value suitable for inclusion in a jsonlite::toJSON call.
Ensure that scalars and lists of integers are converted to an R vector of integers.
Description
Ensure that scalars and lists of integers are converted to an R vector of integers.
Usage
ensure_integer_vec(selection)
Ensure that scalars, single slices, and R integer vectors are converted to a list containing either R integer vectors or slice instances as values.
Description
Ensure that scalars, single slices, and R integer vectors are converted to a list containing either R integer vectors or slice instances as values.
Usage
ensure_list(selection)
Get a codec instance from the registry.
Description
Get a codec instance from the registry.
Usage
get_codec(config)
Arguments
config |
A codec config as a named list. |
Value
The instance of the codec.
Get the default compressor.
Description
Get the default compressor.
Usage
get_default_compressor()
Value
A Zstd compressor instance.
Generate a product of lists.
Description
Generate a product of lists.
Usage
get_list_product(dim_indexer_iterables)
Arguments
dim_indexer_iterables |
A list of lists. |
Value
A list of lists.
get parallel settings
Description
given information about user preferences and environment conditions, returns a function and cluster object.
Usage
get_parallel_settings(
on_windows = (.Platform$OS.type == "windows"),
parallel_option = getOption("pizzarr.parallel_backend", NA),
progress = getOption("pizzarr.progress_bar", FALSE)
)
Arguments
on_windows |
Logical indicating if windows restrictions should apply. |
parallel_option |
Integer, or "future" to control how parallelization occurs. |
progress |
Logical to control whether |
Value
list containing the function to use in parallel operations, a cluster object to be used in parallel operations, and whether or not the cluster object needs to be closed.
Check if the bit64 package is available
Description
Check if the bit64 package is available
Usage
has_bit64()
Value
Logical.
Initialize an array store with the given configuration. Note that this is a low-level function and there should be no need to call this directly from user code.
Description
Initialize an array store with the given configuration. Note that this is a low-level function and there should be no need to call this directly from user code.
Usage
init_array(
store,
shape,
chunks = TRUE,
dtype = NA,
compressor = NA,
fill_value = NA,
order = NA,
overwrite = FALSE,
path = NA,
chunk_store = NA,
filters = NA,
object_codec = NA,
dimension_separator = NA,
zarr_format = 2L
)
Arguments
store |
: Store A mapping that supports string keys and bytes-like values. |
shape |
: int or tuple of ints Array shape. |
chunks |
: bool, int or tuple of ints, optional
Chunk shape. If True, will be guessed from |
dtype |
: string or dtype, optional NumPy dtype. |
compressor |
: Codec, optional Primary compressor. |
fill_value |
: object Default value to use for uninitialized portions of the array. |
order |
: |
overwrite |
: bool, optional
If True, erase all data in |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
filters |
: sequence, optional Sequence of filters to use to encode chunk data prior to compression. |
object_codec |
: Codec, optional A codec to encode object arrays, only needed if dtype=object. |
dimension_separator |
: |
Initialize a group store. Note that this is a low-level function and there should be no need to call this directly from user code.
Description
Initialize a group store. Note that this is a low-level function and there should be no need to call this directly from user code.
Usage
init_group(
store,
overwrite = FALSE,
path = NA,
chunk_store = NA,
zarr_format = 2L
)
Arguments
store |
: Store A mapping that supports string keys and bytes-like values. |
overwrite |
: bool, optional
If True, erase all data in |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
Convenience function for the internal Int class constructor.
Description
Convenience function for the internal Int class constructor.
Usage
int(index, zero_based = FALSE)
Arguments
index |
The integer index. |
zero_based |
The index of the dimension. By default, FALSE for R-like behavior. |
Value
A Int instance with the specified parameters.
Convert integer64 vector to raw bytes
Description
Convert integer64 vector to raw bytes
Usage
integer64_to_raw(x, endian = "little")
Arguments
x |
A bit64::integer64 vector. |
endian |
"little" or "big". |
Value
A raw vector.
Check that a value is boolean with length 1
Description
Check that a value is boolean with length 1
Usage
is_bool(s)
Check that a value is a list of one or more boolean
Description
Check that a value is a list of one or more boolean
Usage
is_bool_list(s)
Check that a value is a vector of one or more boolean
Description
Check that a value is a vector of one or more boolean
Usage
is_bool_vec(s)
Check if a dtype represents a 64-bit integer type
Description
Check if a dtype represents a 64-bit integer type
Usage
is_int64_dtype(dtype_obj)
Arguments
dtype_obj |
A Dtype instance. |
Value
Logical.
Check if a value is an integer R vector or scalar.
Description
Check if a value is an integer R vector or scalar.
Usage
is_integer(s)
Check that a value is a list of one or more integers.
Description
Check that a value is a list of one or more integers.
Usage
is_integer_list(s)
Check if a value is both a scalar (tagged by as_scalar) and an integer.
Description
Check if a value is both a scalar (tagged by as_scalar) and an integer.
Usage
is_integer_scalar(s)
Check that a value is a vector of one or more integers and has not been explicitly tagged as a scalar.
Description
Check that a value is a vector of one or more integers and has not been explicitly tagged as a scalar.
Usage
is_integer_vec(s)
Check if an error is a KeyError.
Description
Check if an error is a KeyError.
Usage
is_key_error(e)
Arguments
e |
The error to check. |
Value
TRUE if the error is a KeyError, FALSE otherwise.
Check if a value, potentially a vector, is NA
Description
Check if a value, potentially a vector, is NA
Usage
is_na(val)
Arguments
val |
The value to check |
Value
Whether the value is NA
Check if a value is a scalar (i.e., a one-element vector that was converted with as_scalar).
Description
Check if a value is a scalar (i.e., a one-element vector that was converted with as_scalar).
Usage
is_scalar(s)
Arguments
s |
The value to check. |
Value
TRUE if the value is a scalar, FALSE otherwise.
Check if a value is a Slice instance.
Description
Check if a value is a Slice instance.
Usage
is_slice(s)
Arguments
s |
The value to check. |
Value
TRUE if the value is a Slice instance, FALSE otherwise.
Create an empty named list
Description
A helper function to construct an empty list which converts to a JSON object rather than a JSON array.
Usage
obj_list(...)
Arguments
... |
A variable number of list entries. |
Value
A named list.
Examples
default_window <- obj_list(
min = 0,
max = 255
)
pizzarr_option_defaults
Description
pizzarr.http_store_cache_time_seconds how long to cache web requests
pizzarr.parallel_backend "future", a cluster object, or an integer (if not on windows)
pizzarr.parallel_write_enabled logical, whether to use parallel backend for writing
pizzarr.progress_bar logical whether to use
pbapplyto emit a progress bar
Usage
pizzarr_option_defaults
Format
An object of class list of length 4.
pizzarr demo data
Description
pizzarr demo data
Usage
pizzarr_sample(
dataset = NULL,
outdir = file.path(tools::R_user_dir("pizzarr"), "pizzarr_sample")
)
Arguments
dataset |
character defining which demo dataset is desired, If NULL, all are returned |
outdir |
character directory path to store sample zarr stores |
Details
For directory stores, unzips the store to a temporary directory and returns the resulting path.
Value
path to ready to use zarr store
Examples
sample_dir <- tools::R_user_dir("pizzarr")
clean <- !dir.exists(sample_dir)
zarr_samples <- pizzarr_sample(outdir = sample_dir)
#printing without system path for example
gsub(sample_dir, "...", zarr_samples, fixed = TRUE)
# clean up if you don't want to keep them for next time
if(clean) unlink(sample_dir, recursive = TRUE)
Convert raw bytes to double from int64 (fallback when bit64 unavailable)
Description
Convert raw bytes to double from int64 (fallback when bit64 unavailable)
Usage
raw_to_double_from_int64(buf, n, endian = "little", signed = TRUE)
Arguments
buf |
Raw vector of 8-byte integers. |
n |
Number of elements to read. |
endian |
"little" or "big". |
signed |
Logical; if TRUE, treat as signed int64. |
Value
A double vector (precision loss possible for values > 2^53).
Convert raw bytes to integer64 vector
Description
Convert raw bytes to integer64 vector
Usage
raw_to_integer64(buf, n, endian = "little")
Arguments
buf |
Raw vector of 8-byte little-endian integers. |
n |
Number of elements to read. |
endian |
"little" or "big". |
Value
A bit64::integer64 vector.
Convert user selections, potentially containing "...", to a list of slices that can be used internally.
Description
Convert user selections, potentially containing "...", to a list of slices that can be used internally.
Usage
replace_ellipsis(selection, shape)
Arguments
selection |
The user-provided selection list. |
shape |
The shape of the array, to be used to fill in ellipsis values. |
Value
A list of selections with ellipsis values converted to NA.
Convenience function for the internal Slice R6 class constructor.
Description
Convenience function for the internal Slice R6 class constructor.
Usage
slice(start, stop = NA, step = NA, zero_based = FALSE)
Arguments
start |
The start index. |
stop |
The stop index. |
step |
The step size. Negative values reverse the direction of the
slice, matching Python/NumPy semantics (e.g., |
zero_based |
The index of the dimension. By default, FALSE for R-like behavior. |
Value
A Slice instance with the specified parameters.
Examples
g <- zarr_volcano()
v <- g$get_item("volcano")
# Reverse the first 5 columns of row 1 (zero-based: 5:0:-1)
v$get_orthogonal_selection(list(zb_slice(0, 1), zb_slice(5, 0, -1)))
# Full reverse of row 1 (zero-based: -1::-1)
v$get_orthogonal_selection(list(zb_slice(0, 1), zb_slice(-1, NA, -1)))
Convert a string into a character vector.
Description
Convert a string into a character vector.
Usage
str_to_vec(s)
Arguments
s |
The string. |
Value
A vector where each element is an individual character.
Create an empty array
Description
Create an empty array
Usage
zarr_create(
shape,
chunks = TRUE,
dtype = NA,
compressor = NA,
fill_value = NA,
order = NA,
store = NA,
synchronizer = NA,
overwrite = FALSE,
path = NA,
chunk_store = NA,
filters = NA,
cache_metadata = TRUE,
cache_attrs = TRUE,
read_only = FALSE,
object_codec = NA,
dimension_separator = NA,
write_empty_chunks = TRUE,
zarr_format = 2L
)
Arguments
shape |
: int or tuple of ints Array shape. |
chunks |
: int or tuple of ints, optional
Chunk shape. If True, will be guessed from |
dtype |
: string or dtype, optional NumPy dtype. |
compressor |
: Codec, optional Primary compressor. |
fill_value |
: object Default value to use for uninitialized portions of the array. |
order |
: |
store |
: Store A mapping that supports string keys and bytes-like values. |
synchronizer |
: object, optional Array synchronizer. |
overwrite |
: bool, optional
If True, erase all data in |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
filters |
: sequence, optional Sequence of filters to use to encode chunk data prior to compression. |
cache_metadata |
: bool, optional If True, array configuration metadata will be cached for the lifetime of the object. If False, array metadata will be reloaded prior to all data access and modification operations (may incur overhead depending on storage and data access pattern). |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
read_only |
: bool, optional True if array should be protected against modification. |
object_codec |
: Codec, optional A codec to encode object arrays, only needed if dtype=object. |
dimension_separator |
: |
write_empty_chunks |
: bool, optional If True (default), all chunks will be stored regardless of their contents. If False, each chunk is compared to the array's fill value prior to storing. If a chunk is uniformly equal to the fill value, then that chunk is not be stored, and the store entry for that chunk's key is deleted. This setting enables sparser storage, as only chunks with non-fill-value data are stored, at the expense of overhead associated with checking the data of each chunk. |
zarr_format |
: int, optional
Zarr format version. Use |
Value
ZarrArray
Create an array initialized with data.
Description
Create an array initialized with data.
Usage
zarr_create_array(data, ...)
Arguments
data |
A base R array() or pizzarr NestedArray instance. |
... |
The params of zarr_create() |
Value
ZarrArray
Create an array filled with NAs.
Description
Create an array filled with NAs.
Usage
zarr_create_empty(shape, ...)
Arguments
shape |
: int or tuple of ints Array shape. |
... |
The params of zarr_create() |
Value
ZarrArray
Create a group.
Description
Create a group.
Usage
zarr_create_group(
store = NA,
overwrite = FALSE,
chunk_store = NA,
cache_attrs = TRUE,
synchronizer = NA,
path = NA,
zarr_format = 2L
)
Arguments
store |
: Store A mapping that supports string keys and bytes-like values. |
overwrite |
: bool, optional
If True, erase all data in |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
synchronizer |
: object, optional Array synchronizer. |
path |
: string, bytes, optional Path under which array is stored. |
zarr_format |
: int, optional
Zarr format version. Use |
Value
ZarrGroup
Create an array filled with zeros.
Description
Create an array filled with zeros.
Usage
zarr_create_zeros(shape, ...)
Arguments
shape |
: int or tuple of ints Array shape. |
... |
The params of zarr_create() |
Value
ZarrArray
Convenience function to open a group or array using file-mode-like semantics.
Description
Convenience function to open a group or array using file-mode-like semantics.
Usage
zarr_open(store = NA, mode = NA, path = NA, ...)
Arguments
store |
: Store A mapping that supports string keys and bytes-like values. |
mode |
: |
path |
: string, bytes, optional Path under which array is stored. |
... |
Additional arguments to pass to zarr_open_array or zarr_open_group. |
Value
ZarrArray or ZarrGroup
Open an array using file-mode-like semantics.
Description
Open an array using file-mode-like semantics.
Usage
zarr_open_array(
store = NA,
storage_options = NA,
mode = NA,
shape = NA,
chunks = TRUE,
dtype = NA,
compressor = NA,
fill_value = NA,
order = NA,
synchronizer = NA,
overwrite = FALSE,
path = NA,
chunk_store = NA,
filters = NA,
cache_metadata = TRUE,
cache_attrs = TRUE,
object_codec = NA,
dimension_separator = NA,
write_empty_chunks = TRUE,
zarr_format = 2L
)
Arguments
store |
: Store A mapping that supports string keys and bytes-like values. |
storage_options |
: dict If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise. |
mode |
: |
shape |
: int or tuple of ints Array shape. |
chunks |
: bool, int or tuple of ints, optional
Chunk shape. If True, will be guessed from |
dtype |
: string or dtype, optional NumPy dtype. |
compressor |
: Codec, optional Primary compressor. |
fill_value |
: object Default value to use for uninitialized portions of the array. |
order |
: |
synchronizer |
: object, optional Array synchronizer. |
overwrite |
: bool, optional
If True, erase all data in |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
filters |
: sequence, optional Sequence of filters to use to encode chunk data prior to compression. |
cache_metadata |
: bool, optional If True, array configuration metadata will be cached for the lifetime of the object. If False, array metadata will be reloaded prior to all data access and modification operations (may incur overhead depending on storage and data access pattern). |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
object_codec |
: Codec, optional A codec to encode object arrays, only needed if dtype=object. |
dimension_separator |
: |
write_empty_chunks |
: bool, optional If True (default), all chunks will be stored regardless of their contents. If False, each chunk is compared to the array's fill value prior to storing. If a chunk is uniformly equal to the fill value, then that chunk is not be stored, and the store entry for that chunk's key is deleted. This setting enables sparser storage, as only chunks with non-fill-value data are stored, at the expense of overhead associated with checking the data of each chunk. |
zarr_format |
: int, optional
Zarr format version. Use |
Value
ZarrArray
Open a group using file-mode-like semantics.
Description
Open a group using file-mode-like semantics.
Usage
zarr_open_group(
store = NA,
mode = NA,
cache_attrs = TRUE,
synchronizer = NA,
path = NA,
chunk_store = NA,
storage_options = NA,
zarr_format = 2L
)
Arguments
store |
: Store A mapping that supports string keys and bytes-like values. |
mode |
: |
cache_attrs |
: bool, optional If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations. |
synchronizer |
: object, optional Array synchronizer. |
path |
: string, bytes, optional Path under which array is stored. |
chunk_store |
: Store, optional
Separate storage for chunks. If not provided, |
storage_options |
: dict If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise. |
zarr_format |
: int, optional
Zarr format version. Use |
Value
ZarrGroup
Convenience function to save a ZarrArray to the local file system.
Description
Convenience function to save a ZarrArray to the local file system.
Usage
zarr_save_array(store, arr, ...)
Arguments
store |
: Store A mapping that supports string keys and bytes-like values. |
arr |
: ZarrArray The array with data to save. |
... |
Additional arguments to pass to zarr_create_array(). |
Create a demo Zarr group containing R's volcano dataset
Description
Writes the volcano matrix into a temporary
DirectoryStore as a Zarr array named "volcano" and returns the
opened group.
Usage
zarr_volcano()
Value
A ZarrGroup containing a single array called "volcano".
Examples
g <- zarr_volcano()
v <- g$get_item("volcano")
image(v$get_item("...")$data, main = "Maunga Whau Volcano")
Convenience function for the internal Int class constructor with zero-based indexing
Description
Convenience function for the internal Int class constructor with zero-based indexing
Usage
zb_int(index)
Arguments
index |
integer index |
Convenience function for the internal Slice R6 class constructor with zero-based indexing and exclusive stop index.
Description
Convenience function for the internal Slice R6 class constructor with zero-based indexing and exclusive stop index.
Usage
zb_slice(start, stop = NA, step = NA)
Arguments
start |
The start index. |
stop |
The stop index. |
step |
The step size. Negative values reverse the direction of the
slice, matching Python/NumPy semantics (e.g., |
Value
A Slice instance with the specified parameters.
Examples
# Equivalent to Python's arr[5:0:-1]
zb_slice(5, 0, -1)
# Equivalent to Python's arr[-1::-1] (full reverse)
zb_slice(-1, NA, -1)