13
13
if TYPE_CHECKING :
14
14
from typing_extensions import Self
15
15
16
- from zarr .common import ArraySpec , SliceSelection
16
+ from zarr .common import ArraySpec
17
+ from zarr .indexing import SelectorTuple
17
18
from zarr .metadata import ArrayMetadata
18
19
19
20
@@ -155,21 +156,21 @@ class ArrayBytesCodecPartialDecodeMixin:
155
156
"""Mixin for array-to-bytes codecs that implement partial decoding."""
156
157
157
158
async def _decode_partial_single (
158
- self , byte_getter : ByteGetter , selection : SliceSelection , chunk_spec : ArraySpec
159
+ self , byte_getter : ByteGetter , selection : SelectorTuple , chunk_spec : ArraySpec
159
160
) -> NDBuffer | None :
160
161
raise NotImplementedError
161
162
162
163
async def decode_partial (
163
164
self ,
164
- batch_info : Iterable [tuple [ByteGetter , SliceSelection , ArraySpec ]],
165
+ batch_info : Iterable [tuple [ByteGetter , SelectorTuple , ArraySpec ]],
165
166
) -> Iterable [NDBuffer | None ]:
166
167
"""Partially decodes a batch of chunks.
167
168
This method determines parts of a chunk from the slice selection,
168
169
fetches these parts from the store (via ByteGetter) and decodes them.
169
170
170
171
Parameters
171
172
----------
172
- batch_info : Iterable[tuple[ByteGetter, SliceSelection , ArraySpec]]
173
+ batch_info : Iterable[tuple[ByteGetter, SelectorTuple , ArraySpec]]
173
174
Ordered set of information about slices of encoded chunks.
174
175
The slice selection determines which parts of the chunk will be fetched.
175
176
The ByteGetter is used to fetch the necessary bytes.
@@ -196,14 +197,14 @@ async def _encode_partial_single(
196
197
self ,
197
198
byte_setter : ByteSetter ,
198
199
chunk_array : NDBuffer ,
199
- selection : SliceSelection ,
200
+ selection : SelectorTuple ,
200
201
chunk_spec : ArraySpec ,
201
202
) -> None :
202
203
raise NotImplementedError
203
204
204
205
async def encode_partial (
205
206
self ,
206
- batch_info : Iterable [tuple [ByteSetter , NDBuffer , SliceSelection , ArraySpec ]],
207
+ batch_info : Iterable [tuple [ByteSetter , NDBuffer , SelectorTuple , ArraySpec ]],
207
208
) -> None :
208
209
"""Partially encodes a batch of chunks.
209
210
This method determines parts of a chunk from the slice selection, encodes them and
@@ -213,7 +214,7 @@ async def encode_partial(
213
214
214
215
Parameters
215
216
----------
216
- batch_info : Iterable[tuple[ByteSetter, NDBuffer, SliceSelection , ArraySpec]]
217
+ batch_info : Iterable[tuple[ByteSetter, NDBuffer, SelectorTuple , ArraySpec]]
217
218
Ordered set of information about slices of to-be-encoded chunks.
218
219
The slice selection determines which parts of the chunk will be encoded.
219
220
The ByteSetter is used to write the necessary bytes and fetch bytes for existing chunk data.
@@ -342,15 +343,16 @@ async def encode(
342
343
@abstractmethod
343
344
async def read (
344
345
self ,
345
- batch_info : Iterable [tuple [ByteGetter , ArraySpec , SliceSelection , SliceSelection ]],
346
+ batch_info : Iterable [tuple [ByteGetter , ArraySpec , SelectorTuple , SelectorTuple ]],
346
347
out : NDBuffer ,
348
+ drop_axes : tuple [int , ...] = (),
347
349
) -> None :
348
350
"""Reads chunk data from the store, decodes it and writes it into an output array.
349
351
Partial decoding may be utilized if the codecs and stores support it.
350
352
351
353
Parameters
352
354
----------
353
- batch_info : Iterable[tuple[ByteGetter, ArraySpec, SliceSelection, SliceSelection ]]
355
+ batch_info : Iterable[tuple[ByteGetter, ArraySpec, SelectorTuple, SelectorTuple ]]
354
356
Ordered set of information about the chunks.
355
357
The first slice selection determines which parts of the chunk will be fetched.
356
358
The second slice selection determines where in the output array the chunk data will be written.
@@ -363,16 +365,17 @@ async def read(
363
365
@abstractmethod
364
366
async def write (
365
367
self ,
366
- batch_info : Iterable [tuple [ByteSetter , ArraySpec , SliceSelection , SliceSelection ]],
368
+ batch_info : Iterable [tuple [ByteSetter , ArraySpec , SelectorTuple , SelectorTuple ]],
367
369
value : NDBuffer ,
370
+ drop_axes : tuple [int , ...] = (),
368
371
) -> None :
369
372
"""Encodes chunk data and writes it to the store.
370
373
Merges with existing chunk data by reading first, if necessary.
371
374
Partial encoding may be utilized if the codecs and stores support it.
372
375
373
376
Parameters
374
377
----------
375
- batch_info : Iterable[tuple[ByteSetter, ArraySpec, SliceSelection, SliceSelection ]]
378
+ batch_info : Iterable[tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple ]]
376
379
Ordered set of information about the chunks.
377
380
The first slice selection determines which parts of the chunk will be encoded.
378
381
The second slice selection determines where in the value array the chunk data is located.
0 commit comments