Skip to content

Commit 2f332b1

Browse files
committed
Preserve lazy b2object carriers when storing them in DictStore
1 parent 663cfe1 commit 2f332b1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/blosc2/dict_store.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,20 @@ def __setitem__(
397397

398398
# Save the value to the destination path
399399
if not external_file:
400-
if hasattr(value, "save"):
400+
if isinstance(value, blosc2.NDArray) and "b2o" in value.schunk.meta:
401+
carrier = blosc2.empty(
402+
value.shape,
403+
value.dtype,
404+
chunks=value.chunks,
405+
blocks=value.blocks,
406+
cparams=value.cparams,
407+
urlpath=dest_path,
408+
mode="w",
409+
meta={"b2o": value.schunk.meta["b2o"]},
410+
)
411+
for meta_key, meta_value in value.schunk.vlmeta[:].items():
412+
carrier.schunk.vlmeta[meta_key] = meta_value
413+
elif hasattr(value, "save"):
401414
value.save(urlpath=dest_path)
402415
else:
403416
# SChunk, VLArray and BatchStore can all be persisted via their cframe.

0 commit comments

Comments
 (0)