diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d617a..4604603 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## [0.17.3] - 2025-11-27 + +### Features + +- Compress zarr traces with zstd (Adrian Seyboldt) + + ## [0.17.2] - 2025-11-27 ### Bug Fixes @@ -13,6 +20,8 @@ All notable changes to this project will be documented in this file. - Update pulp dependency (Adrian Seyboldt) +- Prepare release (Adrian Seyboldt) + ## [0.17.1] - 2025-11-13 diff --git a/Cargo.toml b/Cargo.toml index 6aa9f1a..e1ced60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nuts-rs" -version = "0.17.2" +version = "0.17.3" authors = [ "Adrian Seyboldt ", "PyMC Developers ", diff --git a/src/storage/zarr/common.rs b/src/storage/zarr/common.rs index 042b148..38c33b2 100644 --- a/src/storage/zarr/common.rs +++ b/src/storage/zarr/common.rs @@ -4,6 +4,7 @@ use std::{collections::HashMap, num::NonZero}; use anyhow::Result; use nuts_storable::{ItemType, Value}; +use zarrs::array::codec::{BloscCodec, BloscCodecConfiguration, BloscCodecConfigurationV1}; use zarrs::array::{Array, ArrayBuilder, DataType, FillValue}; use zarrs::metadata_ext::data_type::NumpyTimeUnit; @@ -232,7 +233,30 @@ pub fn create_arrays( .chain(std::iter::once(draw_chunk_size)) .chain(extra_shape) .collect(); + + let codec = { + if let Some(typesize) = zarr_type.fixed_size() { + let config = BloscCodecConfiguration::V1(BloscCodecConfigurationV1 { + cname: zarrs::array::codec::BloscCompressor::Zstd, + clevel: 3u8.try_into().unwrap(), + shuffle: zarrs::array::codec::BloscShuffleMode::Shuffle, + blocksize: 0, + typesize: Some(typesize), + }); + BloscCodec::new_with_configuration(&config)? + } else { + let config = BloscCodecConfiguration::V1(BloscCodecConfigurationV1 { + cname: zarrs::array::codec::BloscCompressor::Zstd, + clevel: 3u8.try_into().unwrap(), + shuffle: zarrs::array::codec::BloscShuffleMode::NoShuffle, + blocksize: 0, + typesize: None, + }); + BloscCodec::new_with_configuration(&config)? + } + }; let array = ArrayBuilder::new(shape, grid, zarr_type, fill_value) + .bytes_to_bytes_codecs(vec![Arc::new(codec)]) .dimension_names(Some(dims)) .build(store.clone(), &format!("{}/{}", group_path, name))?; arrays.insert(name.to_string(), array);