-
-
Notifications
You must be signed in to change notification settings - Fork 399
perf/store sync #3725
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
perf/store sync #3725
Changes from 15 commits
2b64daa
cd4efb0
41b7a6a
5a2a884
4e262b1
34b30a1
8cb35d9
9710a74
c0c1b24
b36a2d4
acb6c25
71b6643
748657d
cdfb3c3
25585b9
29d12e6
5f81fba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -187,6 +187,56 @@ def __repr__(self) -> str: | |||||
| def __eq__(self, other: object) -> bool: | ||||||
| return isinstance(other, type(self)) and self.root == other.root | ||||||
|
|
||||||
| # ------------------------------------------------------------------- | ||||||
| # Synchronous store methods | ||||||
| # ------------------------------------------------------------------- | ||||||
|
|
||||||
| def _ensure_open_sync(self) -> None: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this necessary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. in our current zarr-python/src/zarr/storage/_local.py Lines 199 to 200 in b6d3ae2
|
||||||
| if not self._is_open: | ||||||
| if not self.read_only: | ||||||
| self.root.mkdir(parents=True, exist_ok=True) | ||||||
| if not self.root.exists(): | ||||||
| raise FileNotFoundError(f"{self.root} does not exist") | ||||||
| self._is_open = True | ||||||
|
|
||||||
| def get_sync( | ||||||
| self, | ||||||
| key: str, | ||||||
| *, | ||||||
| prototype: BufferPrototype | None = None, | ||||||
| byte_range: ByteRequest | None = None, | ||||||
| ) -> Buffer | None: | ||||||
| if prototype is None: | ||||||
| prototype = default_buffer_prototype() | ||||||
| self._ensure_open_sync() | ||||||
| assert isinstance(key, str) | ||||||
| path = self.root / key | ||||||
| try: | ||||||
| return _get(path, prototype, byte_range) | ||||||
| except (FileNotFoundError, IsADirectoryError, NotADirectoryError): | ||||||
| return None | ||||||
|
|
||||||
| def set_sync(self, key: str, value: Buffer) -> None: | ||||||
| self._ensure_open_sync() | ||||||
| self._check_writable() | ||||||
| assert isinstance(key, str) | ||||||
| if not isinstance(value, Buffer): | ||||||
| raise TypeError( | ||||||
| f"LocalStore.set(): `value` must be a Buffer instance. " | ||||||
| f"Got an instance of {type(value)} instead." | ||||||
| ) | ||||||
| path = self.root / key | ||||||
| _put(path, value) | ||||||
|
|
||||||
| def delete_sync(self, key: str) -> None: | ||||||
| self._ensure_open_sync() | ||||||
| self._check_writable() | ||||||
| path = self.root / key | ||||||
| if path.is_dir(): | ||||||
| shutil.rmtree(path) | ||||||
| else: | ||||||
| path.unlink(missing_ok=True) | ||||||
|
|
||||||
| async def get( | ||||||
| self, | ||||||
| key: str, | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.