Zarr Metadata

Header file: <libs/zarr/zarr_metadata.hpp> [source]

std::string vec_to_string(const std::vector<size_t> &vals)

Converts a vector of integers into a single list written as a string.

Given vector of a type convertible to a string with values [a, b, c, …, z], function returns the string “[a, b, c, …, z]” with elements separated by commas and enclosed in square brackets. Function is useful for converting vectors representing the shape of chunks and arrays etc. into a string format for metadata json files.

Parameters:

vals – The vector values of a type convertible to a string.

Returns:

A string representation of the vector.

std::string make_part_zarrmetadata(const std::vector<size_t> &chunkshape, const std::string_view dtype)

Generates part of the metadata for a Zarr array .zarray json file.

This function constructs a string containing all the compulsory metadata of a Zarr array for its .zarray json file, excluding the array’s shape.

Parameters:
  • chunkshape – The shape of individual data chunks along each dimension.

  • dtype – The data type stored in the arrays (e.g., “<f8”).

Returns:

A string view containing the partial metadata for the Zarr array.

template<typename T>
class ZarrMetadata

Class for generating metadata required for a Zarr array.

This class generates compulsory metadata for the Zarr array .zarray JSON file. The metadata includes information such as chunk shape, data type, etc.

Template Parameters:

T – The data type of the array’s elements.

Public Functions

inline ZarrMetadata(const std::vector<size_t> &chunkshape, const std::string_view dtype)

Constructs a ZarrMetadata object.

Constructs a ZarrMetadata object with the given chunk shape and data type.

Parameters:
  • chunkshape – The shape of the chunks used to store array data.

  • dtype – The data type of the array’s elements in Zarr format (e.g., “<f8” for double).

inline std::string operator()(const std::vector<size_t> &arrayshape) const

Generates metadata for the Zarr array.

Generates compulsory metadata for the Zarr array .zarray JSON file.

Parameters:

arrayshape – The shape of the Zarr array.

Returns:

A string containing the metadata for the Zarr array.

Private Members

std::string part_zarrmetadata

Metadata required for zarr array excluding array’s shape