4
4
from collections .abc import MutableMapping
5
5
from copy import copy
6
6
from string import ascii_letters , digits
7
- from typing import Any , List , Mapping , Optional , Union
7
+ from typing import Any , Dict , List , Mapping , Optional , Sequence , Tuple , Union
8
8
9
9
from zarr .meta import Metadata2 , Metadata3
10
10
from zarr .util import normalize_storage_path
@@ -261,10 +261,14 @@ def rmdir(self, path=None):
261
261
"""Remove a data path and all its subkeys and related metadata.
262
262
Expects a path without the data or meta root prefix."""
263
263
264
+ @property
264
265
def supports_efficient_get_partial_values (self ):
265
266
return False
266
267
267
- def get_partial_values (self , key_ranges ):
268
+ def get_partial_values (
269
+ self ,
270
+ key_ranges : Sequence [Tuple [str , Tuple [int , Optional [int ]]]]
271
+ ) -> List [Union [bytes , memoryview , bytearray ]]:
268
272
"""Get multiple partial values.
269
273
key_ranges can be an iterable of key, range pairs,
270
274
where a range specifies two integers range_start and range_length
@@ -274,8 +278,12 @@ def get_partial_values(self, key_ranges):
274
278
from the end of the file.
275
279
A key may occur multiple times with different ranges.
276
280
Inserts None for missing keys into the returned list."""
277
- results = [None ] * len (key_ranges )
278
- indexed_ranges_by_key = defaultdict (list )
281
+ results : List [Union [bytes , memoryview , bytearray ]] = (
282
+ [None ] * len (key_ranges ) # type: ignore[list-item]
283
+ )
284
+ indexed_ranges_by_key : Dict [str , List [Tuple [int , Tuple [int , Optional [int ]]]]] = (
285
+ defaultdict (list )
286
+ )
279
287
for i , (key , range_ ) in enumerate (key_ranges ):
280
288
indexed_ranges_by_key [key ].append ((i , range_ ))
281
289
for key , indexed_ranges in indexed_ranges_by_key .items ():
@@ -504,8 +512,9 @@ def __iter__(self):
504
512
def __len__ (self ):
505
513
return self .inner_store .__len__ ()
506
514
515
+ @property
507
516
def supports_efficient_get_partial_values (self ):
508
- return self .inner_store .supports_efficient_get_partial_values ()
517
+ return self .inner_store .supports_efficient_get_partial_values
509
518
510
519
def get_partial_values (self , key_ranges ):
511
520
return self .inner_store .get_partial_values (key_ranges )
0 commit comments