Skip to content

Commit

Permalink
fletcher32 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Jan 7, 2025
1 parent 4edc7cf commit 09eb5b8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `Group::[set_]consolidated_metadata`
- Add `Node::consolidate_metadata`
- Consolidated metadata is not currently used to optimise node hierarchy requests
- Add `fletcher32` checksum codec based on the numcodecs implementation
- Add experimental `fletcher32` checksum codec based on the numcodecs implementation
- Adds `fletcher32` feature flag

### Changed
- **Breaking**: Seal `Array` extension traits: `ArraySharded[Readable]Ext` and `ArrayChunkCacheExt`
Expand Down
2 changes: 2 additions & 0 deletions zarrs/doc/status/codecs_experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This is configurable with [`Config::experimental_codec_names_mut`](config::Confi
| | [vlen-utf8] | <https://codec.zarrs.dev/array_to_bytes/vlen_utf8> | &check; | &check; | |
| Bytes to Bytes | [bz2] | <https://codec.zarrs.dev/bytes_to_bytes/bz2> | &check; | &check; | bz2 |
| | [gdeflate] | <https://codec.zarrs.dev/bytes_to_bytes/gdeflate> | &check; | | gdeflate |
| | [fletcher32] | <https://codec.zarrs.dev/bytes_to_bytes/fletcher32> | &check; | &check; | fletcher32 |

[bitround]: (crate::array::codec::array_to_array::bitround)
[zfp]: crate::array::codec::array_to_bytes::zfp
Expand All @@ -23,3 +24,4 @@ This is configurable with [`Config::experimental_codec_names_mut`](config::Confi
[vlen-utf8]: crate::array::codec::array_to_bytes::vlen_utf8
[bz2]: crate::array::codec::bytes_to_bytes::bz2
[gdeflate]: crate::array::codec::bytes_to_bytes::gdeflate
[fletcher32]: crate::array::codec::bytes_to_bytes::fletcher32
9 changes: 9 additions & 0 deletions zarrs/src/array/codec/bytes_to_bytes/fletcher32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
//!
//! Appends a fletcher32 checksum of the input bytestream.
//!
//! This is based on the `numcodecs` implementation.
//! See <https://numcodecs.readthedocs.io/en/latest/checksum32.html#fletcher32>.
//!
//! <div class="warning">
//! This codec is experimental and may be incompatible with other Zarr V3 implementations.
//! </div>
//!
//! This codec requires the `fletcher32` feature, which is disabled by default.
//!
//! See [`Fletcher32CodecConfigurationV1`] for example `JSON` metadata.
mod fletcher32_codec;

Expand Down
2 changes: 1 addition & 1 deletion zarrs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::array::{codec::CodecOptions, ArrayMetadataOptions};
///
/// [`CodecOptions::validate_checksums()`] defaults to [`Config::validate_checksums()`].
///
/// If validate checksums is enabled, checksum codecs (e.g. `crc32c`) will validate that encoded data matches stored checksums, otherwise validation is skipped.
/// If validate checksums is enabled, checksum codecs (e.g. `crc32c`, `fletcher32`) will validate that encoded data matches stored checksums, otherwise validation is skipped.
/// Note that regardless of this configuration option, checksum codecs may skip validation when partial decoding.
///
/// ### Store Empty Chunks
Expand Down
2 changes: 1 addition & 1 deletion zarrs/tests/zarr_python_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn zarr_python_compat_fletcher32() -> Result<(), Box<dyn Error>> {
let elements = array.retrieve_array_subset_elements::<u16>(&ArraySubset::new_with_shape(
array.shape().to_vec(),
))?;
assert_eq!(elements, (0..100*100).collect::<Vec<u16>>());
assert_eq!(elements, (0..100 * 100).collect::<Vec<u16>>());

Ok(())
}
8 changes: 7 additions & 1 deletion zarrs_metadata/src/v3/array/codec/fletcher32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ pub enum Fletcher32CodecConfiguration {

/// `fletcher32` (checksum) codec configuration parameters (version 1.0 draft).
///
/// See <https://numcodecs.readthedocs.io/en/latest/checksum32.html>.
/// ### Example (Zarr V3)
/// ```json
/// {
/// "name": "fletcher32",
/// "configuration": {}
/// }
/// ```
#[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Debug, Display)]
#[serde(deny_unknown_fields)]
#[display("{}", serde_json::to_string(self).unwrap_or_default())]
Expand Down

0 comments on commit 09eb5b8

Please sign in to comment.