Skip to content

implement soft delete by replacing key with empty byte literal #2832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/zarr/storage/_zip.py
Original file line number Diff line number Diff line change
@@ -241,11 +241,12 @@

async def delete(self, key: str) -> None:
# docstring inherited
# we choose to only raise NotImplementedError here if the key exists
# this allows the array/group APIs to avoid the overhead of existence checks
# If key is present it is replaced by an empty byte literal as a way of representing it as deleted
self._check_writable()
if await self.exists(key):
raise NotImplementedError
with self._lock:
empty_buffer = Buffer.from_bytes(b"")
self._set(key, empty_buffer)

Check warning on line 249 in src/zarr/storage/_zip.py

Codecov / codecov/patch

src/zarr/storage/_zip.py#L249

Added line #L249 was not covered by tests

async def exists(self, key: str) -> bool:
# docstring inherited