libzarr
Header-only C++17 Zarr v2/v3, WASM-compatible
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
zarr::Array Class Reference

#include <array.hpp>

Public Member Functions

const ArrayMetameta () const
 Normalized metadata (shape, chunks, dtype, codecs, attributes).
 
const std::string & path () const
 Node path within the store ("" = root).
 
std::vector< std::uint64_t > grid_shape () const
 Chunk-grid extent per dimension.
 
std::uint64_t nbytes () const
 Whole-array size in bytes (elements x itemsize).
 
std::uint64_t chunk_nbytes () const
 One full chunk's size in bytes.
 
Bytes read_chunk (const std::vector< std::uint64_t > &index) const
 
void write_chunk (const std::vector< std::uint64_t > &index, const void *data, std::size_t size)
 
Bytes read_chunk_range (const std::vector< std::uint64_t > &index, std::uint64_t element_offset, std::uint64_t element_count) const
 
void read (void *dst, std::size_t size) const
 
void write (const void *src, std::size_t size)
 
void read_region (const std::vector< std::uint64_t > &origin, const std::vector< std::uint64_t > &shape, void *dst, std::size_t size) const
 
void write_region (const std::vector< std::uint64_t > &origin, const std::vector< std::uint64_t > &shape, const void *src, std::size_t size)
 
const jsonattributes () const
 User attributes (.zattrs).
 
void set_attributes (json attributes)
 
std::string chunk_store_key (const std::vector< std::uint64_t > &index) const
 Store key of the chunk at index (bounds-checked against the grid).
 

Static Public Member Functions

static Array create (std::shared_ptr< Store > store, const std::string &path, const ArraySpec &spec)
 
static Array open (std::shared_ptr< Store > store, const std::string &path, OpenOptions options={})
 

Friends

class Group
 

Detailed Description

A Zarr array bound to a Store. Value-semantics handle: cheap to move, holds a shared reference to the store.

Member Function Documentation

◆ create()

static Array zarr::Array::create ( std::shared_ptr< Store store,
const std::string &  path,
const ArraySpec spec 
)
inlinestatic

Creates an array at path ("" = the store root) in spec.format, writing canonical metadata. Fails if the spec is invalid; overwrites existing metadata.

◆ open()

static Array zarr::Array::open ( std::shared_ptr< Store store,
const std::string &  path,
OpenOptions  options = {} 
)
inlinestatic

Opens an existing array at path, probing v3 (zarr.json) first, then v2 (.zarray).

◆ read()

void zarr::Array::read ( void *  dst,
std::size_t  size 
) const
inline

Reads the whole array into dst (native order, C layout); size must equal nbytes().

◆ read_chunk()

Bytes zarr::Array::read_chunk ( const std::vector< std::uint64_t > &  index) const
inline

Reads one chunk as a full native/C-order buffer. Missing chunks read as fill; edge chunks come back full-sized (fill-padded), per the format.

◆ read_chunk_range()

Bytes zarr::Array::read_chunk_range ( const std::vector< std::uint64_t > &  index,
std::uint64_t  element_offset,
std::uint64_t  element_count 
) const
inline

Reads element_count consecutive elements of one chunk starting at linear element element_offset (in stored C order), using a store byte-range read — a single hosted object can be range-served. Requires an uncompressed, untransposed chunk layout (CodecPipeline::supports_partial_read).

◆ read_region()

void zarr::Array::read_region ( const std::vector< std::uint64_t > &  origin,
const std::vector< std::uint64_t > &  shape,
void *  dst,
std::size_t  size 
) const
inline

Reads the hyperslab of shape starting at origin (array coordinates) into dst as a C-order native buffer of exactly size bytes. Missing chunks read as fill.

◆ set_attributes()

void zarr::Array::set_attributes ( json  attributes)
inline

Replaces the user attributes and persists them. For v3, the stored zarr.json is patched in place, preserving any extension members.

◆ write()

void zarr::Array::write ( const void *  src,
std::size_t  size 
)
inline

Writes the whole array from src (native order, C layout); size must equal nbytes(). Edge chunks are fill-padded, per the format.

◆ write_chunk()

void zarr::Array::write_chunk ( const std::vector< std::uint64_t > &  index,
const void *  data,
std::size_t  size 
)
inline

Writes one full chunk (native byte order, C layout, exactly chunk_nbytes() bytes — edge chunks included, fill-padded).

◆ write_region()

void zarr::Array::write_region ( const std::vector< std::uint64_t > &  origin,
const std::vector< std::uint64_t > &  shape,
const void *  src,
std::size_t  size 
)
inline

Writes the hyperslab of shape starting at origin from src (a C-order native buffer of exactly size bytes). Partially covered chunks are read-modify-written, preserving their other elements; chunks the region covers entirely are rebuilt without a read.


The documentation for this class was generated from the following file: