Skip to content

Commit

Permalink
refactor: make {Array,Bytes}PartialDecoderCache private
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Dec 23, 2024
1 parent 3a2a554 commit 2a4a848
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Reduce metadata code duplication in the `Node` module
- **Breaking**: Make `{Array,Bytes}PartialDecoderCache` private

### Fixed
- Cleanup unnecessary lifetime constraints in partial decoders
Expand Down
6 changes: 3 additions & 3 deletions zarrs/src/array/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//!
//! A [`CodecChain`] represents a codec sequence consisting of any number of array to array and bytes to bytes codecs, and one array to bytes codec.
//! A codec chain is itself an array to bytes codec.
//! A [`ArrayPartialDecoderCache`] or [`BytesPartialDecoderCache`] may be inserted into a codec chain to optimise partial decoding where appropriate.
//! A cache may be inserted into a codec chain to optimise partial decoding where appropriate.
//!
//! See <https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html#id18>.
Expand Down Expand Up @@ -59,8 +59,8 @@ use thiserror::Error;

mod array_partial_decoder_cache;
mod bytes_partial_decoder_cache;
pub use array_partial_decoder_cache::ArrayPartialDecoderCache;
pub use bytes_partial_decoder_cache::BytesPartialDecoderCache;
pub(crate) use array_partial_decoder_cache::ArrayPartialDecoderCache;
pub(crate) use bytes_partial_decoder_cache::BytesPartialDecoderCache;

mod byte_interval_partial_decoder;
pub use byte_interval_partial_decoder::ByteIntervalPartialDecoder;
Expand Down
6 changes: 3 additions & 3 deletions zarrs/src/array/codec/array_partial_decoder_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::{ArrayPartialDecoderTraits, ArraySubset, CodecError, CodecOptions};
use super::AsyncArrayPartialDecoderTraits;

/// A cache for an [`ArrayPartialDecoderTraits`] partial decoder.
pub struct ArrayPartialDecoderCache {
pub(crate) struct ArrayPartialDecoderCache {
decoded_representation: ChunkRepresentation,
cache: ArrayBytes<'static>,
}
Expand All @@ -18,7 +18,7 @@ impl ArrayPartialDecoderCache {
///
/// # Errors
/// Returns a [`CodecError`] if initialisation of the partial decoder fails.
pub fn new(
pub(crate) fn new(
input_handle: &dyn ArrayPartialDecoderTraits,
decoded_representation: ChunkRepresentation,
options: &CodecOptions,
Expand All @@ -43,7 +43,7 @@ impl ArrayPartialDecoderCache {
///
/// # Errors
/// Returns a [`CodecError`] if initialisation of the partial decoder fails.
pub async fn async_new(
pub(crate) async fn async_new(
input_handle: &dyn AsyncArrayPartialDecoderTraits,
decoded_representation: ChunkRepresentation,
options: &CodecOptions,
Expand Down
2 changes: 1 addition & 1 deletion zarrs/src/array/codec/array_to_bytes/codec_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::array::codec::{AsyncArrayPartialDecoderTraits, AsyncBytesPartialDecod

/// A codec chain is a sequence of array to array, a bytes to bytes, and a sequence of array to bytes codecs.
///
/// A codec chain partial decoder may insert a cache: [`ArrayPartialDecoderCache`] or [`BytesPartialDecoderCache`].
/// A codec chain partial decoder may insert a cache.
/// For example, the output of the `blosc`/`gzip` codecs should be cached since they read and decode an entire chunk.
/// If decoding (i.e. going backwards through a codec chain), then a cache may be inserted
/// - following the last codec with [`partial_decoder_decodes_all`](crate::array::codec::CodecTraits::partial_decoder_decodes_all) true, or
Expand Down
6 changes: 3 additions & 3 deletions zarrs/src/array/codec/bytes_partial_decoder_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{BytesPartialDecoderTraits, CodecError, CodecOptions};
use super::AsyncBytesPartialDecoderTraits;

/// A cache for a [`BytesPartialDecoderTraits`] partial decoder.
pub struct BytesPartialDecoderCache<'a> {
pub(crate) struct BytesPartialDecoderCache<'a> {
cache: Option<Vec<u8>>,
phantom: PhantomData<&'a ()>,
}
Expand All @@ -23,7 +23,7 @@ impl<'a> BytesPartialDecoderCache<'a> {
///
/// # Errors
/// Returns a [`CodecError`] if caching fails.
pub fn new(
pub(crate) fn new(
input_handle: &dyn BytesPartialDecoderTraits,
options: &CodecOptions,
) -> Result<Self, CodecError> {
Expand All @@ -41,7 +41,7 @@ impl<'a> BytesPartialDecoderCache<'a> {
///
/// # Errors
/// Returns a [`CodecError`] if caching fails.
pub async fn async_new(
pub(crate) async fn async_new(
input_handle: &dyn AsyncBytesPartialDecoderTraits,
options: &CodecOptions,
) -> Result<BytesPartialDecoderCache<'a>, CodecError> {
Expand Down

0 comments on commit 2a4a848

Please sign in to comment.