File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed
Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1+ Improved performance of reading arrays by not unnecessarily using
2+ the fill value.
Original file line number Diff line number Diff line change @@ -423,6 +423,11 @@ async def read(
423423 The second slice selection determines where in the output array the chunk data will be written.
424424 The ByteGetter is used to fetch the necessary bytes.
425425 The chunk spec contains information about the construction of an array from the bytes.
426+
427+ If the Store returns ``None`` for a chunk, then the chunk was not
428+ written and the implementation must set the values of that chunk (or
429+ ``out``) to the fill value for the array.
430+
426431 out : NDBuffer
427432 """
428433 ...
Original file line number Diff line number Diff line change @@ -452,11 +452,10 @@ async def _decode_single(
452452 )
453453
454454 # setup output array
455- out = chunk_spec .prototype .nd_buffer .create (
455+ out = chunk_spec .prototype .nd_buffer .empty (
456456 shape = shard_shape ,
457457 dtype = shard_spec .dtype .to_native_dtype (),
458458 order = shard_spec .order ,
459- fill_value = 0 ,
460459 )
461460 shard_dict = await _ShardReader .from_bytes (shard_bytes , self , chunks_per_shard )
462461
@@ -499,11 +498,10 @@ async def _decode_partial_single(
499498 )
500499
501500 # setup output array
502- out = shard_spec .prototype .nd_buffer .create (
501+ out = shard_spec .prototype .nd_buffer .empty (
503502 shape = indexer .shape ,
504503 dtype = shard_spec .dtype .to_native_dtype (),
505504 order = shard_spec .order ,
506- fill_value = 0 ,
507505 )
508506
509507 indexed_chunks = list (indexer )
Original file line number Diff line number Diff line change @@ -1350,11 +1350,10 @@ async def _get_selection(
13501350 f"shape of out argument doesn't match. Expected { indexer .shape } , got { out .shape } "
13511351 )
13521352 else :
1353- out_buffer = prototype .nd_buffer .create (
1353+ out_buffer = prototype .nd_buffer .empty (
13541354 shape = indexer .shape ,
13551355 dtype = out_dtype ,
13561356 order = self .order ,
1357- fill_value = self .metadata .fill_value ,
13581357 )
13591358 if product (indexer .shape ) > 0 :
13601359 # need to use the order from the metadata for v2
You can’t perform that action at this time.
0 commit comments