1919 from zarr .abc .store import ByteGetter , ByteSetter , Store
2020 from zarr .core .array_spec import ArraySpec
2121 from zarr .core .chunk_grids import ChunkGrid
22- from zarr .core .codec_pipeline import ChunkRequest
22+ from zarr .core .codec_pipeline import ChunkTransform , ReadChunkRequest , WriteChunkRequest
2323 from zarr .core .dtype .wrapper import TBaseDType , TBaseScalar , ZDType
2424 from zarr .core .indexing import ChunkProjection , SelectorTuple
2525 from zarr .core .metadata import ArrayMetadata
@@ -711,6 +711,20 @@ def compute_encoded_size(self, byte_length: int, array_spec: ArraySpec) -> int:
711711 """
712712 ...
713713
714+ @abstractmethod
715+ def get_chunk_transform (self , array_spec : ArraySpec ) -> ChunkTransform :
716+ """Creates a ChunkTransform for the given array spec.
717+
718+ Parameters
719+ ----------
720+ array_spec : ArraySpec
721+
722+ Returns
723+ -------
724+ ChunkTransform
725+ """
726+ ...
727+
714728 @abstractmethod
715729 async def decode (
716730 self ,
@@ -752,7 +766,7 @@ async def encode(
752766 @abstractmethod
753767 async def read (
754768 self ,
755- batch_info : Iterable [ChunkRequest ],
769+ batch_info : Iterable [ReadChunkRequest ],
756770 out : NDBuffer ,
757771 drop_axes : tuple [int , ...] = (),
758772 ) -> None :
@@ -761,10 +775,10 @@ async def read(
761775
762776 Parameters
763777 ----------
764- batch_info : Iterable[ChunkRequest ]
765- Ordered set of chunk requests. Each ``ChunkRequest`` carries the
766- store path (``byte_setter``), the ``ArraySpec`` for that chunk,
767- chunk and output selections, and whether the chunk is complete .
778+ batch_info : Iterable[ReadChunkRequest ]
779+ Ordered set of read requests. Each carries a ``byte_getter``,
780+ a ``ChunkTransform`` (codec chain + spec), and chunk/output
781+ selections.
768782
769783 If the Store returns ``None`` for a chunk, then the chunk was not
770784 written and the implementation must set the values of that chunk (or
@@ -777,7 +791,7 @@ async def read(
777791 @abstractmethod
778792 async def write (
779793 self ,
780- batch_info : Iterable [ChunkRequest ],
794+ batch_info : Iterable [WriteChunkRequest ],
781795 value : NDBuffer ,
782796 drop_axes : tuple [int , ...] = (),
783797 ) -> None :
@@ -787,14 +801,37 @@ async def write(
787801
788802 Parameters
789803 ----------
790- batch_info : Iterable[ChunkRequest ]
791- Ordered set of chunk requests. Each ``ChunkRequest`` carries the
792- store path (``byte_setter``), the ``ArraySpec`` for that chunk,
793- chunk and output selections, and whether the chunk is complete.
804+ batch_info : Iterable[WriteChunkRequest ]
805+ Ordered set of write requests. Each carries a ``byte_setter``,
806+ a ``ChunkTransform`` (codec chain + spec), chunk/output
807+ selections, and whether the chunk is complete.
794808 value : NDBuffer
795809 """
796810 ...
797811
812+ @property
813+ def supports_sync_io (self ) -> bool :
814+ """Whether this pipeline can run read/write entirely on the calling thread."""
815+ return False
816+
817+ def read_sync (
818+ self ,
819+ batch_info : Iterable [ReadChunkRequest ],
820+ out : NDBuffer ,
821+ drop_axes : tuple [int , ...] = (),
822+ ) -> None :
823+ """Synchronous read: fetch bytes from store, decode, scatter into *out*."""
824+ raise NotImplementedError
825+
826+ def write_sync (
827+ self ,
828+ batch_info : Iterable [WriteChunkRequest ],
829+ value : NDBuffer ,
830+ drop_axes : tuple [int , ...] = (),
831+ ) -> None :
832+ """Synchronous write: gather from *value*, encode, persist to store."""
833+ raise NotImplementedError
834+
798835
799836async def _batching_helper (
800837 func : Callable [[CodecInput , ArraySpec ], Awaitable [CodecOutput | None ]],
0 commit comments