| Title: | Slice into 'Zarr' Arrays |
|---|---|
| Description: | An implementation of chunked, compressed, N-dimensional arrays for R. 'Zarr' spec V2 (2024) <doi:10.5281/zenodo.11320255>. |
| Authors: | David Blodgett [cre, aut] (ORCID: <https://orcid.org/0000-0001-9489-1710>), Mark Keller [aut] (ORCID: <https://orcid.org/0000-0003-3003-874X>), Artür Manukyan [aut] (ORCID: <https://orcid.org/0000-0002-0441-9517>), zarr-developers [cph] |
| Maintainer: | David Blodgett <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-05-29 19:36:33 UTC |
| Source: | https://github.com/zarr-developers/pizzarr |
jsonlite::unbox function to "tag" the value as a scalar.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.
as_scalar(obj)as_scalar(obj)
obj |
The value to convert. |
The value wrapped as a scalar.
Class providing access to user attributes on an array or group.
The Zarr Attributes class.
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.
new()
Create a new Attributes instance.
Attributes$new( store, key = NA, read_only = FALSE, cache = TRUE, synchronizer = NA, zarr_format = NULL )
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).
An Attributes instance.
to_list()
convert attributes to list
Attributes$to_list()
list().
refresh()
refresh attributes
Attributes$refresh()
NULL (called for side effects).
contains()
check if object contains item
Attributes$contains(x)
xObject to test.
logical(1).
get_item()
get attribute
Attributes$get_item(item)
itemCharacter attribute name.
The attribute value.
set_item()
set attribute
Attributes$set_item(item, value)
itemCharacter attribute name.
valueValue to add or update.
NULL (called for side effects).
del_item()
delete attribute
Attributes$del_item(item)
itemCharacter attribute name.
NULL (called for side effects).
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.
Attributes$set_cached_v3_attrs(attrs_list)
attrs_listA named list of attributes from V3 zarr.json.
NULL (modifies cache in place).
clone()
The objects of this class are cloneable with this method.
Attributes$clone(deep = FALSE)
deepWhether to make a deep clone.
Class representing a Blosc compressor
R6::R6Class inheriting from Codec.
Blosc compressor for Zarr
pizzarr::Codec -> BloscCodec
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.
new()
Create a new Blosc compressor.
BloscCodec$new(cname = "lz4", clevel = 5, shuffle = TRUE, blocksize = NA, ...)
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.
A new BloscCodec object.
encode()
Compress data.
BloscCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
decode()
Decompress data.
BloscCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
get_config()
Get codec configuration as a list.
BloscCodec$get_config()
A named list.
clone()
The objects of this class are cloneable with this method.
BloscCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Class representing a bz2 compressor
R6::R6Class inheriting from Codec.
Bz2 compressor for Zarr
pizzarr::Codec -> Bz2Codec
levelThe compression level.
new()
Create a new Bz2 compressor.
Bz2Codec$new(level = 6, ...)
levelThe compression level, between 1 and 22.
...Not used.
A new Bz2Codec object.
encode()
Compress data.
Bz2Codec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
decode()
Decompress data.
Bz2Codec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
get_config()
Get codec configuration as a list.
Bz2Codec$get_config()
A named list.
clone()
The objects of this class are cloneable with this method.
Bz2Codec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Abstract class representing a compressor.
Abstract compressor for Zarr
encode()
Compress data.
Codec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
decode()
Decompress data.
Codec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
get_config()
Get codec configuration as a list.
Codec$get_config()
A named list.
clone()
The objects of this class are cloneable with this method.
Codec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
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.
The Zarr Dtype class.
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.
new()
Create a new Dtype instance.
Dtype$new(dtype, object_codec = NA)
dtypeThe original dtype string, like "<f4".
object_codecThe object codec instance.
A Dtype instance.
get_asrtype()
Get the R coercion function name for this dtype.
Dtype$get_asrtype()
Character string (e.g., "as.double").
get_rtype()
Get the R base type for this dtype.
Dtype$get_rtype()
An R prototype value (e.g., integer(), double(), or bit64::integer64()).
get_typed_array_ctr()
Get a constructor function for typed arrays of this dtype.
Dtype$get_typed_array_ctr()
A function that takes dim and returns an array.
clone()
The objects of this class are cloneable with this method.
Dtype$clone(deep = FALSE)
deepWhether to make a deep clone.
https://numpy.org/doc/stable/reference/arrays.dtypes.html
Thin store wrapper for Google Cloud Storage URLs. All I/O is delegated
to the zarrs Rust backend via object_store. Requires the gcs
compiled feature (r-universe tier).
GCS Store for Zarr (zarrs backend)
pizzarr::Store -> GcsStore
pizzarr::Store$close()pizzarr::Store$contains_item()pizzarr::Store$delete_item()pizzarr::Store$get_consolidated_metadata()pizzarr::Store$get_item()pizzarr::Store$is_erasable()pizzarr::Store$is_listable()pizzarr::Store$is_readable()pizzarr::Store$is_writeable()pizzarr::Store$listdir()pizzarr::Store$rename()pizzarr::Store$rmdir()pizzarr::Store$set_item()new()
Create a GcsStore.
GcsStore$new(url)
urlCharacter. GCS URL (e.g., "gs://bucket/prefix").
get_store_identifier()
Return the GCS URL for zarrs dispatch.
GcsStore$get_store_identifier()
A character string.
print()
Print a human-readable summary of the store.
GcsStore$print(...)
...Ignored.
self (invisibly).
clone()
The objects of this class are cloneable with this method.
GcsStore$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Store classes:
DirectoryStore,
HttpStore,
MemoryStore,
S3Store,
Store
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.
R6::R6Class inheriting from Codec.
Gzip compressor for Zarr
pizzarr::Codec -> GzipCodec
levelThe compression level.
new()
Create a new Gzip compressor.
GzipCodec$new(level = 6, ...)
levelThe compression level, between 1 and 22.
...Not used.
A new GzipCodec object.
encode()
Compress data.
GzipCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
decode()
Decompress data.
GzipCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
get_config()
Get codec configuration as a list.
GzipCodec$get_config()
A named list.
clone()
The objects of this class are cloneable with this method.
GzipCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Store class that uses HTTP requests.
Read-only. Depends on the crul package.
R6::R6Class inheriting from Store.
pizzarr::Store -> HttpStore
new()
Create a HttpStore object
HttpStore$new(url, options = NA, headers = NA)
url(character(1))
URL of the store.
options(list() or NA)
Options passed to crul.
headers(list() or NA)
Headers passed to crul.
A new HttpStore object.
get_item()
Get an item from the store.
HttpStore$get_item(item)
itemThe item key.
The item data in a vector of type raw.
contains_item()
Determine whether the store contains an item.
HttpStore$contains_item(item)
itemThe item key.
A boolean value.
listdir()
Fetches .zmetadata from the store evaluates its names
HttpStore$listdir()
Character vector of unique keys that do not start with a ..
get_cache_time_seconds()
Get cache time of http requests.
HttpStore$get_cache_time_seconds()
numeric(1).
set_cache_time_seconds()
Set cache time of http requests.
HttpStore$set_cache_time_seconds(seconds)
secondsNumber of seconds until cache is invalid – 0 for no cache.
NULL (called for side effects).
get_store_identifier()
Print a human-readable summary of the store.
Return the store URL for zarrs dispatch.
HttpStore$get_store_identifier()
A character string.
print()
HttpStore$print(...)
...Ignored.
self (invisibly).
clone()
The objects of this class are cloneable with this method.
HttpStore$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Store classes:
DirectoryStore,
GcsStore,
MemoryStore,
S3Store,
Store
Convenience function for the internal Int class constructor.
int(index, zero_based = FALSE)int(index, zero_based = FALSE)
index |
The integer index. |
zero_based |
The index of the dimension. By default, FALSE for R-like behavior. |
A Int instance with the specified parameters.
Check if an error is a KeyError.
is_key_error(e)is_key_error(e)
e |
The error to check. |
TRUE if the error is a KeyError, FALSE otherwise.
Check if a value is a scalar (i.e., a one-element vector that was converted with as_scalar).
is_scalar(s)is_scalar(s)
s |
The value to check. |
TRUE if the value is a scalar, FALSE otherwise.
Check if a value is a Slice instance.
is_slice(s)is_slice(s)
s |
The value to check. |
TRUE if the value is a Slice instance, FALSE otherwise.
Class representing a lzma compressor
R6::R6Class inheriting from Codec.
Lzma compressor for Zarr
pizzarr::Codec -> LzmaCodec
levelThe compression level.
formatThe compression format.
new()
Create a new lzma compressor.
LzmaCodec$new(level = 9, format = 1, ...)
levelThe compression level, between 1 and 22.
format(integer(1))
Only 1 is supported.
...Not used.
A new LzmaCodec object.
encode()
Compress data.
LzmaCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
decode()
Decompress data.
LzmaCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
get_config()
Get codec configuration as a list.
LzmaCodec$get_config()
A named list.
clone()
The objects of this class are cloneable with this method.
LzmaCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
VLenUtf8Codec,
ZlibCodec,
ZstdCodec
Represents a multi-dimensional array that can be accessed and subsetted via list of Slice instances.
The Zarr NestedArray class.
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.
new()
Create a new NestedArray instance.
NestedArray$new(data, shape = NA, dtype = NA, order = NA)
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 data is a raw vector. Optional.
A NestedArray instance.
get()
Subset the array.
NestedArray$get(selection)
selectionA list of slices.
A new NestedArray (potentially a subset) representing the selection.
set()
Set a subset of the array.
NestedArray$set(selection, value)
selectionA list of slices.
valueA NestedArray or a base R array.
NULL (called for side effects, modifies self$data in place).
flatten()
Flatten the array contents.
NestedArray$flatten(order = NA)
orderEither "C", "F", or NA.
The data as a flat vector.
flatten_to_raw()
Flatten the array contents and convert to a raw vector.
NestedArray$flatten_to_raw(order = NA)
orderEither "C", "F", or NA.
The data as a flat raw() vector (or plain vector for object dtypes).
as.array()
Convert NestedArray to a base R array.
NestedArray$as.array()
array().
clone()
The objects of this class are cloneable with this method.
NestedArray$clone(deep = FALSE)
deepWhether to make a deep clone.
Returns the feature flags compiled into the zarrs backend, or
character(0) with a message when the backend is absent.
pizzarr_compiled_features()pizzarr_compiled_features()
Character vector of feature names (e.g. "filesystem",
"gzip").
Controls parallelism and HTTP behaviour for the zarrs backend. Called with no arguments, returns the current settings as a named list. Called with arguments, sets the specified options and applies them to the Rust backend immediately.
pizzarr_config( nthreads = NULL, concurrent_target = NULL, http_batch_range_requests = NULL )pizzarr_config( nthreads = NULL, concurrent_target = NULL, http_batch_range_requests = NULL )
nthreads |
Integer or NULL. Number of threads for the rayon thread
pool. NULL uses all CPUs (the default). The pool can only be initialised
once per R session; later changes require a restart. Use the
|
concurrent_target |
Integer or NULL. Codec concurrency level — how many codec operations zarrs runs in parallel within a single read/write call. NULL uses the zarrs default (CPU count). Can be changed at any time. |
http_batch_range_requests |
Logical or NULL. Whether HTTP stores use
multipart range requests (default TRUE). Set to FALSE for servers with
incomplete multipart range support. Takes effect on the next
|
When called with no arguments, a named list of current settings. When called with arguments, the previous values (invisibly).
pizzarr.http_store_cache_time_seconds how long to cache web requests
pizzarr.nthreads number of threads for parallel codec operations (NULL = all CPUs). Set-once: takes effect only before the first zarrs operation. Use env var PIZZARR_NTHREADS for reliable session-level control.
pizzarr.concurrent_target codec concurrency level — how many codec operations zarrs runs in parallel within a single read/write call (NULL = zarrs default, typically CPU count). Can be changed at any time.
pizzarr.http_batch_range_requests whether HTTP stores use multipart range requests (TRUE by default). Set to FALSE for servers with incomplete multipart range support. Takes effect on next store open.
pizzarr_option_defaultspizzarr_option_defaults
An object of class list of length 4.
pizzarr demo data
pizzarr_sample( dataset = NULL, outdir = file.path(tools::R_user_dir("pizzarr"), "pizzarr_sample") )pizzarr_sample( dataset = NULL, outdir = file.path(tools::R_user_dir("pizzarr"), "pizzarr_sample") )
dataset |
character defining which demo dataset is desired, If NULL, all are returned |
outdir |
character directory path to store sample zarr stores |
For directory stores, unzips the store to a temporary directory and returns the resulting path.
path to ready to use zarr store
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)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)
Prints the command to install pizzarr from r-universe with the compiled zarrs backend, or reports that zarrs is already available.
pizzarr_upgrade()pizzarr_upgrade()
Thin store wrapper for S3 URLs. All I/O is delegated to the zarrs Rust
backend via object_store. Requires the s3 compiled feature
(r-universe tier).
S3 Store for Zarr (zarrs backend)
pizzarr::Store -> S3Store
pizzarr::Store$close()pizzarr::Store$contains_item()pizzarr::Store$delete_item()pizzarr::Store$get_consolidated_metadata()pizzarr::Store$get_item()pizzarr::Store$is_erasable()pizzarr::Store$is_listable()pizzarr::Store$is_readable()pizzarr::Store$is_writeable()pizzarr::Store$listdir()pizzarr::Store$rename()pizzarr::Store$rmdir()pizzarr::Store$set_item()new()
Create an S3Store.
S3Store$new(url)
urlCharacter. S3 URL (e.g., "s3://bucket/prefix").
get_store_identifier()
Return the S3 URL for zarrs dispatch.
S3Store$get_store_identifier()
A character string.
print()
Print a human-readable summary of the store.
S3Store$print(...)
...Ignored.
self (invisibly).
clone()
The objects of this class are cloneable with this method.
S3Store$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Store classes:
DirectoryStore,
GcsStore,
HttpStore,
MemoryStore,
Store
Convenience function for the internal Slice R6 class constructor.
slice(start, stop = NA, step = NA, zero_based = FALSE)slice(start, stop = NA, step = NA, zero_based = FALSE)
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. |
A Slice instance with the specified parameters.
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)))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)))
Class representing a VLenUtf8 compressor
R6::R6Class inheriting from Codec.
Variable-length UTF-8 codec for Zarr
pizzarr::Codec -> VLenUtf8Codec
encode()
Compress data.
VLenUtf8Codec$encode(buf, zarr_arr)
buf(character())
The un-compressed data (character vector).
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
decode()
Decompress data.
VLenUtf8Codec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
get_config()
Get codec configuration as a list.
VLenUtf8Codec$get_config()
A named list.
clone()
The objects of this class are cloneable with this method.
VLenUtf8Codec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
ZlibCodec,
ZstdCodec
Create an empty array
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, dimension_names = NULL )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, dimension_names = NULL )
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 |
dimension_names |
: character vector, optional
Named dimensions for V3 arrays. Length must equal |
ZarrArray
Create an array initialized with data.
zarr_create_array(data, ...)zarr_create_array(data, ...)
data |
A base R array() or pizzarr NestedArray instance. |
... |
The params of zarr_create() |
ZarrArray
Create an array filled with NAs.
zarr_create_empty(shape, ...)zarr_create_empty(shape, ...)
shape |
: int or tuple of ints Array shape. |
... |
The params of zarr_create() |
ZarrArray
Create a group.
zarr_create_group( store = NA, overwrite = FALSE, chunk_store = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, zarr_format = 2L )zarr_create_group( store = NA, overwrite = FALSE, chunk_store = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, zarr_format = 2L )
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 |
ZarrGroup
Create an array filled with zeros.
zarr_create_zeros(shape, ...)zarr_create_zeros(shape, ...)
shape |
: int or tuple of ints Array shape. |
... |
The params of zarr_create() |
ZarrArray
Convenience function to open a group or array using file-mode-like semantics.
zarr_open(store = NA, mode = NA, path = NA, ...)zarr_open(store = NA, mode = NA, path = NA, ...)
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. |
ZarrArray or ZarrGroup
Open an array using file-mode-like semantics.
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 )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 )
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 |
ZarrArray
Open a group using file-mode-like semantics.
zarr_open_group( store = NA, mode = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, chunk_store = NA, storage_options = NA, zarr_format = 2L )zarr_open_group( store = NA, mode = NA, cache_attrs = TRUE, synchronizer = NA, path = NA, chunk_store = NA, storage_options = NA, zarr_format = 2L )
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 |
ZarrGroup
Convenience function to save a ZarrArray to the local file system.
zarr_save_array(store, arr, ...)zarr_save_array(store, arr, ...)
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(). |
Writes the volcano matrix into a temporary
DirectoryStore as a Zarr array named "volcano" and returns the
opened group.
zarr_volcano()zarr_volcano()
A ZarrGroup containing a single array called "volcano".
g <- zarr_volcano() v <- g$get_item("volcano") image(v$get_item("...")$data, main = "Maunga Whau Volcano")g <- zarr_volcano() v <- g$get_item("volcano") image(v$get_item("...")$data, main = "Maunga Whau Volcano")
Returns TRUE if the store was in the cache and was removed,
FALSE if it was not cached.
zarrs_close_store(store_url)zarrs_close_store(store_url)
store_url |
Filesystem path or URL of the store to close. |
Called once at .onLoad to populate .pizzarr_env$zarrs_available.
The feature list is determined at compile time via cfg! checks.
Also installs a no-op panic hook on first call.
zarrs_compiled_features()zarrs_compiled_features()
Returns the same metadata list as zarrs_open_array_metadata.
zarrs_create_array( store_url, array_path, shape, chunks, dtype, codec_preset, fill_value, attributes_json, zarr_format )zarrs_create_array( store_url, array_path, shape, chunks, dtype, codec_preset, fill_value, attributes_json, zarr_format )
store_url |
Filesystem path to the store root. |
array_path |
Path to the array within the store. |
shape |
Integer vector of array dimensions. |
chunks |
Integer vector of chunk dimensions. |
dtype |
V3-style data type name (e.g., "float64", "int32"). |
codec_preset |
Compression preset: "none", "gzip", "blosc", or "zstd". |
fill_value |
Scalar fill value (numeric, integer, logical, or NA). |
attributes_json |
JSON string of array attributes. |
zarr_format |
Integer: 2 for V2, 3 for V3. |
Returns a named list with data (numeric, integer, or logical vector)
and shape (integer vector). Ranges are 0-based, exclusive stop.
zarrs_get_subset(store_url, array_path, ranges, concurrent_target)zarrs_get_subset(store_url, array_path, ranges, concurrent_target)
store_url |
Filesystem path or URL to the store root. |
array_path |
Path to the array within the store. |
ranges |
R list of length-2 integer vectors |
concurrent_target |
Optional codec concurrency override. |
Open (or reuse) the store at store_url, then probe for V3 and V2
metadata keys at path.
zarrs_node_exists(store_url, path)zarrs_node_exists(store_url, path)
store_url |
Filesystem path or URL to the store root. |
path |
Path within the store (e.g. |
store_url - Filesystem path or URL to the store root.
path - Path within the store (e.g. "group1/array1" or "" for root).
Returns an R error if the store cannot be opened or a storage I/O error occurs while probing keys.
Returns a named list with shape, chunks, dtype, r_type,
fill_value_json, zarr_format, and order.
zarrs_open_array_metadata(store_url, array_path)zarrs_open_array_metadata(store_url, array_path)
store_url |
Filesystem path or URL to the store root. |
array_path |
Path to the array within the store. |
Returns a named list with codec_concurrent_target,
store_cache_entries, and compiled_features.
zarrs_runtime_info()zarrs_runtime_info()
Controls the number of concurrent codec operations zarrs uses within a single array operation.
zarrs_set_codec_concurrent_target(n)zarrs_set_codec_concurrent_target(n)
n |
Positive integer. |
Controls multipart range request behaviour for HTTP stores created after this call. Existing cached stores are not affected.
zarrs_set_http_batch_range_requests(enable)zarrs_set_http_batch_range_requests(enable)
enable |
Logical scalar. |
Initialises the rayon global thread pool with n threads. The pool
can only be initialised once per process; returns TRUE on success,
FALSE if the pool was already initialised.
zarrs_set_nthreads(n)zarrs_set_nthreads(n)
n |
Positive integer. |
Returns true on success. Ranges are 0-based, exclusive stop.
Data must be a flat vector in C-order (row-major).
zarrs_set_subset(store_url, array_path, ranges, data, concurrent_target)zarrs_set_subset(store_url, array_path, ranges, data, concurrent_target)
store_url |
Filesystem path or URL to the store root. |
array_path |
Path to the array within the store. |
ranges |
R list of length-2 integer vectors |
data |
R vector (numeric, integer, or logical). |
concurrent_target |
Optional codec concurrency override. |
Convenience function for the internal Int class constructor with zero-based indexing
zb_int(index)zb_int(index)
index |
integer index |
Convenience function for the internal Slice R6 class constructor with zero-based indexing and exclusive stop index.
zb_slice(start, stop = NA, step = NA)zb_slice(start, stop = NA, step = NA)
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., |
A Slice instance with the specified parameters.
# 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)# 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)
Class representing a zlib compressor
R6::R6Class inheriting from Codec.
Zlib compressor for Zarr
pizzarr::Codec -> ZlibCodec
levelThe compression level.
new()
Create a new Zlib compressor.
ZlibCodec$new(level = 6, ...)
levelThe compression level, between 1 and 22.
...Not used.
A new ZlibCodec object.
encode()
Compress data.
ZlibCodec$encode(buf, zarr_arr)
buf(raw())
The un-compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Compressed data.
decode()
Decompress data.
ZlibCodec$decode(buf, zarr_arr)
buf(raw())
The compressed data.
zarr_arr(ZarrArray)
The ZarrArray instance.
Un-compressed data.
get_config()
Get codec configuration as a list.
ZlibCodec$get_config()
A named list.
clone()
The objects of this class are cloneable with this method.
ZlibCodec$clone(deep = FALSE)
deepWhether to make a deep clone.
Other Codec classes:
BloscCodec,
Bz2Codec,
Codec,
GzipCodec,
Lz4Codec,
LzmaCodec,
VLenUtf8Codec,
ZstdCodec