Skip to content

Commit fff58dc

Browse files
committed
Rename SuffixRange to SuffixByteRequest
1 parent 7659be4 commit fff58dc

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

src/zarr/abc/store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ class OffsetByteRequest:
4040

4141

4242
@dataclass
43-
class SuffixRange:
43+
class SuffixByteRequest:
4444
"""Request up to the last `n` bytes"""
4545

4646
suffix: int
4747
"""The number of bytes from the suffix to request."""
4848

4949

50-
ByteRangeRequest: TypeAlias = ExplicitByteRequest | OffsetByteRequest | SuffixRange
50+
ByteRangeRequest: TypeAlias = ExplicitByteRequest | OffsetByteRequest | SuffixByteRequest
5151

5252

5353
class Store(ABC):
@@ -182,7 +182,7 @@ async def get(
182182
183183
- ExplicitByteRequest(int, int): Request a specific range of bytes in the form (start, end). The end is exclusive. If the given range is zero-length or starts after the end of the object, an error will be returned. Additionally, if the range ends after the end of the object, the entire remainder of the object will be returned. Otherwise, the exact requested range will be returned.
184184
- OffsetByteRequest(int): Request all bytes starting from a given byte offset. This is equivalent to bytes={int}- as an HTTP header.
185-
- SuffixRange(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header.
185+
- SuffixByteRequest(int): Request the last int bytes. Note that here, int is the size of the request, not the byte offset. This is equivalent to bytes=-{int} as an HTTP header.
186186
187187
Returns
188188
-------

src/zarr/codecs/sharding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
ByteRangeRequest,
2323
ByteSetter,
2424
ExplicitByteRequest,
25-
SuffixRange,
25+
SuffixByteRequest,
2626
)
2727
from zarr.codecs.bytes import BytesCodec
2828
from zarr.codecs.crc32c_ import Crc32cCodec
@@ -708,7 +708,7 @@ async def _load_shard_index_maybe(
708708
)
709709
else:
710710
index_bytes = await byte_getter.get(
711-
prototype=numpy_buffer_prototype(), byte_range=SuffixRange(shard_index_size)
711+
prototype=numpy_buffer_prototype(), byte_range=SuffixByteRequest(shard_index_size)
712712
)
713713
if index_bytes is not None:
714714
return await self._decode_shard_index(index_bytes, chunks_per_shard)

src/zarr/storage/_fsspec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ExplicitByteRequest,
99
OffsetByteRequest,
1010
Store,
11-
SuffixRange,
11+
SuffixByteRequest,
1212
)
1313
from zarr.storage._common import _dereference_path
1414

@@ -227,7 +227,7 @@ async def get(
227227
value = prototype.buffer.from_bytes(
228228
await self.fs._cat_file(path, start=byte_range.offset, end=None)
229229
)
230-
elif isinstance(byte_range, SuffixRange):
230+
elif isinstance(byte_range, SuffixByteRequest):
231231
value = prototype.buffer.from_bytes(
232232
await self.fs._cat_file(path, start=-byte_range.suffix, end=None)
233233
)
@@ -299,7 +299,7 @@ async def get_partial_values(
299299
elif isinstance(byte_range, OffsetByteRequest):
300300
starts.append(byte_range.offset)
301301
stops.append(None)
302-
elif isinstance(byte_range, SuffixRange):
302+
elif isinstance(byte_range, SuffixByteRequest):
303303
starts.append(-byte_range.suffix)
304304
stops.append(None)
305305
else:

src/zarr/storage/_local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ExplicitByteRequest,
1313
OffsetByteRequest,
1414
Store,
15-
SuffixRange,
15+
SuffixByteRequest,
1616
)
1717
from zarr.core.buffer import Buffer
1818
from zarr.core.buffer.core import default_buffer_prototype
@@ -34,7 +34,7 @@ def _get(path: Path, prototype: BufferPrototype, byte_range: ByteRangeRequest |
3434
return prototype.buffer.from_bytes(f.read(byte_range.end - f.tell()))
3535
elif isinstance(byte_range, OffsetByteRequest):
3636
f.seek(byte_range.offset)
37-
elif isinstance(byte_range, SuffixRange):
37+
elif isinstance(byte_range, SuffixByteRequest):
3838
f.seek(max(0, size - byte_range.suffix))
3939
else:
4040
raise TypeError("Invalid format for ByteRangeRequest")

src/zarr/storage/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
from typing import TYPE_CHECKING
66

7-
from zarr.abc.store import ExplicitByteRequest, OffsetByteRequest, SuffixRange
7+
from zarr.abc.store import ExplicitByteRequest, OffsetByteRequest, SuffixByteRequest
88

99
if TYPE_CHECKING:
1010
from zarr.abc.store import ByteRangeRequest
@@ -62,7 +62,7 @@ def _normalize_byte_range_index(
6262
elif isinstance(byte_range, OffsetByteRequest):
6363
start = byte_range.offset
6464
stop = len(data) + 1
65-
elif isinstance(byte_range, SuffixRange):
65+
elif isinstance(byte_range, SuffixByteRequest):
6666
start = len(data) - byte_range.suffix
6767
stop = len(data) + 1
6868
return (start, stop)

src/zarr/storage/_zip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ExplicitByteRequest,
1313
OffsetByteRequest,
1414
Store,
15-
SuffixRange,
15+
SuffixByteRequest,
1616
)
1717
from zarr.core.buffer import Buffer, BufferPrototype
1818

@@ -157,7 +157,7 @@ def _get(
157157
size = f.seek(0, os.SEEK_END)
158158
if isinstance(byte_range, OffsetByteRequest):
159159
f.seek(byte_range.offset)
160-
elif isinstance(byte_range, SuffixRange):
160+
elif isinstance(byte_range, SuffixByteRequest):
161161
f.seek(max(0, size - byte_range.suffix))
162162
else:
163163
raise TypeError("Invalid format for ByteRangeRequest")

src/zarr/testing/store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
ExplicitByteRequest,
2020
OffsetByteRequest,
2121
Store,
22-
SuffixRange,
22+
SuffixByteRequest,
2323
)
2424
from zarr.core.buffer import Buffer, default_buffer_prototype
2525
from zarr.core.sync import _collect_aiterator
@@ -122,7 +122,7 @@ def test_store_supports_listing(self, store: S) -> None:
122122
@pytest.mark.parametrize("key", ["c/0", "foo/c/0.0", "foo/0/0"])
123123
@pytest.mark.parametrize("data", [b"\x01\x02\x03\x04", b""])
124124
@pytest.mark.parametrize(
125-
"byte_range", [None, ExplicitByteRequest(1, 4), OffsetByteRequest(1), SuffixRange(1)]
125+
"byte_range", [None, ExplicitByteRequest(1, 4), OffsetByteRequest(1), SuffixByteRequest(1)]
126126
)
127127
async def test_get(self, store: S, key: str, data: bytes, byte_range: ByteRangeRequest) -> None:
128128
"""
@@ -189,7 +189,7 @@ async def test_set_many(self, store: S) -> None:
189189
[("c/0", ExplicitByteRequest(0, 2)), ("zarr.json", None)],
190190
[
191191
("c/0/0", ExplicitByteRequest(0, 2)),
192-
("c/0/1", SuffixRange(2)),
192+
("c/0/1", SuffixByteRequest(2)),
193193
("c/0/2", OffsetByteRequest(2)),
194194
],
195195
],

0 commit comments

Comments
 (0)