diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c821a3..5cadb41c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add store lock tests - Added `contiguous_elements` method to `ContiguousIndicesIterator` and `ContiguousLinearisedIndicesIterator` - Added `ChunkShape::num_elements` - - Added `codec::{Encode,Decode,PartialDecode,PartialDecoder}Options{Builder}` + - Added `codec::CodecOptions{Builder}` - Added new `Array::opt` methods which can use new encode/decode options - **Breaking** Existing `Array` `_opt` use new encode/decode options insted of `parallel: bool` - Implement `DoubleEndedIterator` for `{Indices,LinearisedIndices,ContiguousIndices,ContiguousLinearisedIndicesIterator}Iterator` diff --git a/src/array/array_async_readable.rs b/src/array/array_async_readable.rs index 86fc9bb3..01878612 100644 --- a/src/array/array_async_readable.rs +++ b/src/array/array_async_readable.rs @@ -10,8 +10,8 @@ use crate::{ use super::{ codec::{ - ArrayCodecTraits, ArrayToBytesCodecTraits, AsyncArrayPartialDecoderTraits, - AsyncStoragePartialDecoder, DecodeOptions, PartialDecoderOptions, + options::CodecOptions, ArrayCodecTraits, ArrayToBytesCodecTraits, + AsyncArrayPartialDecoderTraits, AsyncStoragePartialDecoder, }, transmute_from_bytes_vec, unsafe_cell_slice::UnsafeCellSlice, @@ -52,7 +52,7 @@ impl Array { pub async fn async_retrieve_chunk_if_exists_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result>, ArrayError> { let storage_handle = Arc::new(StorageHandle::new(self.storage.clone())); let storage_transformer = self @@ -94,7 +94,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result>, ArrayError> { - self.async_retrieve_chunk_if_exists_opt(chunk_indices, &DecodeOptions::default()) + self.async_retrieve_chunk_if_exists_opt(chunk_indices, &CodecOptions::default()) .await } @@ -111,7 +111,7 @@ impl Array { pub async fn async_retrieve_chunk_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { let chunk = self .async_retrieve_chunk_if_exists_opt(chunk_indices, options) @@ -128,7 +128,7 @@ impl Array { /// Read and decode the chunk at `chunk_indices` into its bytes or the fill value if it does not exist (default options). #[allow(clippy::missing_panics_doc, clippy::missing_errors_doc)] pub async fn async_retrieve_chunk(&self, chunk_indices: &[u64]) -> Result, ArrayError> { - self.async_retrieve_chunk_opt(chunk_indices, &DecodeOptions::default()) + self.async_retrieve_chunk_opt(chunk_indices, &CodecOptions::default()) .await } @@ -144,7 +144,7 @@ impl Array { pub async fn async_retrieve_chunk_elements_if_exists_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result>, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self @@ -159,7 +159,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result>, ArrayError> { - self.async_retrieve_chunk_elements_if_exists_opt(chunk_indices, &DecodeOptions::default()) + self.async_retrieve_chunk_elements_if_exists_opt(chunk_indices, &CodecOptions::default()) .await } @@ -175,7 +175,7 @@ impl Array { pub async fn async_retrieve_chunk_elements_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self @@ -190,7 +190,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result, ArrayError> { - self.async_retrieve_chunk_elements_opt(chunk_indices, &DecodeOptions::default()) + self.async_retrieve_chunk_elements_opt(chunk_indices, &CodecOptions::default()) .await } @@ -210,7 +210,7 @@ impl Array { pub async fn async_retrieve_chunk_ndarray_if_exists_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result>, ArrayError> { // validate_element_size::(self.data_type())?; in // async_retrieve_chunk_elements_if_exists let shape = self @@ -234,7 +234,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result>, ArrayError> { - self.async_retrieve_chunk_ndarray_if_exists_opt(chunk_indices, &DecodeOptions::default()) + self.async_retrieve_chunk_ndarray_if_exists_opt(chunk_indices, &CodecOptions::default()) .await } @@ -254,7 +254,7 @@ impl Array { pub async fn async_retrieve_chunk_ndarray_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { // validate_element_size::(self.data_type())?; // in async_retrieve_chunk_elements let shape = self @@ -274,7 +274,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result, ArrayError> { - self.async_retrieve_chunk_ndarray_opt(chunk_indices, &DecodeOptions::default()) + self.async_retrieve_chunk_ndarray_opt(chunk_indices, &CodecOptions::default()) .await } @@ -291,7 +291,7 @@ impl Array { pub async fn async_retrieve_chunks_opt( &self, chunks: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { if chunks.dimensionality() != self.dimensionality() { return Err(ArrayError::InvalidArraySubset( @@ -349,7 +349,7 @@ impl Array { /// Read and decode the chunk at `chunk_indices` into its bytes (default options). #[allow(clippy::missing_panics_doc, clippy::missing_errors_doc)] pub async fn async_retrieve_chunks(&self, chunks: &ArraySubset) -> Result, ArrayError> { - self.async_retrieve_chunks_opt(chunks, &DecodeOptions::default()) + self.async_retrieve_chunks_opt(chunks, &CodecOptions::default()) .await } @@ -360,7 +360,7 @@ impl Array { pub async fn async_retrieve_chunks_elements_opt( &self, chunks: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self.async_retrieve_chunks_opt(chunks, options).await?; @@ -375,7 +375,7 @@ impl Array { &self, chunks: &ArraySubset, ) -> Result, ArrayError> { - self.async_retrieve_chunks_elements_opt(chunks, &DecodeOptions::default()) + self.async_retrieve_chunks_elements_opt(chunks, &CodecOptions::default()) .await } @@ -387,7 +387,7 @@ impl Array { pub async fn async_retrieve_chunks_ndarray_opt( &self, chunks: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let array_subset = self.chunks_subset(chunks)?; @@ -404,7 +404,7 @@ impl Array { &self, chunks: &ArraySubset, ) -> Result, ArrayError> { - self.async_retrieve_chunks_ndarray_opt(chunks, &DecodeOptions::default()) + self.async_retrieve_chunks_ndarray_opt(chunks, &CodecOptions::default()) .await } @@ -413,7 +413,7 @@ impl Array { chunk_indices: &[u64], array_subset: &ArraySubset, output: &mut [u8], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { // Get the subset of the array corresponding to the chunk let chunk_subset_in_array = unsafe { @@ -474,7 +474,7 @@ impl Array { pub async fn async_retrieve_array_subset_opt( &self, array_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { if array_subset.dimensionality() != self.dimensionality() { return Err(ArrayError::InvalidArraySubset( @@ -647,7 +647,7 @@ impl Array { &self, array_subset: &ArraySubset, ) -> Result, ArrayError> { - self.async_retrieve_array_subset_opt(array_subset, &DecodeOptions::default()) + self.async_retrieve_array_subset_opt(array_subset, &CodecOptions::default()) .await } @@ -663,7 +663,7 @@ impl Array { pub async fn async_retrieve_array_subset_elements_opt( &self, array_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self @@ -678,7 +678,7 @@ impl Array { &self, array_subset: &ArraySubset, ) -> Result, ArrayError> { - self.async_retrieve_array_subset_elements_opt(array_subset, &DecodeOptions::default()) + self.async_retrieve_array_subset_elements_opt(array_subset, &CodecOptions::default()) .await } @@ -696,7 +696,7 @@ impl Array { pub async fn async_retrieve_array_subset_ndarray_opt( &self, array_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { // validate_element_size::(self.data_type())?; // in async_retrieve_array_subset_elements let elements = self @@ -712,7 +712,7 @@ impl Array { &self, array_subset: &ArraySubset, ) -> Result, ArrayError> { - self.async_retrieve_array_subset_ndarray_opt(array_subset, &DecodeOptions::default()) + self.async_retrieve_array_subset_ndarray_opt(array_subset, &CodecOptions::default()) .await } @@ -731,7 +731,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { let chunk_representation = self.chunk_array_representation(chunk_indices)?; if !chunk_subset.inbounds(&chunk_representation.shape_u64()) { @@ -777,7 +777,7 @@ impl Array { chunk_indices: &[u64], chunk_subset: &ArraySubset, ) -> Result, ArrayError> { - self.async_retrieve_chunk_subset_opt(chunk_indices, chunk_subset, &DecodeOptions::default()) + self.async_retrieve_chunk_subset_opt(chunk_indices, chunk_subset, &CodecOptions::default()) .await } @@ -793,7 +793,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self @@ -812,7 +812,7 @@ impl Array { self.async_retrieve_chunk_subset_elements_opt( chunk_indices, chunk_subset, - &DecodeOptions::default(), + &CodecOptions::default(), ) .await } @@ -833,7 +833,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { // validate_element_size::(self.data_type())?; // in async_retrieve_chunk_subset_elements let elements = self @@ -853,7 +853,7 @@ impl Array { self.async_retrieve_chunk_subset_ndarray_opt( chunk_indices, chunk_subset, - &DecodeOptions::default(), + &CodecOptions::default(), ) .await } @@ -865,7 +865,7 @@ impl Array { pub async fn async_partial_decoder_opt<'a>( &'a self, chunk_indices: &[u64], - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, ArrayError> { let storage_handle = Arc::new(StorageHandle::new(self.storage.clone())); let storage_transformer = self @@ -890,7 +890,7 @@ impl Array { &'a self, chunk_indices: &[u64], ) -> Result, ArrayError> { - self.async_partial_decoder_opt(chunk_indices, &PartialDecoderOptions::default()) + self.async_partial_decoder_opt(chunk_indices, &CodecOptions::default()) .await } } diff --git a/src/array/array_async_readable_writable.rs b/src/array/array_async_readable_writable.rs index f2859cee..172d2096 100644 --- a/src/array/array_async_readable_writable.rs +++ b/src/array/array_async_readable_writable.rs @@ -5,10 +5,7 @@ use crate::{ storage::{data_key, AsyncReadableWritableStorageTraits}, }; -use super::{ - codec::{DecodeOptions, EncodeOptions}, - Array, ArrayError, -}; +use super::{codec::options::CodecOptions, Array, ArrayError}; impl Array { /// Encode `subset_bytes` and store in `array_subset`. @@ -27,8 +24,7 @@ impl Array, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { // Validation if array_subset.dimensionality() != self.shape().len() { @@ -65,7 +61,7 @@ impl Array Array Array Array, ) -> Result<(), ArrayError> { - self.async_store_array_subset_opt( - array_subset, - subset_bytes, - &EncodeOptions::default(), - &DecodeOptions::default(), - ) - .await + self.async_store_array_subset_opt(array_subset, subset_bytes, &CodecOptions::default()) + .await } /// Encode `subset_elements` and store in `array_subset`. @@ -173,18 +162,12 @@ impl Array, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_async_store_elements!( self, subset_elements, - async_store_array_subset_opt( - array_subset, - subset_elements, - encode_options, - decode_options - ) + async_store_array_subset_opt(array_subset, subset_elements, options) ) } @@ -198,8 +181,7 @@ impl Array Array, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let subset = ArraySubset::new_with_start_shape( subset_start.to_vec(), @@ -224,12 +205,7 @@ impl Array Array Array, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { // Validation if let Some(chunk_shape) = self @@ -295,7 +269,7 @@ impl Array Array Array Array Array, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_async_store_elements!( self, @@ -377,8 +349,7 @@ impl Array Array Array, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let subset = ArraySubset::new_with_start_shape( chunk_subset_start.to_vec(), @@ -432,8 +401,7 @@ impl Array Array Array { &self, chunk_indices: &[u64], chunk_bytes: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { // Validation let chunk_array_representation = self.chunk_array_representation(chunk_indices)?; @@ -84,7 +84,7 @@ impl Array { chunk_indices: &[u64], chunk_bytes: Vec, ) -> Result<(), ArrayError> { - self.async_store_chunk_opt(chunk_indices, chunk_bytes, &EncodeOptions::default()) + self.async_store_chunk_opt(chunk_indices, chunk_bytes, &CodecOptions::default()) .await } @@ -100,7 +100,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_elements: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_async_store_elements!( self, @@ -116,12 +116,8 @@ impl Array { chunk_indices: &[u64], chunk_elements: Vec, ) -> Result<(), ArrayError> { - self.async_store_chunk_elements_opt( - chunk_indices, - chunk_elements, - &EncodeOptions::default(), - ) - .await + self.async_store_chunk_elements_opt(chunk_indices, chunk_elements, &CodecOptions::default()) + .await } #[cfg(feature = "ndarray")] @@ -136,7 +132,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_array: &ndarray::ArrayViewD<'_, T>, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_async_store_ndarray!( self, @@ -153,7 +149,7 @@ impl Array { chunk_indices: &[u64], chunk_array: &ndarray::ArrayViewD<'_, T>, ) -> Result<(), ArrayError> { - self.async_store_chunk_ndarray_opt(chunk_indices, chunk_array, &EncodeOptions::default()) + self.async_store_chunk_ndarray_opt(chunk_indices, chunk_array, &CodecOptions::default()) .await } @@ -172,7 +168,7 @@ impl Array { &self, chunks: &ArraySubset, chunks_bytes: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let num_chunks = chunks.num_elements_usize(); if num_chunks == 1 { @@ -247,7 +243,7 @@ impl Array { chunks: &ArraySubset, chunks_bytes: Vec, ) -> Result<(), ArrayError> { - self.async_store_chunks_opt(chunks, chunks_bytes, &EncodeOptions::default()) + self.async_store_chunks_opt(chunks, chunks_bytes, &CodecOptions::default()) .await } @@ -259,7 +255,7 @@ impl Array { &self, chunks: &ArraySubset, chunks_elements: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_async_store_elements!( self, @@ -275,7 +271,7 @@ impl Array { chunks: &ArraySubset, chunks_elements: Vec, ) -> Result<(), ArrayError> { - self.async_store_chunks_elements_opt(chunks, chunks_elements, &EncodeOptions::default()) + self.async_store_chunks_elements_opt(chunks, chunks_elements, &CodecOptions::default()) .await } @@ -288,7 +284,7 @@ impl Array { &self, chunks: &ArraySubset, chunks_array: &ndarray::ArrayViewD<'_, T>, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_async_store_ndarray!( self, @@ -305,7 +301,7 @@ impl Array { chunks: &ArraySubset, chunks_array: &ndarray::ArrayViewD<'_, T>, ) -> Result<(), ArrayError> { - self.async_store_chunks_ndarray_opt(chunks, chunks_array, &EncodeOptions::default()) + self.async_store_chunks_ndarray_opt(chunks, chunks_array, &CodecOptions::default()) .await } diff --git a/src/array/array_sync_readable.rs b/src/array/array_sync_readable.rs index 1c1d75a0..a7ff4e61 100644 --- a/src/array/array_sync_readable.rs +++ b/src/array/array_sync_readable.rs @@ -11,8 +11,8 @@ use crate::{ use super::{ codec::{ - ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToBytesCodecTraits, CodecError, - DecodeOptions, PartialDecoderOptions, StoragePartialDecoder, + options::CodecOptions, ArrayCodecTraits, ArrayPartialDecoderTraits, + ArrayToBytesCodecTraits, CodecError, StoragePartialDecoder, }, concurrency::concurrency_chunks_and_codec, transmute_from_bytes_vec, @@ -53,7 +53,7 @@ impl Array { pub fn retrieve_chunk_if_exists_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result>, ArrayError> { if chunk_indices.len() != self.dimensionality() { return Err(ArrayError::InvalidChunkGridIndicesError( @@ -98,7 +98,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result>, ArrayError> { - self.retrieve_chunk_if_exists_opt(chunk_indices, &DecodeOptions::default()) + self.retrieve_chunk_if_exists_opt(chunk_indices, &CodecOptions::default()) } /// Read and decode the chunk at `chunk_indices` into its bytes or the fill value if it does not exist. @@ -114,7 +114,7 @@ impl Array { pub fn retrieve_chunk_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { let chunk = self.retrieve_chunk_if_exists_opt(chunk_indices, options)?; if let Some(chunk) = chunk { @@ -129,7 +129,7 @@ impl Array { /// Read and decode the chunk at `chunk_indices` into its bytes or the fill value if it does not exist (default options). #[allow(clippy::missing_panics_doc, clippy::missing_errors_doc)] pub fn retrieve_chunk(&self, chunk_indices: &[u64]) -> Result, ArrayError> { - self.retrieve_chunk_opt(chunk_indices, &DecodeOptions::default()) + self.retrieve_chunk_opt(chunk_indices, &CodecOptions::default()) } /// Read and decode the chunk at `chunk_indices` into a vector of its elements if it exists. @@ -144,7 +144,7 @@ impl Array { pub fn retrieve_chunk_elements_if_exists_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result>, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self.retrieve_chunk_if_exists_opt(chunk_indices, options)?; @@ -157,7 +157,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result>, ArrayError> { - self.retrieve_chunk_elements_if_exists_opt(chunk_indices, &DecodeOptions::default()) + self.retrieve_chunk_elements_if_exists_opt(chunk_indices, &CodecOptions::default()) } /// Read and decode the chunk at `chunk_indices` into a vector of its elements or the fill value if it does not exist. @@ -172,7 +172,7 @@ impl Array { pub fn retrieve_chunk_elements_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self.retrieve_chunk_opt(chunk_indices, options)?; @@ -185,7 +185,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result, ArrayError> { - self.retrieve_chunk_elements_opt(chunk_indices, &DecodeOptions::default()) + self.retrieve_chunk_elements_opt(chunk_indices, &CodecOptions::default()) } #[cfg(feature = "ndarray")] @@ -204,7 +204,7 @@ impl Array { pub fn retrieve_chunk_ndarray_if_exists_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result>, ArrayError> { // validate_element_size::(self.data_type())?; // in retrieve_chunk_elements_if_exists let shape = self @@ -226,7 +226,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result>, ArrayError> { - self.retrieve_chunk_ndarray_if_exists_opt(chunk_indices, &DecodeOptions::default()) + self.retrieve_chunk_ndarray_if_exists_opt(chunk_indices, &CodecOptions::default()) } #[cfg(feature = "ndarray")] @@ -245,7 +245,7 @@ impl Array { pub fn retrieve_chunk_ndarray_opt( &self, chunk_indices: &[u64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { // validate_element_size::(self.data_type())?; // in retrieve_chunk_elements let shape = self @@ -265,7 +265,7 @@ impl Array { &self, chunk_indices: &[u64], ) -> Result, ArrayError> { - self.retrieve_chunk_ndarray_opt(chunk_indices, &DecodeOptions::default()) + self.retrieve_chunk_ndarray_opt(chunk_indices, &CodecOptions::default()) } /// Retrieve a chunk and output into an existing array. @@ -280,7 +280,7 @@ impl Array { &self, chunk_indices: &[u64], array_view: &ArrayView, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let chunk_representation = self.chunk_array_representation(chunk_indices)?; let chunk_shape_u64 = chunk_representation.shape_u64(); @@ -344,11 +344,7 @@ impl Array { chunk_indices: &[u64], array_view: &ArrayView, ) -> Result<(), ArrayError> { - self.retrieve_chunk_into_array_view_opt( - chunk_indices, - array_view, - &DecodeOptions::default(), - ) + self.retrieve_chunk_into_array_view_opt(chunk_indices, array_view, &CodecOptions::default()) } /// Retrieve a subset of a chunk and output into an existing array. @@ -364,7 +360,7 @@ impl Array { chunk_indices: &[u64], chunk_subset: &ArraySubset, array_view: &ArrayView, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { if chunk_subset.shape() != array_view.subset().shape() { return Err(ArrayError::InvalidArraySubset( @@ -405,7 +401,7 @@ impl Array { chunk_indices, chunk_subset, array_view, - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -422,7 +418,7 @@ impl Array { pub fn retrieve_chunks_opt( &self, chunks: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { if chunks.dimensionality() != self.dimensionality() { return Err(ArrayError::InvalidArraySubset( @@ -502,7 +498,7 @@ impl Array { /// # Panics /// See [`Array::retrieve_chunks_opt`]. pub fn retrieve_chunks(&self, chunks: &ArraySubset) -> Result, ArrayError> { - self.retrieve_chunks_opt(chunks, &DecodeOptions::default()) + self.retrieve_chunks_opt(chunks, &CodecOptions::default()) } /// Read and decode the chunks at `chunks` into a vector of its elements. @@ -515,7 +511,7 @@ impl Array { pub fn retrieve_chunks_elements_opt( &self, chunks: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self.retrieve_chunks_opt(chunks, options)?; @@ -532,7 +528,7 @@ impl Array { &self, chunks: &ArraySubset, ) -> Result, ArrayError> { - self.retrieve_chunks_elements_opt(chunks, &DecodeOptions::default()) + self.retrieve_chunks_elements_opt(chunks, &CodecOptions::default()) } #[cfg(feature = "ndarray")] @@ -546,7 +542,7 @@ impl Array { pub fn retrieve_chunks_ndarray_opt( &self, chunks: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { // validate_element_size::(self.data_type())?; // in retrieve_chunks_elements_opt let array_subset = self.chunks_subset(chunks)?; @@ -565,7 +561,7 @@ impl Array { &self, chunks: &ArraySubset, ) -> Result, ArrayError> { - self.retrieve_chunks_ndarray_opt(chunks, &DecodeOptions::default()) + self.retrieve_chunks_ndarray_opt(chunks, &CodecOptions::default()) } /// Read and decode the `array_subset` of array into its bytes. @@ -584,7 +580,7 @@ impl Array { pub fn retrieve_array_subset_opt( &self, array_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { if array_subset.dimensionality() != self.dimensionality() { return Err(ArrayError::InvalidArraySubset( @@ -695,7 +691,7 @@ impl Array { &self, array_subset: &ArraySubset, array_view: &ArrayView, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { if array_subset.shape() != array_view.subset().shape() { return Err(ArrayError::InvalidArraySubset( @@ -803,7 +799,7 @@ impl Array { self.retrieve_array_subset_into_array_view_opt( array_subset, array_view, - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -814,7 +810,7 @@ impl Array { /// # Panics /// See [`Array::retrieve_array_subset_opt`]. pub fn retrieve_array_subset(&self, array_subset: &ArraySubset) -> Result, ArrayError> { - self.retrieve_array_subset_opt(array_subset, &DecodeOptions::default()) + self.retrieve_array_subset_opt(array_subset, &CodecOptions::default()) } /// Read and decode the `array_subset` of array into a vector of its elements. @@ -829,7 +825,7 @@ impl Array { pub fn retrieve_array_subset_elements_opt( &self, array_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self.retrieve_array_subset_opt(array_subset, options)?; @@ -846,7 +842,7 @@ impl Array { &self, array_subset: &ArraySubset, ) -> Result, ArrayError> { - self.retrieve_array_subset_elements_opt(array_subset, &DecodeOptions::default()) + self.retrieve_array_subset_elements_opt(array_subset, &CodecOptions::default()) } #[cfg(feature = "ndarray")] @@ -863,7 +859,7 @@ impl Array { pub fn retrieve_array_subset_ndarray_opt( &self, array_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { // validate_element_size::(self.data_type())?; // in retrieve_array_subset_elements_opt let elements = self.retrieve_array_subset_elements_opt::(array_subset, options)?; @@ -881,7 +877,7 @@ impl Array { &self, array_subset: &ArraySubset, ) -> Result, ArrayError> { - self.retrieve_array_subset_ndarray_opt(array_subset, &DecodeOptions::default()) + self.retrieve_array_subset_ndarray_opt(array_subset, &CodecOptions::default()) } /// Read and decode the `chunk_subset` of the chunk at `chunk_indices` into its bytes. @@ -899,7 +895,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { let chunk_representation = self.chunk_array_representation(chunk_indices)?; if !chunk_subset.inbounds(&chunk_representation.shape_u64()) { @@ -950,7 +946,7 @@ impl Array { chunk_indices: &[u64], chunk_subset: &ArraySubset, ) -> Result, ArrayError> { - self.retrieve_chunk_subset_opt(chunk_indices, chunk_subset, &DecodeOptions::default()) + self.retrieve_chunk_subset_opt(chunk_indices, chunk_subset, &CodecOptions::default()) } /// Read and decode the `chunk_subset` of the chunk at `chunk_indices` into its elements. @@ -965,7 +961,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { validate_element_size::(self.data_type())?; let bytes = self.retrieve_chunk_subset_opt(chunk_indices, chunk_subset, options)?; @@ -982,7 +978,7 @@ impl Array { self.retrieve_chunk_subset_elements_opt( chunk_indices, chunk_subset, - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -1002,7 +998,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_subset: &ArraySubset, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, ArrayError> { // validate_element_size::(self.data_type())?; // in retrieve_chunk_subset_elements let elements = @@ -1021,7 +1017,7 @@ impl Array { self.retrieve_chunk_subset_ndarray_opt( chunk_indices, chunk_subset, - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -1032,7 +1028,7 @@ impl Array { pub fn partial_decoder_opt<'a>( &'a self, chunk_indices: &[u64], - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, ArrayError> { let storage_handle = Arc::new(StorageHandle::new(self.storage.clone())); let storage_transformer = self @@ -1056,6 +1052,6 @@ impl Array { &'a self, chunk_indices: &[u64], ) -> Result, ArrayError> { - self.partial_decoder_opt(chunk_indices, &PartialDecoderOptions::default()) + self.partial_decoder_opt(chunk_indices, &CodecOptions::default()) } } diff --git a/src/array/array_sync_readable_writable.rs b/src/array/array_sync_readable_writable.rs index cb3e0b45..c18a777f 100644 --- a/src/array/array_sync_readable_writable.rs +++ b/src/array/array_sync_readable_writable.rs @@ -6,9 +6,7 @@ use crate::{ }; use super::{ - codec::{DecodeOptions, EncodeOptions}, - concurrency::concurrency_chunks_and_codec, - Array, ArrayError, + codec::options::CodecOptions, concurrency::concurrency_chunks_and_codec, Array, ArrayError, }; impl Array { @@ -28,8 +26,7 @@ impl Array &self, array_subset: &ArraySubset, subset_bytes: Vec, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { // Validation if array_subset.dimensionality() != self.shape().len() { @@ -65,7 +62,7 @@ impl Array if array_subset == &chunk_subset_in_array { // A fast path if the array subset matches the chunk subset // This skips the internal decoding occurring in store_chunk_subset - self.store_chunk_opt(chunk_indices, subset_bytes, encode_options)?; + self.store_chunk_opt(chunk_indices, subset_bytes, options)?; } else { let overlap = unsafe { array_subset.overlap_unchecked(&chunk_subset_in_array) }; let chunk_subset_in_array_subset = @@ -86,8 +83,7 @@ impl Array chunk_indices, &array_subset_in_chunk_subset, chunk_subset_bytes, - encode_options, - decode_options, + options, )?; } } else { @@ -96,7 +92,7 @@ impl Array self.chunk_array_representation(&vec![0; self.dimensionality()])?; let codec_concurrency = self.recommended_codec_concurrency(&chunk_representation)?; let (chunk_concurrent_limit, options) = concurrency_chunks_and_codec( - encode_options.concurrent_target(), + options.concurrent_target(), num_chunks, &codec_concurrency, ); @@ -127,7 +123,6 @@ impl Array &array_subset_in_chunk_subset, chunk_subset_bytes, &options, - &options, )?; Ok(()) @@ -153,12 +148,7 @@ impl Array array_subset: &ArraySubset, subset_bytes: Vec, ) -> Result<(), ArrayError> { - self.store_array_subset_opt( - array_subset, - subset_bytes, - &EncodeOptions::default(), - &DecodeOptions::default(), - ) + self.store_array_subset_opt(array_subset, subset_bytes, &CodecOptions::default()) } /// Encode `subset_elements` and store in `array_subset`. @@ -173,18 +163,12 @@ impl Array &self, array_subset: &ArraySubset, subset_elements: Vec, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_store_elements!( self, subset_elements, - store_array_subset_opt( - array_subset, - subset_elements, - encode_options, - decode_options - ) + store_array_subset_opt(array_subset, subset_elements, options) ) } @@ -198,8 +182,7 @@ impl Array self.store_array_subset_elements_opt( array_subset, subset_elements, - &EncodeOptions::default(), - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -213,8 +196,7 @@ impl Array &self, subset_start: &[u64], subset_array: &ndarray::ArrayViewD, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let subset = ArraySubset::new_with_start_shape( subset_start.to_vec(), @@ -223,7 +205,7 @@ impl Array array_store_ndarray!( self, subset_array, - store_array_subset_elements_opt(&subset, subset_array, encode_options, decode_options) + store_array_subset_elements_opt(&subset, subset_array, options) ) } @@ -235,12 +217,7 @@ impl Array subset_start: &[u64], subset_array: &ndarray::ArrayViewD, ) -> Result<(), ArrayError> { - self.store_array_subset_ndarray_opt( - subset_start, - subset_array, - &EncodeOptions::default(), - &DecodeOptions::default(), - ) + self.store_array_subset_ndarray_opt(subset_start, subset_array, &CodecOptions::default()) } /// Encode `chunk_subset_bytes` and store in `chunk_subset` of the chunk at `chunk_indices`. @@ -260,8 +237,7 @@ impl Array chunk_indices: &[u64], chunk_subset: &ArraySubset, chunk_subset_bytes: Vec, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let chunk_shape = self .chunk_grid() @@ -289,7 +265,7 @@ impl Array if chunk_subset.shape() == chunk_shape && chunk_subset.start().iter().all(|&x| x == 0) { // The subset spans the whole chunk, so store the bytes directly and skip decoding - self.store_chunk_opt(chunk_indices, chunk_subset_bytes, encode_options) + self.store_chunk_opt(chunk_indices, chunk_subset_bytes, options) } else { // Lock the chunk let key = data_key(self.path(), chunk_indices, self.chunk_key_encoding()); @@ -297,7 +273,7 @@ impl Array let _lock = mutex.lock(); // Decode the entire chunk - let mut chunk_bytes = self.retrieve_chunk_opt(chunk_indices, decode_options)?; + let mut chunk_bytes = self.retrieve_chunk_opt(chunk_indices, options)?; // Update the intersecting subset of the chunk let element_size = self.data_type().size() as u64; @@ -316,7 +292,7 @@ impl Array } // Store the updated chunk - self.store_chunk_opt(chunk_indices, chunk_bytes, encode_options) + self.store_chunk_opt(chunk_indices, chunk_bytes, options) } } @@ -332,8 +308,7 @@ impl Array chunk_indices, chunk_subset, chunk_subset_bytes, - &EncodeOptions::default(), - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -350,19 +325,12 @@ impl Array chunk_indices: &[u64], chunk_subset: &ArraySubset, chunk_subset_elements: Vec, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_store_elements!( self, chunk_subset_elements, - store_chunk_subset_opt( - chunk_indices, - chunk_subset, - chunk_subset_elements, - encode_options, - decode_options - ) + store_chunk_subset_opt(chunk_indices, chunk_subset, chunk_subset_elements, options) ) } @@ -378,8 +346,7 @@ impl Array chunk_indices, chunk_subset, chunk_subset_elements, - &EncodeOptions::default(), - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -396,8 +363,7 @@ impl Array chunk_indices: &[u64], chunk_subset_start: &[u64], chunk_subset_array: &ndarray::ArrayViewD, - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let subset = ArraySubset::new_with_start_shape( chunk_subset_start.to_vec(), @@ -410,13 +376,7 @@ impl Array array_store_ndarray!( self, chunk_subset_array, - store_chunk_subset_elements_opt( - chunk_indices, - &subset, - chunk_subset_array, - encode_options, - decode_options - ) + store_chunk_subset_elements_opt(chunk_indices, &subset, chunk_subset_array, options) ) } @@ -433,8 +393,7 @@ impl Array chunk_indices, chunk_subset_start, chunk_subset_array, - &EncodeOptions::default(), - &DecodeOptions::default(), + &CodecOptions::default(), ) } } diff --git a/src/array/array_sync_writable.rs b/src/array/array_sync_writable.rs index 3d383286..b4b73cb2 100644 --- a/src/array/array_sync_writable.rs +++ b/src/array/array_sync_writable.rs @@ -9,7 +9,7 @@ use crate::{ }; use super::{ - codec::{ArrayCodecTraits, EncodeOptions}, + codec::{options::CodecOptions, ArrayCodecTraits}, concurrency::concurrency_chunks_and_codec, Array, ArrayError, }; @@ -41,7 +41,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_bytes: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { // Validation let chunk_array_representation = self.chunk_array_representation(chunk_indices)?; @@ -83,7 +83,7 @@ impl Array { chunk_indices: &[u64], chunk_bytes: Vec, ) -> Result<(), ArrayError> { - self.store_chunk_opt(chunk_indices, chunk_bytes, &EncodeOptions::default()) + self.store_chunk_opt(chunk_indices, chunk_bytes, &CodecOptions::default()) } /// Encode `chunk_elements` and store at `chunk_indices`. @@ -98,7 +98,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_elements: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_store_elements!( self, @@ -114,7 +114,7 @@ impl Array { chunk_indices: &[u64], chunk_elements: Vec, ) -> Result<(), ArrayError> { - self.store_chunk_elements_opt(chunk_indices, chunk_elements, &EncodeOptions::default()) + self.store_chunk_elements_opt(chunk_indices, chunk_elements, &CodecOptions::default()) } #[cfg(feature = "ndarray")] @@ -129,7 +129,7 @@ impl Array { &self, chunk_indices: &[u64], chunk_array: &ndarray::ArrayViewD, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_store_ndarray!( self, @@ -146,7 +146,7 @@ impl Array { chunk_indices: &[u64], chunk_array: &ndarray::ArrayViewD, ) -> Result<(), ArrayError> { - self.store_chunk_ndarray_opt(chunk_indices, chunk_array, &EncodeOptions::default()) + self.store_chunk_ndarray_opt(chunk_indices, chunk_array, &CodecOptions::default()) } /// Encode `chunks_bytes` and store at the chunks with indices represented by the `chunks` array subset. @@ -164,7 +164,7 @@ impl Array { &self, chunks: &ArraySubset, chunks_bytes: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { let num_chunks = chunks.num_elements_usize(); match num_chunks { @@ -246,7 +246,7 @@ impl Array { chunks: &ArraySubset, chunks_bytes: Vec, ) -> Result<(), ArrayError> { - self.store_chunks_opt(chunks, chunks_bytes, &EncodeOptions::default()) + self.store_chunks_opt(chunks, chunks_bytes, &CodecOptions::default()) } /// Variation of [`Array::store_chunks_opt`] for elements with a known type. @@ -257,7 +257,7 @@ impl Array { &self, chunks: &ArraySubset, chunks_elements: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_store_elements!( self, @@ -273,7 +273,7 @@ impl Array { chunks: &ArraySubset, chunks_elements: Vec, ) -> Result<(), ArrayError> { - self.store_chunks_elements_opt(chunks, chunks_elements, &EncodeOptions::default()) + self.store_chunks_elements_opt(chunks, chunks_elements, &CodecOptions::default()) } #[cfg(feature = "ndarray")] @@ -285,7 +285,7 @@ impl Array { &self, chunks: &ArraySubset, chunks_array: &ndarray::ArrayViewD<'_, T>, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result<(), ArrayError> { array_store_ndarray!( self, @@ -302,7 +302,7 @@ impl Array { chunks: &ArraySubset, chunks_array: &ndarray::ArrayViewD<'_, T>, ) -> Result<(), ArrayError> { - self.store_chunks_ndarray_opt(chunks, chunks_array, &EncodeOptions::default()) + self.store_chunks_ndarray_opt(chunks, chunks_array, &CodecOptions::default()) } /// Erase the chunk at `chunk_indices`. diff --git a/src/array/codec.rs b/src/array/codec.rs index 6d41664e..4a172d6f 100644 --- a/src/array/codec.rs +++ b/src/array/codec.rs @@ -15,7 +15,7 @@ pub mod array_to_bytes; pub mod bytes_to_bytes; pub mod options; -pub use options::{DecodeOptions, EncodeOptions, PartialDecodeOptions, PartialDecoderOptions}; +pub use options::{CodecOptions, CodecOptionsBuilder}; // Array to array #[cfg(feature = "bitround")] @@ -203,7 +203,7 @@ pub trait ArrayCodecTraits: CodecTraits { &self, decoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError>; /// Encode a chunk (default options). @@ -218,7 +218,7 @@ pub trait ArrayCodecTraits: CodecTraits { self.encode_opt( decoded_value, decoded_representation, - &EncodeOptions::default(), + &CodecOptions::default(), ) } @@ -233,7 +233,7 @@ pub trait ArrayCodecTraits: CodecTraits { &self, decoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { self.encode_opt(decoded_value, decoded_representation, options) } @@ -246,7 +246,7 @@ pub trait ArrayCodecTraits: CodecTraits { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError>; /// Decode a chunk (default options). @@ -261,7 +261,7 @@ pub trait ArrayCodecTraits: CodecTraits { self.decode_opt( encoded_value, decoded_representation, - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -276,7 +276,7 @@ pub trait ArrayCodecTraits: CodecTraits { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { self.decode_opt(encoded_value, decoded_representation, options) } @@ -293,7 +293,7 @@ pub trait ArrayCodecTraits: CodecTraits { encoded_value: &[u8], decoded_representation: &ChunkRepresentation, array_view: &ArrayView, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), CodecError> { let decoded_bytes = self.decode_opt(encoded_value.to_vec(), decoded_representation, options)?; @@ -331,7 +331,7 @@ pub trait BytesPartialDecoderTraits: Send + Sync { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError>; /// Decode all bytes. @@ -340,7 +340,7 @@ pub trait BytesPartialDecoderTraits: Send + Sync { /// /// # Errors /// Returns [`CodecError`] if a codec fails. - fn decode_opt(&self, options: &PartialDecodeOptions) -> Result { + fn decode_opt(&self, options: &CodecOptions) -> Result { Ok(self .partial_decode_opt(&[ByteRange::FromStart(0, None)], options)? .map(|mut v| v.remove(0))) @@ -356,7 +356,7 @@ pub trait BytesPartialDecoderTraits: Send + Sync { &self, byte_ranges: &[ByteRange], ) -> Result>>, CodecError> { - self.partial_decode_opt(byte_ranges, &PartialDecodeOptions::default()) + self.partial_decode_opt(byte_ranges, &CodecOptions::default()) } /// Decode all bytes (default options). @@ -366,7 +366,7 @@ pub trait BytesPartialDecoderTraits: Send + Sync { /// # Errors /// Returns [`CodecError`] if a codec fails. fn decode(&self) -> Result { - self.decode_opt(&PartialDecodeOptions::default()) + self.decode_opt(&CodecOptions::default()) } } @@ -383,7 +383,7 @@ pub trait AsyncBytesPartialDecoderTraits: Send + Sync { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError>; /// Decode all bytes. @@ -392,7 +392,7 @@ pub trait AsyncBytesPartialDecoderTraits: Send + Sync { /// /// # Errors /// Returns [`CodecError`] if a codec fails. - async fn decode_opt(&self, options: &PartialDecodeOptions) -> Result { + async fn decode_opt(&self, options: &CodecOptions) -> Result { Ok(self .partial_decode_opt(&[ByteRange::FromStart(0, None)], options) .await? @@ -409,7 +409,7 @@ pub trait AsyncBytesPartialDecoderTraits: Send + Sync { &self, byte_ranges: &[ByteRange], ) -> Result>>, CodecError> { - self.partial_decode_opt(byte_ranges, &PartialDecodeOptions::default()) + self.partial_decode_opt(byte_ranges, &CodecOptions::default()) .await } @@ -420,7 +420,7 @@ pub trait AsyncBytesPartialDecoderTraits: Send + Sync { /// # Errors /// Returns [`CodecError`] if a codec fails. async fn decode(&self) -> Result { - self.decode_opt(&PartialDecodeOptions::default()).await + self.decode_opt(&CodecOptions::default()).await } } @@ -438,7 +438,7 @@ pub trait ArrayPartialDecoderTraits: Send + Sync { fn partial_decode_opt( &self, array_subsets: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError>; /// Partially decode a chunk (default options). @@ -448,7 +448,7 @@ pub trait ArrayPartialDecoderTraits: Send + Sync { /// # Errors /// Returns [`CodecError`] if a codec fails or an array subset is invalid. fn partial_decode(&self, array_subsets: &[ArraySubset]) -> Result>, CodecError> { - self.partial_decode_opt(array_subsets, &PartialDecodeOptions::default()) + self.partial_decode_opt(array_subsets, &CodecOptions::default()) } /// Partially decode a subset of an array into an array view. @@ -460,7 +460,7 @@ pub trait ArrayPartialDecoderTraits: Send + Sync { &self, array_subset: &ArraySubset, array_view: &ArrayView, - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result<(), CodecError> { if array_subset.shape() != array_view.subset().shape() { return Err(CodecError::InvalidArraySubsetError( @@ -504,11 +504,7 @@ pub trait ArrayPartialDecoderTraits: Send + Sync { array_subset: &ArraySubset, array_view: &ArrayView, ) -> Result<(), CodecError> { - self.partial_decode_into_array_view_opt( - array_subset, - array_view, - &PartialDecodeOptions::default(), - ) + self.partial_decode_into_array_view_opt(array_subset, array_view, &CodecOptions::default()) } } @@ -525,7 +521,7 @@ pub trait AsyncArrayPartialDecoderTraits: Send + Sync { async fn partial_decode_opt( &self, array_subsets: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError>; /// Partially decode a chunk (default options). @@ -539,7 +535,7 @@ pub trait AsyncArrayPartialDecoderTraits: Send + Sync { &self, array_subsets: &[ArraySubset], ) -> Result>, CodecError> { - self.partial_decode_opt(array_subsets, &PartialDecodeOptions::default()) + self.partial_decode_opt(array_subsets, &CodecOptions::default()) .await } } @@ -561,7 +557,7 @@ impl BytesPartialDecoderTraits for StoragePartialDecoder { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - _options: &PartialDecodeOptions, + _options: &CodecOptions, ) -> Result>>, CodecError> { Ok(self .storage @@ -590,7 +586,7 @@ impl AsyncBytesPartialDecoderTraits for AsyncStoragePartialDecoder { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - _options: &PartialDecodeOptions, + _options: &CodecOptions, ) -> Result>>, CodecError> { Ok(self .storage @@ -625,7 +621,7 @@ pub trait ArrayToArrayCodecTraits: &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError>; /// Initialise a partial decoder (default options). @@ -640,7 +636,7 @@ pub trait ArrayToArrayCodecTraits: self.partial_decoder_opt( input_handle, decoded_representation, - &PartialDecoderOptions::default(), + &CodecOptions::default(), ) } @@ -656,7 +652,7 @@ pub trait ArrayToArrayCodecTraits: &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError>; #[cfg(feature = "async")] @@ -672,7 +668,7 @@ pub trait ArrayToArrayCodecTraits: self.async_partial_decoder_opt( input_handle, decoded_representation, - &PartialDecoderOptions::default(), + &CodecOptions::default(), ) .await } @@ -702,7 +698,7 @@ pub trait ArrayToBytesCodecTraits: &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError>; #[cfg(feature = "async")] @@ -714,7 +710,7 @@ pub trait ArrayToBytesCodecTraits: &'a self, mut input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError>; /// Initialise a partial decoder (default options). @@ -729,7 +725,7 @@ pub trait ArrayToBytesCodecTraits: self.partial_decoder_opt( input_handle, decoded_representation, - &PartialDecoderOptions::default(), + &CodecOptions::default(), ) } @@ -746,7 +742,7 @@ pub trait ArrayToBytesCodecTraits: self.async_partial_decoder_opt( input_handle, decoded_representation, - &PartialDecoderOptions::default(), + &CodecOptions::default(), ) .await } @@ -779,7 +775,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt fn encode_opt( &self, decoded_value: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError>; /// Encode chunk bytes (default options). @@ -787,7 +783,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt /// # Errors /// Returns [`CodecError`] if a codec fails. fn encode(&self, decoded_value: Vec) -> Result, CodecError> { - self.encode_opt(decoded_value, &EncodeOptions::default()) + self.encode_opt(decoded_value, &CodecOptions::default()) } /// Decode chunk bytes. @@ -798,7 +794,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt &self, encoded_value: Vec, decoded_representation: &BytesRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError>; /// Decode bytes (default options). @@ -813,7 +809,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt self.decode_opt( encoded_value, decoded_representation, - &DecodeOptions::default(), + &CodecOptions::default(), ) } @@ -825,7 +821,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt &'a self, input_handle: Box, decoded_representation: &BytesRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError>; /// Initialises a partial decoder (default options). @@ -840,7 +836,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt self.partial_decoder_opt( input_handle, decoded_representation, - &PartialDecodeOptions::default(), + &CodecOptions::default(), ) } @@ -854,7 +850,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt async fn async_encode_opt( &self, decoded_value: Vec, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { self.encode_opt(decoded_value, options) } @@ -867,7 +863,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt /// # Errors /// Returns [`CodecError`] if a codec fails. async fn async_encode(&self, decoded_value: Vec) -> Result, CodecError> { - self.async_encode_opt(decoded_value, &EncodeOptions::default()) + self.async_encode_opt(decoded_value, &CodecOptions::default()) .await } @@ -882,7 +878,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt &self, encoded_value: Vec, decoded_representation: &BytesRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { self.decode_opt(encoded_value, decoded_representation, options) } @@ -902,7 +898,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt self.async_decode_opt( encoded_value, decoded_representation, - &DecodeOptions::default(), + &CodecOptions::default(), ) .await } @@ -916,7 +912,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt &'a self, input_handle: Box, decoded_representation: &BytesRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError>; #[cfg(feature = "async")] @@ -932,7 +928,7 @@ pub trait BytesToBytesCodecTraits: CodecTraits + dyn_clone::DynClone + core::fmt self.async_partial_decoder_opt( input_handle, decoded_representation, - &PartialDecoderOptions::default(), + &CodecOptions::default(), ) .await } @@ -944,7 +940,7 @@ impl BytesPartialDecoderTraits for std::io::Cursor<&[u8]> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - _parallel: &PartialDecodeOptions, + _parallel: &CodecOptions, ) -> Result>>, CodecError> { Ok(Some(extract_byte_ranges_read_seek( &mut self.clone(), @@ -957,7 +953,7 @@ impl BytesPartialDecoderTraits for std::io::Cursor> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - _parallel: &PartialDecodeOptions, + _parallel: &CodecOptions, ) -> Result>>, CodecError> { Ok(Some(extract_byte_ranges_read_seek( &mut self.clone(), @@ -972,7 +968,7 @@ impl AsyncBytesPartialDecoderTraits for std::io::Cursor<&[u8]> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - _parallel: &PartialDecodeOptions, + _parallel: &CodecOptions, ) -> Result>>, CodecError> { Ok(Some(extract_byte_ranges_read_seek( &mut self.clone(), @@ -987,7 +983,7 @@ impl AsyncBytesPartialDecoderTraits for std::io::Cursor> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - _parallel: &PartialDecodeOptions, + _parallel: &CodecOptions, ) -> Result>>, CodecError> { Ok(Some(extract_byte_ranges_read_seek( &mut self.clone(), diff --git a/src/array/codec/array_to_array/bitround/bitround_codec.rs b/src/array/codec/array_to_array/bitround/bitround_codec.rs index d0e8c9dd..718c294e 100644 --- a/src/array/codec/array_to_array/bitround/bitround_codec.rs +++ b/src/array/codec/array_to_array/bitround/bitround_codec.rs @@ -1,9 +1,8 @@ use crate::{ array::{ codec::{ - ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToArrayCodecTraits, CodecError, - CodecTraits, DecodeOptions, EncodeOptions, PartialDecoderOptions, - RecommendedConcurrency, + options::CodecOptions, ArrayCodecTraits, ArrayPartialDecoderTraits, + ArrayToArrayCodecTraits, CodecError, CodecTraits, RecommendedConcurrency, }, ChunkRepresentation, DataType, }, @@ -73,7 +72,7 @@ impl ArrayCodecTraits for BitroundCodec { &self, mut decoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { round_bytes( &mut decoded_value, @@ -87,7 +86,7 @@ impl ArrayCodecTraits for BitroundCodec { &self, encoded_value: Vec, _decoded_representation: &ChunkRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(encoded_value) } @@ -99,7 +98,7 @@ impl ArrayToArrayCodecTraits for BitroundCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( bitround_partial_decoder::BitroundPartialDecoder::new( @@ -115,7 +114,7 @@ impl ArrayToArrayCodecTraits for BitroundCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( bitround_partial_decoder::AsyncBitroundPartialDecoder::new( diff --git a/src/array/codec/array_to_array/bitround/bitround_partial_decoder.rs b/src/array/codec/array_to_array/bitround/bitround_partial_decoder.rs index 8f86e41b..26c2eefa 100644 --- a/src/array/codec/array_to_array/bitround/bitround_partial_decoder.rs +++ b/src/array/codec/array_to_array/bitround/bitround_partial_decoder.rs @@ -1,6 +1,6 @@ use crate::{ array::{ - codec::{ArrayPartialDecoderTraits, CodecError, PartialDecodeOptions}, + codec::{ArrayPartialDecoderTraits, CodecError, CodecOptions}, DataType, }, array_subset::ArraySubset, @@ -58,7 +58,7 @@ impl ArrayPartialDecoderTraits for BitroundPartialDecoder<'_> { fn partial_decode_opt( &self, array_subsets: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let mut bytes = self .input_handle @@ -119,7 +119,7 @@ impl AsyncArrayPartialDecoderTraits for AsyncBitroundPartialDecoder<'_> { async fn partial_decode_opt( &self, array_subsets: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let mut bytes = self .input_handle diff --git a/src/array/codec/array_to_array/transpose/transpose_codec.rs b/src/array/codec/array_to_array/transpose/transpose_codec.rs index 18fb7bd3..38bcb0af 100644 --- a/src/array/codec/array_to_array/transpose/transpose_codec.rs +++ b/src/array/codec/array_to_array/transpose/transpose_codec.rs @@ -4,9 +4,8 @@ use thiserror::Error; use crate::{ array::{ codec::{ - ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToArrayCodecTraits, CodecError, - CodecTraits, DecodeOptions, EncodeOptions, PartialDecoderOptions, - RecommendedConcurrency, + options::CodecOptions, ArrayCodecTraits, ArrayPartialDecoderTraits, + ArrayToArrayCodecTraits, CodecError, CodecTraits, RecommendedConcurrency, }, ChunkRepresentation, }, @@ -77,7 +76,7 @@ impl ArrayToArrayCodecTraits for TransposeCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( super::transpose_partial_decoder::TransposePartialDecoder::new( @@ -93,7 +92,7 @@ impl ArrayToArrayCodecTraits for TransposeCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( super::transpose_partial_decoder::AsyncTransposePartialDecoder::new( @@ -133,7 +132,7 @@ impl ArrayCodecTraits for TransposeCodec { &self, decoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { if decoded_value.len() as u64 != decoded_representation.size() { return Err(CodecError::UnexpectedChunkDecodedSize( @@ -162,7 +161,7 @@ impl ArrayCodecTraits for TransposeCodec { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let order_decode = calculate_order_decode(&self.order, decoded_representation.shape().len()); diff --git a/src/array/codec/array_to_array/transpose/transpose_partial_decoder.rs b/src/array/codec/array_to_array/transpose/transpose_partial_decoder.rs index 8b0ed40e..908ef10c 100644 --- a/src/array/codec/array_to_array/transpose/transpose_partial_decoder.rs +++ b/src/array/codec/array_to_array/transpose/transpose_partial_decoder.rs @@ -1,6 +1,6 @@ use super::{calculate_order_decode, permute, transpose_array, TransposeOrder}; use crate::array::{ - codec::{ArrayPartialDecoderTraits, ArraySubset, CodecError, PartialDecodeOptions}, + codec::{ArrayPartialDecoderTraits, ArraySubset, CodecError, CodecOptions}, ChunkRepresentation, }; @@ -37,7 +37,7 @@ impl ArrayPartialDecoderTraits for TransposePartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { for array_subset in decoded_regions { if array_subset.dimensionality() != self.decoded_representation.dimensionality() { @@ -112,7 +112,7 @@ impl AsyncArrayPartialDecoderTraits for AsyncTransposePartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { // Get transposed array subsets let mut decoded_regions_transposed = Vec::with_capacity(decoded_regions.len()); diff --git a/src/array/codec/array_to_bytes/bytes/bytes_codec.rs b/src/array/codec/array_to_bytes/bytes/bytes_codec.rs index 37fe2645..b268369f 100644 --- a/src/array/codec/array_to_bytes/bytes/bytes_codec.rs +++ b/src/array/codec/array_to_bytes/bytes/bytes_codec.rs @@ -4,8 +4,8 @@ use crate::{ array::{ codec::{ ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToBytesCodecTraits, - BytesPartialDecoderTraits, CodecError, CodecTraits, DecodeOptions, EncodeOptions, - PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, CodecError, CodecOptions, CodecTraits, + RecommendedConcurrency, }, BytesRepresentation, ChunkRepresentation, }, @@ -129,7 +129,7 @@ impl ArrayCodecTraits for BytesCodec { &self, decoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { self.do_encode_or_decode(decoded_value, decoded_representation) } @@ -138,7 +138,7 @@ impl ArrayCodecTraits for BytesCodec { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { self.do_encode_or_decode(encoded_value, decoded_representation) } @@ -150,7 +150,7 @@ impl ArrayToBytesCodecTraits for BytesCodec { &self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(bytes_partial_decoder::BytesPartialDecoder::new( input_handle, @@ -164,7 +164,7 @@ impl ArrayToBytesCodecTraits for BytesCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( bytes_partial_decoder::AsyncBytesPartialDecoder::new( diff --git a/src/array/codec/array_to_bytes/bytes/bytes_partial_decoder.rs b/src/array/codec/array_to_bytes/bytes/bytes_partial_decoder.rs index 62600934..e54627ce 100644 --- a/src/array/codec/array_to_bytes/bytes/bytes_partial_decoder.rs +++ b/src/array/codec/array_to_bytes/bytes/bytes_partial_decoder.rs @@ -2,7 +2,7 @@ use crate::{ array::{ codec::{ ArrayPartialDecoderTraits, ArraySubset, BytesPartialDecoderTraits, CodecError, - PartialDecodeOptions, + CodecOptions, }, ChunkRepresentation, }, @@ -44,7 +44,7 @@ impl ArrayPartialDecoderTraits for BytesPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let mut bytes = Vec::with_capacity(decoded_regions.len()); let chunk_shape = self.decoded_representation.shape_u64(); @@ -122,7 +122,7 @@ impl AsyncArrayPartialDecoderTraits for AsyncBytesPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let mut bytes = Vec::with_capacity(decoded_regions.len()); let chunk_shape = self.decoded_representation.shape_u64(); diff --git a/src/array/codec/array_to_bytes/codec_chain.rs b/src/array/codec/array_to_bytes/codec_chain.rs index f9dc3a95..d356d6bf 100644 --- a/src/array/codec/array_to_bytes/codec_chain.rs +++ b/src/array/codec/array_to_bytes/codec_chain.rs @@ -6,7 +6,7 @@ use crate::{ partial_decoder_cache::{ArrayPartialDecoderCache, BytesPartialDecoderCache}, ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToArrayCodecTraits, ArrayToBytesCodecTraits, BytesPartialDecoderTraits, BytesToBytesCodecTraits, Codec, - CodecError, CodecTraits, DecodeOptions, EncodeOptions, PartialDecoderOptions, + CodecError, CodecOptions, CodecTraits, }, concurrency::RecommendedConcurrency, ArrayView, BytesRepresentation, ChunkRepresentation, @@ -221,7 +221,7 @@ impl ArrayToBytesCodecTraits for CodecChain { &'a self, mut input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError> { let array_representations = self.get_array_representations(decoded_representation.clone())?; @@ -284,7 +284,7 @@ impl ArrayToBytesCodecTraits for CodecChain { &'a self, mut input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError> { let array_representations = self.get_array_representations(decoded_representation.clone())?; @@ -427,7 +427,7 @@ impl ArrayCodecTraits for CodecChain { &self, decoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { if decoded_value.len() as u64 != decoded_representation.size() { return Err(CodecError::UnexpectedChunkDecodedSize( @@ -466,7 +466,7 @@ impl ArrayCodecTraits for CodecChain { &self, mut encoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { let array_representations = self.get_array_representations(decoded_representation.clone())?; @@ -511,7 +511,7 @@ impl ArrayCodecTraits for CodecChain { &self, decoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { if decoded_value.len() as u64 != decoded_representation.size() { return Err(CodecError::UnexpectedChunkDecodedSize( @@ -554,7 +554,7 @@ impl ArrayCodecTraits for CodecChain { &self, mut encoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { let array_representations = self.get_array_representations(decoded_representation.clone())?; @@ -606,7 +606,7 @@ impl ArrayCodecTraits for CodecChain { encoded_value: &[u8], decoded_representation: &ChunkRepresentation, array_view: &ArrayView, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), CodecError> { let array_representations = self.get_array_representations(decoded_representation.clone())?; diff --git a/src/array/codec/array_to_bytes/pcodec/pcodec_codec.rs b/src/array/codec/array_to_bytes/pcodec/pcodec_codec.rs index 5decd0c4..adc6e9a6 100644 --- a/src/array/codec/array_to_bytes/pcodec/pcodec_codec.rs +++ b/src/array/codec/array_to_bytes/pcodec/pcodec_codec.rs @@ -4,8 +4,8 @@ use crate::{ array::{ codec::{ ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToBytesCodecTraits, - BytesPartialDecoderTraits, CodecError, CodecTraits, DecodeOptions, EncodeOptions, - PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, CodecError, CodecOptions, CodecTraits, + RecommendedConcurrency, }, transmute_from_bytes_vec, transmute_to_bytes_vec, BytesRepresentation, ChunkRepresentation, DataType, @@ -100,7 +100,7 @@ impl ArrayCodecTraits for PcodecCodec { &self, decoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let data_type = decoded_representation.data_type(); macro_rules! pcodec_encode { @@ -143,7 +143,7 @@ impl ArrayCodecTraits for PcodecCodec { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let data_type = decoded_representation.data_type(); macro_rules! pcodec_decode { @@ -187,7 +187,7 @@ impl ArrayToBytesCodecTraits for PcodecCodec { &self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(pcodec_partial_decoder::PcodecPartialDecoder::new( input_handle, @@ -200,7 +200,7 @@ impl ArrayToBytesCodecTraits for PcodecCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( pcodec_partial_decoder::AsyncPCodecPartialDecoder::new( diff --git a/src/array/codec/array_to_bytes/pcodec/pcodec_partial_decoder.rs b/src/array/codec/array_to_bytes/pcodec/pcodec_partial_decoder.rs index 1f21323b..11824079 100644 --- a/src/array/codec/array_to_bytes/pcodec/pcodec_partial_decoder.rs +++ b/src/array/codec/array_to_bytes/pcodec/pcodec_partial_decoder.rs @@ -2,7 +2,7 @@ use crate::{ array::{ codec::{ ArrayPartialDecoderTraits, ArraySubset, BytesPartialDecoderTraits, CodecError, - PartialDecodeOptions, + CodecOptions, }, ChunkRepresentation, DataType, }, @@ -112,7 +112,7 @@ impl ArrayPartialDecoderTraits for PcodecPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let decoded = self.input_handle.decode_opt(options)?; do_partial_decode(decoded, decoded_regions, &self.decoded_representation) @@ -146,7 +146,7 @@ impl AsyncArrayPartialDecoderTraits for AsyncPCodecPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { for array_subset in decoded_regions { if array_subset.dimensionality() != self.decoded_representation.dimensionality() { diff --git a/src/array/codec/array_to_bytes/sharding.rs b/src/array/codec/array_to_bytes/sharding.rs index f61ea5fe..d32ad820 100644 --- a/src/array/codec/array_to_bytes/sharding.rs +++ b/src/array/codec/array_to_bytes/sharding.rs @@ -27,7 +27,7 @@ use thiserror::Error; use crate::{ array::{ - codec::{ArrayToBytesCodecTraits, Codec, CodecError, CodecPlugin, DecodeOptions}, + codec::{ArrayToBytesCodecTraits, Codec, CodecError, CodecOptions, CodecPlugin}, BytesRepresentation, ChunkRepresentation, ChunkShape, DataType, FillValue, }, metadata::Metadata, @@ -108,7 +108,7 @@ fn decode_shard_index( encoded_shard_index: Vec, index_array_representation: &ChunkRepresentation, index_codecs: &dyn ArrayToBytesCodecTraits, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { // Decode the shard index let decoded_shard_index = @@ -124,7 +124,7 @@ async fn async_decode_shard_index( encoded_shard_index: Vec, index_array_representation: &ChunkRepresentation, index_codecs: &dyn ArrayToBytesCodecTraits, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { // Decode the shard index let decoded_shard_index = index_codecs @@ -140,9 +140,8 @@ async fn async_decode_shard_index( mod tests { use crate::{ array::codec::{ - bytes_to_bytes::test_unbounded::TestUnboundedCodec, - options::{DecodeOptionsBuilder, EncodeOptionsBuilder}, - ArrayCodecTraits, BytesToBytesCodecTraits, EncodeOptions, PartialDecodeOptions, + bytes_to_bytes::test_unbounded::TestUnboundedCodec, ArrayCodecTraits, + BytesToBytesCodecTraits, CodecOptions, CodecOptionsBuilder, }, array_subset::ArraySubset, config::global_config, @@ -207,8 +206,7 @@ mod tests { }"#; fn codec_sharding_round_trip_impl( - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, unbounded: bool, index_at_end: bool, all_fill_value: bool, @@ -240,10 +238,10 @@ mod tests { .build(); let encoded = codec - .encode_opt(bytes.clone(), &chunk_representation, encode_options) + .encode_opt(bytes.clone(), &chunk_representation, options) .unwrap(); let decoded = codec - .decode_opt(encoded.clone(), &chunk_representation, decode_options) + .decode_opt(encoded.clone(), &chunk_representation, options) .unwrap(); assert_ne!(encoded, decoded); assert_eq!(bytes, decoded); @@ -258,13 +256,10 @@ mod tests { for unbounded in [true, false] { for parallel in [true, false] { let concurrent_target = get_concurrent_target(parallel); - let encode_options = - EncodeOptionsBuilder::new().concurrent_target(concurrent_target); - let decode_options = - DecodeOptionsBuilder::new().concurrent_target(concurrent_target); + let options = + CodecOptionsBuilder::new().concurrent_target(concurrent_target); codec_sharding_round_trip_impl( - &encode_options.build(), - &decode_options.build(), + &options.build(), unbounded, all_fill_value, index_at_end, @@ -289,13 +284,10 @@ mod tests { for unbounded in [true, false] { for parallel in [true, false] { let concurrent_target = get_concurrent_target(parallel); - let encode_options = - EncodeOptionsBuilder::new().concurrent_target(concurrent_target); - let decode_options = - DecodeOptionsBuilder::new().concurrent_target(concurrent_target); + let options = + CodecOptionsBuilder::new().concurrent_target(concurrent_target); codec_sharding_round_trip_impl( - &encode_options.build(), - &decode_options.build(), + &options.build(), unbounded, all_fill_value, index_at_end, @@ -312,8 +304,7 @@ mod tests { #[cfg(feature = "async")] async fn codec_sharding_async_round_trip_impl( - encode_options: &EncodeOptions, - decode_options: &DecodeOptions, + options: &CodecOptions, unbounded: bool, index_at_end: bool, all_fill_value: bool, @@ -345,11 +336,11 @@ mod tests { .build(); let encoded = codec - .async_encode_opt(bytes.clone(), &chunk_representation, encode_options) + .async_encode_opt(bytes.clone(), &chunk_representation, options) .await .unwrap(); let decoded = codec - .async_decode_opt(encoded.clone(), &chunk_representation, decode_options) + .async_decode_opt(encoded.clone(), &chunk_representation, options) .await .unwrap(); assert_ne!(encoded, decoded); @@ -366,13 +357,10 @@ mod tests { for unbounded in [true, false] { for parallel in [true, false] { let concurrent_target = get_concurrent_target(parallel); - let encode_options = - EncodeOptionsBuilder::new().concurrent_target(concurrent_target); - let decode_options = - DecodeOptionsBuilder::new().concurrent_target(concurrent_target); + let options = + CodecOptionsBuilder::new().concurrent_target(concurrent_target); codec_sharding_async_round_trip_impl( - &encode_options.build(), - &decode_options.build(), + &options.build(), unbounded, all_fill_value, index_at_end, @@ -386,7 +374,7 @@ mod tests { } fn codec_sharding_partial_decode( - options: &PartialDecodeOptions, + options: &CodecOptions, unbounded: bool, index_at_end: bool, all_fill_value: bool, @@ -450,10 +438,10 @@ mod tests { for unbounded in [true, false] { for parallel in [true, false] { let concurrent_target = get_concurrent_target(parallel); - let decode_options = - DecodeOptionsBuilder::new().concurrent_target(concurrent_target); + let options = + CodecOptionsBuilder::new().concurrent_target(concurrent_target); codec_sharding_partial_decode( - &decode_options.build(), + &options.build(), unbounded, all_fill_value, index_at_end, @@ -466,7 +454,7 @@ mod tests { #[cfg(feature = "async")] async fn codec_sharding_async_partial_decode( - options: &PartialDecodeOptions, + options: &CodecOptions, unbounded: bool, index_at_end: bool, all_fill_value: bool, @@ -533,10 +521,10 @@ mod tests { for unbounded in [true, false] { for parallel in [true, false] { let concurrent_target = get_concurrent_target(parallel); - let decode_options = - DecodeOptionsBuilder::new().concurrent_target(concurrent_target); + let options = + CodecOptionsBuilder::new().concurrent_target(concurrent_target); codec_sharding_async_partial_decode( - &decode_options.build(), + &options.build(), unbounded, all_fill_value, index_at_end, diff --git a/src/array/codec/array_to_bytes/sharding/sharding_codec.rs b/src/array/codec/array_to_bytes/sharding/sharding_codec.rs index 6fb7ab71..fc370502 100644 --- a/src/array/codec/array_to_bytes/sharding/sharding_codec.rs +++ b/src/array/codec/array_to_bytes/sharding/sharding_codec.rs @@ -4,10 +4,9 @@ use crate::{ array::{ chunk_shape_to_array_shape, codec::{ - options::{DecodeOptionsBuilder, EncodeOptionsBuilder}, ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToBytesCodecTraits, - BytesPartialDecoderTraits, CodecChain, CodecError, CodecTraits, DecodeOptions, - EncodeOptions, PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, CodecChain, CodecError, CodecOptions, CodecOptionsBuilder, + CodecTraits, RecommendedConcurrency, }, concurrency::calc_concurrency_outer_inner, transmute_to_bytes_vec, unravel_index, @@ -120,7 +119,7 @@ impl ArrayCodecTraits for ShardingCodec { &self, decoded_value: Vec, shard_rep: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { if decoded_value.len() as u64 != shard_rep.size() { return Err(CodecError::UnexpectedChunkDecodedSize( @@ -152,7 +151,7 @@ impl ArrayCodecTraits for ShardingCodec { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { // Allocate an array for the output let len = decoded_representation.size_usize(); @@ -181,7 +180,7 @@ impl ArrayCodecTraits for ShardingCodec { &self, decoded_value: Vec, shard_rep: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { if decoded_value.len() as u64 != shard_rep.size() { return Err(CodecError::UnexpectedChunkDecodedSize( @@ -216,7 +215,7 @@ impl ArrayCodecTraits for ShardingCodec { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { let chunks_per_shard = calculate_chunks_per_shard(decoded_representation.shape(), self.chunk_shape.as_slice()) @@ -240,7 +239,7 @@ impl ArrayCodecTraits for ShardingCodec { encoded_shard: &[u8], shard_representation: &ChunkRepresentation, array_view: &ArrayView, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result<(), CodecError> { let chunks_per_shard = calculate_chunks_per_shard(shard_representation.shape(), self.chunk_shape.as_slice()) @@ -278,7 +277,7 @@ impl ArrayCodecTraits for ShardingCodec { .inner_codecs .recommended_concurrency(&chunk_representation)?, ); - let options = DecodeOptionsBuilder::new() + let options = CodecOptionsBuilder::new() .concurrent_target(concurrency_limit_inner_chunks) .build(); // println!("{shard_concurrent_limit} {concurrency_limit_inner_chunks:?}"); // FIXME: log debug? @@ -355,7 +354,7 @@ impl ArrayToBytesCodecTraits for ShardingCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( sharding_partial_decoder::ShardingPartialDecoder::new( @@ -375,7 +374,7 @@ impl ArrayToBytesCodecTraits for ShardingCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( sharding_partial_decoder::AsyncShardingPartialDecoder::new( @@ -466,7 +465,7 @@ impl ShardingCodec { shard_representation: &ChunkRepresentation, chunk_representation: &ChunkRepresentation, chunk_size_bounded: u64, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { debug_assert_eq!(decoded_value.len() as u64, shard_representation.size()); // already validated in par_encode @@ -505,7 +504,7 @@ impl ShardingCodec { .inner_codecs .recommended_concurrency(chunk_representation)?, ); - let options = EncodeOptionsBuilder::new() + let options = CodecOptionsBuilder::new() .concurrent_target(concurrency_limit_inner_chunks) .build(); // println!("{shard_concurrent_limit} {concurrency_limit_inner_chunks:?}"); // FIXME: log debug? @@ -606,7 +605,7 @@ impl ShardingCodec { decoded_value: &[u8], shard_representation: &ChunkRepresentation, chunk_representation: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { debug_assert_eq!(decoded_value.len() as u64, shard_representation.size()); // already validated in par_encode @@ -635,7 +634,7 @@ impl ShardingCodec { .inner_codecs .recommended_concurrency(chunk_representation)?, ); - let options_inner = EncodeOptionsBuilder::new() + let options_inner = CodecOptionsBuilder::new() .concurrent_target(concurrency_limit_inner_chunks) .build(); // println!("{shard_concurrent_limit} {concurrency_limit_inner_chunks:?}"); // FIXME: log debug? @@ -744,7 +743,7 @@ impl ShardingCodec { shard_representation: &ChunkRepresentation, chunk_representation: &ChunkRepresentation, chunk_size_bounded: u64, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { debug_assert_eq!(decoded_value.len() as u64, shard_representation.size()); // already validated in par_encode @@ -886,7 +885,7 @@ impl ShardingCodec { decoded_value: &[u8], shard_representation: &ChunkRepresentation, chunk_representation: &ChunkRepresentation, - options: &EncodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { debug_assert_eq!(decoded_value.len() as u64, shard_representation.size()); // already validated in par_encode @@ -1014,7 +1013,7 @@ impl ShardingCodec { &self, encoded_shard: &[u8], chunks_per_shard: &[NonZeroU64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { // Get index array representation and encoded size let index_array_representation = sharding_index_decoded_representation(chunks_per_shard); @@ -1053,7 +1052,7 @@ impl ShardingCodec { &self, encoded_shard: &[u8], chunks_per_shard: &[NonZeroU64], - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { // Get index array representation and encoded size let index_array_representation = sharding_index_decoded_representation(chunks_per_shard); @@ -1095,7 +1094,7 @@ impl ShardingCodec { encoded_shard: &[u8], shard_index: &[u64], shard_representation: &ChunkRepresentation, - options: &DecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { // Allocate an array for the output let shard_size = shard_representation.size_usize(); diff --git a/src/array/codec/array_to_bytes/sharding/sharding_partial_decoder.rs b/src/array/codec/array_to_bytes/sharding/sharding_partial_decoder.rs index b0e724bf..b868482f 100644 --- a/src/array/codec/array_to_bytes/sharding/sharding_partial_decoder.rs +++ b/src/array/codec/array_to_bytes/sharding/sharding_partial_decoder.rs @@ -7,10 +7,9 @@ use crate::{ chunk_grid::RegularChunkGrid, chunk_shape_to_array_shape, codec::{ - options::EncodeOptionsBuilder, ArrayCodecTraits, ArrayPartialDecoderTraits, - ArraySubset, ArrayToBytesCodecTraits, ByteIntervalPartialDecoder, - BytesPartialDecoderTraits, CodecChain, CodecError, PartialDecodeOptions, - PartialDecoderOptions, + ArrayCodecTraits, ArrayPartialDecoderTraits, ArraySubset, ArrayToBytesCodecTraits, + ByteIntervalPartialDecoder, BytesPartialDecoderTraits, CodecChain, CodecError, + CodecOptions, CodecOptionsBuilder, }, concurrency::{calc_concurrency_outer_inner, RecommendedConcurrency}, ravel_indices, @@ -52,7 +51,7 @@ impl<'a> ShardingPartialDecoder<'a> { inner_codecs: &'a CodecChain, index_codecs: &'a CodecChain, index_location: ShardingIndexLocation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result { let shard_index = Self::decode_shard_index( &*input_handle, @@ -78,7 +77,7 @@ impl<'a> ShardingPartialDecoder<'a> { index_location: ShardingIndexLocation, chunk_shape: &[NonZeroU64], decoded_representation: &ChunkRepresentation, - options: &PartialDecoderOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let shard_shape = decoded_representation.shape(); let chunk_representation = unsafe { @@ -132,7 +131,7 @@ impl ArrayPartialDecoderTraits for ShardingPartialDecoder<'_> { fn partial_decode_opt( &self, array_subsets: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { for array_subset in array_subsets { if array_subset.dimensionality() != self.decoded_representation.dimensionality() { @@ -185,7 +184,7 @@ impl ArrayPartialDecoderTraits for ShardingPartialDecoder<'_> { .inner_codecs .recommended_concurrency(&chunk_representation)?, ); - let options = EncodeOptionsBuilder::new() + let options = CodecOptionsBuilder::new() .concurrent_target(concurrency_limit_codec) .build(); @@ -385,7 +384,7 @@ impl<'a> AsyncShardingPartialDecoder<'a> { inner_codecs: &'a CodecChain, index_codecs: &'a CodecChain, index_location: ShardingIndexLocation, - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { let shard_index = Self::decode_shard_index( &*input_handle, @@ -412,7 +411,7 @@ impl<'a> AsyncShardingPartialDecoder<'a> { index_location: ShardingIndexLocation, chunk_shape: &[NonZeroU64], decoded_representation: &ChunkRepresentation, - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let shard_shape = decoded_representation.shape(); let chunk_representation = unsafe { @@ -468,7 +467,7 @@ impl AsyncArrayPartialDecoderTraits for AsyncShardingPartialDecoder<'_> { async fn partial_decode_opt( &self, array_subsets: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let Some(shard_index) = &self.shard_index else { return Ok(array_subsets diff --git a/src/array/codec/array_to_bytes/zfp/zfp_codec.rs b/src/array/codec/array_to_bytes/zfp/zfp_codec.rs index f082d811..7d1b2dbe 100644 --- a/src/array/codec/array_to_bytes/zfp/zfp_codec.rs +++ b/src/array/codec/array_to_bytes/zfp/zfp_codec.rs @@ -10,8 +10,8 @@ use crate::{ array::{ codec::{ ArrayCodecTraits, ArrayPartialDecoderTraits, ArrayToBytesCodecTraits, - BytesPartialDecoderTraits, CodecError, CodecTraits, DecodeOptions, EncodeOptions, - PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, CodecError, CodecOptions, CodecTraits, + RecommendedConcurrency, }, BytesRepresentation, ChunkRepresentation, DataType, }, @@ -139,7 +139,7 @@ impl ArrayCodecTraits for ZfpCodec { &self, mut decoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let Some(zfp_type) = zarr_data_type_to_zfp_data_type(decoded_representation.data_type()) else { @@ -195,7 +195,7 @@ impl ArrayCodecTraits for ZfpCodec { &self, encoded_value: Vec, decoded_representation: &ChunkRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let Some(zfp_type) = zarr_data_type_to_zfp_data_type(decoded_representation.data_type()) else { @@ -219,7 +219,7 @@ impl ArrayToBytesCodecTraits for ZfpCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(zfp_partial_decoder::ZfpPartialDecoder::new( input_handle, @@ -233,7 +233,7 @@ impl ArrayToBytesCodecTraits for ZfpCodec { &'a self, input_handle: Box, decoded_representation: &ChunkRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(zfp_partial_decoder::AsyncZfpPartialDecoder::new( input_handle, diff --git a/src/array/codec/array_to_bytes/zfp/zfp_partial_decoder.rs b/src/array/codec/array_to_bytes/zfp/zfp_partial_decoder.rs index b5b7bd91..ca776ef1 100644 --- a/src/array/codec/array_to_bytes/zfp/zfp_partial_decoder.rs +++ b/src/array/codec/array_to_bytes/zfp/zfp_partial_decoder.rs @@ -2,9 +2,7 @@ use zfp_sys::zfp_type; use crate::{ array::{ - codec::{ - ArrayPartialDecoderTraits, BytesPartialDecoderTraits, CodecError, PartialDecodeOptions, - }, + codec::{ArrayPartialDecoderTraits, BytesPartialDecoderTraits, CodecError, CodecOptions}, ChunkRepresentation, }, array_subset::ArraySubset, @@ -57,7 +55,7 @@ impl ArrayPartialDecoderTraits for ZfpPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { for array_subset in decoded_regions { if array_subset.dimensionality() != self.decoded_representation.dimensionality() { @@ -147,7 +145,7 @@ impl AsyncArrayPartialDecoderTraits for AsyncZfpPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { let encoded_value = self.input_handle.decode_opt(options).await?; let chunk_shape = self.decoded_representation.shape_u64(); diff --git a/src/array/codec/byte_interval_partial_decoder.rs b/src/array/codec/byte_interval_partial_decoder.rs index 1dc9e653..6ac7295e 100644 --- a/src/array/codec/byte_interval_partial_decoder.rs +++ b/src/array/codec/byte_interval_partial_decoder.rs @@ -1,6 +1,6 @@ use crate::byte_range::{ByteLength, ByteOffset, ByteRange}; -use super::{BytesPartialDecoderTraits, CodecError, PartialDecodeOptions}; +use super::{BytesPartialDecoderTraits, CodecError, CodecOptions}; #[cfg(feature = "async")] use super::AsyncBytesPartialDecoderTraits; @@ -33,7 +33,7 @@ impl<'a> BytesPartialDecoderTraits for ByteIntervalPartialDecoder<'a> { fn partial_decode_opt( &self, byte_ranges: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let byte_ranges: Vec = byte_ranges .iter() @@ -89,7 +89,7 @@ impl<'a> AsyncBytesPartialDecoderTraits for AsyncByteIntervalPartialDecoder<'a> async fn partial_decode_opt( &self, byte_ranges: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let byte_ranges: Vec = byte_ranges .iter() diff --git a/src/array/codec/bytes_to_bytes/blosc/blosc_codec.rs b/src/array/codec/bytes_to_bytes/blosc/blosc_codec.rs index a67d0905..223f614a 100644 --- a/src/array/codec/bytes_to_bytes/blosc/blosc_codec.rs +++ b/src/array/codec/bytes_to_bytes/blosc/blosc_codec.rs @@ -5,8 +5,8 @@ use blosc_sys::{blosc_get_complib_info, BLOSC_MAX_OVERHEAD}; use crate::{ array::{ codec::{ - BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecTraits, - DecodeOptions, EncodeOptions, PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecOptions, + CodecTraits, RecommendedConcurrency, }, BytesRepresentation, }, @@ -149,7 +149,7 @@ impl BytesToBytesCodecTraits for BloscCodec { fn encode_opt( &self, decoded_value: Vec, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { // let n_threads = std::cmp::min( // options.concurrent_limit(), @@ -164,7 +164,7 @@ impl BytesToBytesCodecTraits for BloscCodec { &self, encoded_value: Vec, _decoded_representation: &BytesRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { // let n_threads = std::cmp::min( // options.concurrent_limit(), @@ -179,7 +179,7 @@ impl BytesToBytesCodecTraits for BloscCodec { &'a self, input_handle: Box, _decoded_representation: &BytesRepresentation, - _parallel: &PartialDecoderOptions, + _parallel: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(blosc_partial_decoder::BloscPartialDecoder::new( input_handle, @@ -191,7 +191,7 @@ impl BytesToBytesCodecTraits for BloscCodec { &'a self, input_handle: Box, _decoded_representation: &BytesRepresentation, - _parallel: &PartialDecoderOptions, + _parallel: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( blosc_partial_decoder::AsyncBloscPartialDecoder::new(input_handle), diff --git a/src/array/codec/bytes_to_bytes/blosc/blosc_partial_decoder.rs b/src/array/codec/bytes_to_bytes/blosc/blosc_partial_decoder.rs index e521aad1..d5940ad8 100644 --- a/src/array/codec/bytes_to_bytes/blosc/blosc_partial_decoder.rs +++ b/src/array/codec/bytes_to_bytes/blosc/blosc_partial_decoder.rs @@ -1,7 +1,6 @@ use crate::{ array::codec::{ - bytes_to_bytes::blosc::blosc_nbytes, BytesPartialDecoderTraits, CodecError, - PartialDecodeOptions, + bytes_to_bytes::blosc::blosc_nbytes, BytesPartialDecoderTraits, CodecError, CodecOptions, }, byte_range::ByteRange, }; @@ -26,7 +25,7 @@ impl BytesPartialDecoderTraits for BloscPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options)?; let Some(encoded_value) = encoded_value else { @@ -77,7 +76,7 @@ impl AsyncBytesPartialDecoderTraits for AsyncBloscPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options).await?; let Some(encoded_value) = encoded_value else { diff --git a/src/array/codec/bytes_to_bytes/bz2/bz2_codec.rs b/src/array/codec/bytes_to_bytes/bz2/bz2_codec.rs index 120fef5d..a455f443 100644 --- a/src/array/codec/bytes_to_bytes/bz2/bz2_codec.rs +++ b/src/array/codec/bytes_to_bytes/bz2/bz2_codec.rs @@ -3,8 +3,8 @@ use std::io::Read; use crate::{ array::{ codec::{ - BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecTraits, - DecodeOptions, EncodeOptions, PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecOptions, + CodecTraits, RecommendedConcurrency, }, BytesRepresentation, }, @@ -72,7 +72,7 @@ impl BytesToBytesCodecTraits for Bz2Codec { fn encode_opt( &self, decoded_value: Vec, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let mut encoder = bzip2::read::BzEncoder::new(decoded_value.as_slice(), self.compression); let mut out: Vec = Vec::new(); @@ -84,7 +84,7 @@ impl BytesToBytesCodecTraits for Bz2Codec { &self, encoded_value: Vec, _decoded_representation: &BytesRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let mut decoder = bzip2::read::BzDecoder::new(encoded_value.as_slice()); let mut out: Vec = Vec::new(); @@ -96,7 +96,7 @@ impl BytesToBytesCodecTraits for Bz2Codec { &'a self, input_handle: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(bz2_partial_decoder::Bz2PartialDecoder::new( input_handle, @@ -108,7 +108,7 @@ impl BytesToBytesCodecTraits for Bz2Codec { &'a self, input_handle: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(bz2_partial_decoder::AsyncBz2PartialDecoder::new( input_handle, diff --git a/src/array/codec/bytes_to_bytes/bz2/bz2_partial_decoder.rs b/src/array/codec/bytes_to_bytes/bz2/bz2_partial_decoder.rs index 197e7a25..469d8bcf 100644 --- a/src/array/codec/bytes_to_bytes/bz2/bz2_partial_decoder.rs +++ b/src/array/codec/bytes_to_bytes/bz2/bz2_partial_decoder.rs @@ -1,7 +1,7 @@ use std::io::Read; use crate::{ - array::codec::{BytesPartialDecoderTraits, CodecError, PartialDecodeOptions}, + array::codec::{BytesPartialDecoderTraits, CodecError, CodecOptions}, byte_range::{extract_byte_ranges, ByteRange}, }; @@ -23,7 +23,7 @@ impl BytesPartialDecoderTraits for Bz2PartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options)?; let Some(encoded_value) = encoded_value else { @@ -60,7 +60,7 @@ impl AsyncBytesPartialDecoderTraits for AsyncBz2PartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options).await?; let Some(encoded_value) = encoded_value else { diff --git a/src/array/codec/bytes_to_bytes/crc32c/crc32c_codec.rs b/src/array/codec/bytes_to_bytes/crc32c/crc32c_codec.rs index 85de0f6a..42c7f721 100644 --- a/src/array/codec/bytes_to_bytes/crc32c/crc32c_codec.rs +++ b/src/array/codec/bytes_to_bytes/crc32c/crc32c_codec.rs @@ -1,8 +1,8 @@ use crate::{ array::{ codec::{ - BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecTraits, - DecodeOptions, EncodeOptions, PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecOptions, + CodecTraits, RecommendedConcurrency, }, BytesRepresentation, }, @@ -62,7 +62,7 @@ impl BytesToBytesCodecTraits for Crc32cCodec { fn encode_opt( &self, mut decoded_value: Vec, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let checksum = crc32c::crc32c(&decoded_value).to_le_bytes(); decoded_value.reserve_exact(checksum.len()); @@ -74,7 +74,7 @@ impl BytesToBytesCodecTraits for Crc32cCodec { &self, mut encoded_value: Vec, _decoded_representation: &BytesRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { if encoded_value.len() >= CHECKSUM_SIZE { if crate::config::global_config().validate_checksums() { @@ -97,7 +97,7 @@ impl BytesToBytesCodecTraits for Crc32cCodec { &'a self, input_handle: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(crc32c_partial_decoder::Crc32cPartialDecoder::new( input_handle, @@ -109,7 +109,7 @@ impl BytesToBytesCodecTraits for Crc32cCodec { &'a self, input_handle: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( crc32c_partial_decoder::AsyncCrc32cPartialDecoder::new(input_handle), diff --git a/src/array/codec/bytes_to_bytes/crc32c/crc32c_partial_decoder.rs b/src/array/codec/bytes_to_bytes/crc32c/crc32c_partial_decoder.rs index b0a9f230..6bb1ebc7 100644 --- a/src/array/codec/bytes_to_bytes/crc32c/crc32c_partial_decoder.rs +++ b/src/array/codec/bytes_to_bytes/crc32c/crc32c_partial_decoder.rs @@ -1,5 +1,5 @@ use crate::{ - array::codec::{BytesPartialDecoderTraits, CodecError, PartialDecodeOptions}, + array::codec::{BytesPartialDecoderTraits, CodecError, CodecOptions}, byte_range::ByteRange, }; @@ -24,7 +24,7 @@ impl BytesPartialDecoderTraits for Crc32cPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let bytes = self .input_handle @@ -73,7 +73,7 @@ impl AsyncBytesPartialDecoderTraits for AsyncCrc32cPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let bytes = self .input_handle diff --git a/src/array/codec/bytes_to_bytes/gzip/gzip_codec.rs b/src/array/codec/bytes_to_bytes/gzip/gzip_codec.rs index 3b7eb275..0f8a2ea9 100644 --- a/src/array/codec/bytes_to_bytes/gzip/gzip_codec.rs +++ b/src/array/codec/bytes_to_bytes/gzip/gzip_codec.rs @@ -5,8 +5,8 @@ use flate2::bufread::{GzDecoder, GzEncoder}; use crate::{ array::{ codec::{ - BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecTraits, - DecodeOptions, EncodeOptions, PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecOptions, + CodecTraits, RecommendedConcurrency, }, BytesRepresentation, }, @@ -77,7 +77,7 @@ impl BytesToBytesCodecTraits for GzipCodec { fn encode_opt( &self, decoded_value: Vec, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let mut encoder = GzEncoder::new( Cursor::new(decoded_value), @@ -92,7 +92,7 @@ impl BytesToBytesCodecTraits for GzipCodec { &self, encoded_value: Vec, _decoded_representation: &BytesRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let mut decoder = GzDecoder::new(Cursor::new(encoded_value)); let mut out: Vec = Vec::new(); @@ -104,7 +104,7 @@ impl BytesToBytesCodecTraits for GzipCodec { &self, r: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(gzip_partial_decoder::GzipPartialDecoder::new(r))) } @@ -114,7 +114,7 @@ impl BytesToBytesCodecTraits for GzipCodec { &'a self, r: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( gzip_partial_decoder::AsyncGzipPartialDecoder::new(r), diff --git a/src/array/codec/bytes_to_bytes/gzip/gzip_partial_decoder.rs b/src/array/codec/bytes_to_bytes/gzip/gzip_partial_decoder.rs index d9b159a9..dc0fc800 100644 --- a/src/array/codec/bytes_to_bytes/gzip/gzip_partial_decoder.rs +++ b/src/array/codec/bytes_to_bytes/gzip/gzip_partial_decoder.rs @@ -3,7 +3,7 @@ use std::io::{Cursor, Read}; use flate2::bufread::GzDecoder; use crate::{ - array::codec::{BytesPartialDecoderTraits, CodecError, PartialDecodeOptions}, + array::codec::{BytesPartialDecoderTraits, CodecError, CodecOptions}, byte_range::{extract_byte_ranges, ByteRange}, }; @@ -26,7 +26,7 @@ impl BytesPartialDecoderTraits for GzipPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options)?; let Some(encoded_value) = encoded_value else { @@ -64,7 +64,7 @@ impl AsyncBytesPartialDecoderTraits for AsyncGzipPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options).await?; let Some(encoded_value) = encoded_value else { diff --git a/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_codec.rs b/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_codec.rs index 5175fcfa..8b77944f 100644 --- a/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_codec.rs +++ b/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_codec.rs @@ -1,8 +1,8 @@ use crate::{ array::{ codec::{ - BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecTraits, - DecodeOptions, EncodeOptions, PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecOptions, + CodecTraits, RecommendedConcurrency, }, BytesRepresentation, }, @@ -55,7 +55,7 @@ impl BytesToBytesCodecTraits for TestUnboundedCodec { fn encode_opt( &self, decoded_value: Vec, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(decoded_value) } @@ -64,7 +64,7 @@ impl BytesToBytesCodecTraits for TestUnboundedCodec { &self, encoded_value: Vec, _decoded_representation: &BytesRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(encoded_value) } @@ -73,7 +73,7 @@ impl BytesToBytesCodecTraits for TestUnboundedCodec { &self, r: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( test_unbounded_partial_decoder::TestUnboundedPartialDecoder::new(r), @@ -85,7 +85,7 @@ impl BytesToBytesCodecTraits for TestUnboundedCodec { &'a self, r: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( test_unbounded_partial_decoder::AsyncTestUnboundedPartialDecoder::new(r), diff --git a/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_partial_decoder.rs b/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_partial_decoder.rs index 59f3b5e2..7e271704 100644 --- a/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_partial_decoder.rs +++ b/src/array/codec/bytes_to_bytes/test_unbounded/test_unbounded_partial_decoder.rs @@ -1,5 +1,5 @@ use crate::{ - array::codec::{BytesPartialDecoderTraits, CodecError, PartialDecodeOptions}, + array::codec::{BytesPartialDecoderTraits, CodecError, CodecOptions}, byte_range::{extract_byte_ranges, ByteRange}, }; @@ -22,7 +22,7 @@ impl BytesPartialDecoderTraits for TestUnboundedPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options)?; let Some(encoded_value) = encoded_value else { @@ -56,7 +56,7 @@ impl AsyncBytesPartialDecoderTraits for AsyncTestUnboundedPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options).await?; let Some(encoded_value) = encoded_value else { diff --git a/src/array/codec/bytes_to_bytes/zstd/zstd_codec.rs b/src/array/codec/bytes_to_bytes/zstd/zstd_codec.rs index 6b6179a2..ed6a6f66 100644 --- a/src/array/codec/bytes_to_bytes/zstd/zstd_codec.rs +++ b/src/array/codec/bytes_to_bytes/zstd/zstd_codec.rs @@ -3,8 +3,8 @@ use zstd::zstd_safe; use crate::{ array::{ codec::{ - BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecTraits, - DecodeOptions, EncodeOptions, PartialDecoderOptions, RecommendedConcurrency, + BytesPartialDecoderTraits, BytesToBytesCodecTraits, CodecError, CodecOptions, + CodecTraits, RecommendedConcurrency, }, BytesRepresentation, }, @@ -75,7 +75,7 @@ impl BytesToBytesCodecTraits for ZstdCodec { fn encode_opt( &self, decoded_value: Vec, - _options: &EncodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { let mut result = Vec::::new(); let mut encoder = zstd::Encoder::new(&mut result, self.compression)?; @@ -93,7 +93,7 @@ impl BytesToBytesCodecTraits for ZstdCodec { &self, encoded_value: Vec, _decoded_representation: &BytesRepresentation, - _options: &DecodeOptions, + _options: &CodecOptions, ) -> Result, CodecError> { zstd::decode_all(encoded_value.as_slice()).map_err(CodecError::IOError) } @@ -102,7 +102,7 @@ impl BytesToBytesCodecTraits for ZstdCodec { &self, r: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new(zstd_partial_decoder::ZstdPartialDecoder::new(r))) } @@ -112,7 +112,7 @@ impl BytesToBytesCodecTraits for ZstdCodec { &'a self, r: Box, _decoded_representation: &BytesRepresentation, - _options: &PartialDecoderOptions, + _options: &CodecOptions, ) -> Result, CodecError> { Ok(Box::new( zstd_partial_decoder::AsyncZstdPartialDecoder::new(r), diff --git a/src/array/codec/bytes_to_bytes/zstd/zstd_partial_decoder.rs b/src/array/codec/bytes_to_bytes/zstd/zstd_partial_decoder.rs index 187fad9d..e53edc70 100644 --- a/src/array/codec/bytes_to_bytes/zstd/zstd_partial_decoder.rs +++ b/src/array/codec/bytes_to_bytes/zstd/zstd_partial_decoder.rs @@ -1,5 +1,5 @@ use crate::{ - array::codec::{BytesPartialDecoderTraits, CodecError, PartialDecodeOptions}, + array::codec::{BytesPartialDecoderTraits, CodecError, CodecOptions}, byte_range::{extract_byte_ranges, ByteRange}, }; @@ -22,7 +22,7 @@ impl BytesPartialDecoderTraits for ZstdPartialDecoder<'_> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options)?; let Some(encoded_value) = encoded_value else { @@ -59,7 +59,7 @@ impl AsyncBytesPartialDecoderTraits for AsyncZstdPartialDecoder<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { let encoded_value = self.input_handle.decode_opt(options).await?; let Some(encoded_value) = encoded_value else { diff --git a/src/array/codec/options.rs b/src/array/codec/options.rs index 14eb8d1f..dcca3328 100644 --- a/src/array/codec/options.rs +++ b/src/array/codec/options.rs @@ -1,14 +1,14 @@ -//! Options for codec encoding and decoding. +//! Codec options for encoding and decoding. use crate::config::global_config; -/// Encode options. +/// Codec options for encoding/decoding. #[derive(Debug, Clone)] -pub struct EncodeOptions { +pub struct CodecOptions { concurrent_target: usize, } -impl Default for EncodeOptions { +impl Default for CodecOptions { fn default() -> Self { Self { concurrent_target: global_config().codec_concurrent_target(), @@ -16,11 +16,11 @@ impl Default for EncodeOptions { } } -impl EncodeOptions { +impl CodecOptions { /// Create a new encode options builder. #[must_use] - pub fn builder() -> EncodeOptionsBuilder { - EncodeOptionsBuilder::new() + pub fn builder() -> CodecOptionsBuilder { + CodecOptionsBuilder::new() } /// Return the concurrent target. @@ -35,19 +35,19 @@ impl EncodeOptions { } } -/// Builder for [`EncodeOptions`]. +/// Builder for [`CodecOptions`]. #[derive(Debug, Clone)] -pub struct EncodeOptionsBuilder { +pub struct CodecOptionsBuilder { concurrent_target: usize, } -impl Default for EncodeOptionsBuilder { +impl Default for CodecOptionsBuilder { fn default() -> Self { Self::new() } } -impl EncodeOptionsBuilder { +impl CodecOptionsBuilder { /// Create a new encode options builder. #[must_use] pub fn new() -> Self { @@ -58,8 +58,8 @@ impl EncodeOptionsBuilder { /// Build into encode options. #[must_use] - pub fn build(&self) -> EncodeOptions { - EncodeOptions { + pub fn build(&self) -> CodecOptions { + CodecOptions { concurrent_target: self.concurrent_target, } } @@ -71,21 +71,3 @@ impl EncodeOptionsBuilder { self } } - -/// Decode options. -pub type DecodeOptions = EncodeOptions; - -/// Decode options builder. -pub type DecodeOptionsBuilder = EncodeOptionsBuilder; - -/// Partial decoder options. -pub type PartialDecoderOptions = DecodeOptions; - -/// Partial decoder options builder. -pub type PartialDecoderOptionsBuilder = EncodeOptionsBuilder; - -/// Partial decode options. -pub type PartialDecodeOptions = DecodeOptions; - -/// Partial decode options builder. -pub type PartialDecodeOptionsBuilder = EncodeOptionsBuilder; diff --git a/src/array/codec/partial_decoder_cache.rs b/src/array/codec/partial_decoder_cache.rs index 2e50fddd..ebf61da2 100644 --- a/src/array/codec/partial_decoder_cache.rs +++ b/src/array/codec/partial_decoder_cache.rs @@ -11,8 +11,7 @@ use crate::{ }; use super::{ - ArrayPartialDecoderTraits, ArraySubset, BytesPartialDecoderTraits, CodecError, - PartialDecodeOptions, + ArrayPartialDecoderTraits, ArraySubset, BytesPartialDecoderTraits, CodecError, CodecOptions, }; #[cfg(feature = "async")] @@ -31,7 +30,7 @@ impl<'a> BytesPartialDecoderCache<'a> { /// Returns a [`CodecError`] if caching fails. pub fn new( input_handle: &dyn BytesPartialDecoderTraits, - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result { let cache = input_handle .partial_decode_opt(&[ByteRange::FromStart(0, None)], options)? @@ -49,7 +48,7 @@ impl<'a> BytesPartialDecoderCache<'a> { /// Returns a [`CodecError`] if caching fails. pub async fn async_new( input_handle: &dyn AsyncBytesPartialDecoderTraits, - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { let cache = input_handle .partial_decode_opt(&[ByteRange::FromStart(0, None)], options) @@ -66,7 +65,7 @@ impl BytesPartialDecoderTraits for BytesPartialDecoderCache<'_> { fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - _options: &PartialDecodeOptions, + _options: &CodecOptions, ) -> Result>>, CodecError> { Ok(match &self.cache { Some(bytes) => Some( @@ -84,7 +83,7 @@ impl AsyncBytesPartialDecoderTraits for BytesPartialDecoderCache<'_> { async fn partial_decode_opt( &self, decoded_regions: &[ByteRange], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>>, CodecError> { BytesPartialDecoderTraits::partial_decode_opt(self, decoded_regions, options) } @@ -105,7 +104,7 @@ impl<'a> ArrayPartialDecoderCache<'a> { pub fn new( input_handle: &dyn ArrayPartialDecoderTraits, decoded_representation: ChunkRepresentation, - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result { let cache = input_handle .partial_decode_opt( @@ -130,7 +129,7 @@ impl<'a> ArrayPartialDecoderCache<'a> { pub async fn async_new( input_handle: &dyn AsyncArrayPartialDecoderTraits, decoded_representation: ChunkRepresentation, - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result, CodecError> { let cache = input_handle .partial_decode_opt( @@ -157,7 +156,7 @@ impl<'a> ArrayPartialDecoderTraits for ArrayPartialDecoderCache<'a> { fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - _options: &PartialDecodeOptions, + _options: &CodecOptions, ) -> Result>, CodecError> { let mut out: Vec> = Vec::with_capacity(decoded_regions.len()); let array_shape = self.decoded_representation.shape_u64(); @@ -184,7 +183,7 @@ impl<'a> AsyncArrayPartialDecoderTraits for ArrayPartialDecoderCache<'a> { async fn partial_decode_opt( &self, decoded_regions: &[ArraySubset], - options: &PartialDecodeOptions, + options: &CodecOptions, ) -> Result>, CodecError> { ArrayPartialDecoderTraits::partial_decode_opt(self, decoded_regions, options) } diff --git a/src/array/concurrency.rs b/src/array/concurrency.rs index 3fce66a3..4fc23a7a 100644 --- a/src/array/concurrency.rs +++ b/src/array/concurrency.rs @@ -15,7 +15,7 @@ use crate::config::global_config; -use super::codec::{options::EncodeOptionsBuilder, EncodeOptions}; +use super::codec::{options::CodecOptionsBuilder, CodecOptions}; /// The recommended concurrency of a codec includes the most efficient and maximum recommended concurrency. /// @@ -120,7 +120,7 @@ pub fn concurrency_chunks_and_codec( concurrency_target: usize, num_chunks: usize, codec_concurrency: &RecommendedConcurrency, -) -> (usize, EncodeOptions) { +) -> (usize, CodecOptions) { // core::cmp::minmax https://github.com/rust-lang/rust/issues/115939 let min_concurrent_chunks = std::cmp::min(global_config().chunk_concurrent_minimum(), num_chunks); @@ -131,7 +131,7 @@ pub fn concurrency_chunks_and_codec( &RecommendedConcurrency::new(min_concurrent_chunks..max_concurrent_chunks), codec_concurrency, ); - let codec_options = EncodeOptionsBuilder::new() + let codec_options = CodecOptionsBuilder::new() .concurrent_target(codec_concurrent_limit) .build(); (self_concurrent_limit, codec_options) diff --git a/src/config.rs b/src/config.rs index ca66f0d5..55261bba 100644 --- a/src/config.rs +++ b/src/config.rs @@ -30,7 +30,7 @@ use std::sync::{OnceLock, RwLock, RwLockReadGuard, RwLockWriteGuard}; /// /// For array operations involving multiple chunks, this is the preferred minimum chunk concurrency. /// For example, `array_store_chunks` will concurrently encode and store four chunks at a time by default. -/// The concurrency of internal codecs is adjusted to accomodate for the chunk concurrency in accordance with the concurrent target set in the [`EncodeOptions`](crate::array::codec::EncodeOptions) or [`DecodeOptions`](crate::array::codec::DecodeOptions) parameter of an encode or decode method. +/// The concurrency of internal codecs is adjusted to accomodate for the chunk concurrency in accordance with the concurrent target set in the [`CodecOptions`](crate::array::codec::CodecOptions) parameter of an encode or decode method. #[derive(Debug)] pub struct Config {