Skip to content

Commit 4a73b70

Browse files
committed
fixes sharding
1 parent 608f390 commit 4a73b70

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/zarr/codecs/sharding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_chunk_slice(self, chunk_coords: ChunkCoords) -> tuple[int, int] | None:
129129
if (chunk_start, chunk_len) == (MAX_UINT_64, MAX_UINT_64):
130130
return None
131131
else:
132-
return (int(chunk_start), int(chunk_len))
132+
return (int(chunk_start), int(chunk_start + chunk_len))
133133

134134
def set_chunk_slice(self, chunk_coords: ChunkCoords, chunk_slice: slice | None) -> None:
135135
localized_chunk = self._localize_chunk(chunk_coords)
@@ -203,7 +203,7 @@ def create_empty(
203203
def __getitem__(self, chunk_coords: ChunkCoords) -> Buffer:
204204
chunk_byte_slice = self.index.get_chunk_slice(chunk_coords)
205205
if chunk_byte_slice:
206-
return self.buf[chunk_byte_slice[0] : (chunk_byte_slice[0] + chunk_byte_slice[1])]
206+
return self.buf[chunk_byte_slice[0] : chunk_byte_slice[1]]
207207
raise KeyError
208208

209209
def __len__(self) -> int:
@@ -700,7 +700,7 @@ async def _load_shard_index_maybe(
700700
)
701701
else:
702702
index_bytes = await byte_getter.get(
703-
prototype=numpy_buffer_prototype(), byte_range=(-shard_index_size, None)
703+
prototype=numpy_buffer_prototype(), byte_range={"suffix": shard_index_size}
704704
)
705705
if index_bytes is not None:
706706
return await self._decode_shard_index(index_bytes, chunks_per_shard)

0 commit comments

Comments
 (0)