Skip to content

Commit 6d92e49

Browse files
committed
Edit docstrings
1 parent 8f9eb37 commit 6d92e49

1 file changed

Lines changed: 11 additions & 180 deletions

File tree

‎src/zarr_sqlite/zarr_sqlite.py‎

Lines changed: 11 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,23 @@ def _validate_key(key: str):
5050

5151

5252
class SQLiteStore(Store):
53-
"""Single-file SQLite-backed store for Zarr v3 datasets.
54-
55-
Stores a complete Zarr hierarchy inside a single SQLite database file,
56-
providing full ACID guarantees and support for key deletion, overwriting,
57-
and partial value writes.
53+
"""Single-file SQLite-backed store for Zarr datasets.
5854
5955
Parameters
6056
----------
6157
database : str or Path
62-
Path to the SQLite database file (or ``:memory:`` for an in-memory
63-
database).
58+
Path to the SQLite database file, or ``:memory:`` for an in-memory
59+
database. The file will be created if it does not already exist.
6460
read_only : bool, optional
6561
Whether the store is read-only. In-memory databases cannot be opened
66-
read-only.
62+
read-only. Default: False (read-write).
6763
journal_mode : str, optional
6864
SQLite journaling mode. ``"WAL"`` (write-ahead log) or ``"DELETE"``
69-
are supported. Use ``None`` to disable changing the journal mode.
65+
are supported. If ``None``, the journaling mode will be the databases's
66+
previously set value, or SQLite's default for a new database. Default: WAL.
7067
page_size : int, optional
71-
SQLite page size in bytes.
72-
73-
Attributes
74-
----------
75-
database : str
76-
The database path or URI.
77-
supports_writes : bool
78-
Whether the store supports write operations.
79-
supports_deletes : bool
80-
Whether the store supports delete operations.
81-
supports_listing : bool
82-
Whether the store supports listing operations.
83-
read_only : bool
84-
Whether the store is read-only.
68+
SQLite page size in bytes. The default value of 4096 bytes has been found
69+
provide good all-around performance for approximately 1 MB chunks.
8570
"""
8671

8772
_database: str
@@ -95,16 +80,19 @@ class SQLiteStore(Store):
9580
@property
9681
@override
9782
def supports_writes(self) -> bool:
83+
"""`True`"""
9884
return True
9985

10086
@property
10187
@override
10288
def supports_deletes(self) -> bool:
89+
"""`True`"""
10390
return True
10491

10592
@property
10693
@override
10794
def supports_listing(self) -> bool:
95+
"""`True`"""
10896
return True
10997

11098
def __init__(
@@ -231,18 +219,6 @@ async def _open(self) -> None:
231219

232220
@override
233221
def with_read_only(self, read_only: bool = False) -> Self:
234-
"""Return a copy of this store that is read-only or read-write.
235-
236-
Parameters
237-
----------
238-
read_only : bool, optional
239-
Whether the returned store is read-only.
240-
241-
Returns
242-
-------
243-
SQLiteStore
244-
A new store instance with the same database path.
245-
"""
246222
if self.is_in_memory():
247223
raise ValueError("Cannot create a read-only view of an in-memory database.")
248224
return type(self)(self.database, read_only=read_only)
@@ -425,19 +401,6 @@ def _get_text_boundaries(prefix: str) -> tuple[str, str]:
425401

426402
@override
427403
async def is_empty(self, prefix: str) -> bool:
428-
"""Check if the store is empty for a given prefix.
429-
430-
Parameters
431-
----------
432-
prefix : str
433-
The prefix of keys to check. An empty prefix checks whether
434-
any keys exist at all.
435-
436-
Returns
437-
-------
438-
bool
439-
``True`` if no keys with the given prefix exist.
440-
"""
441404
await self._ensure_open()
442405
assert self._conn is not None
443406

@@ -453,7 +416,6 @@ async def is_empty(self, prefix: str) -> bool:
453416

454417
@override
455418
async def clear(self) -> None:
456-
"""Remove all keys and values from the store."""
457419
await self.delete_dir("")
458420

459421
@override
@@ -466,7 +428,6 @@ def __repr__(self) -> str:
466428

467429
@override
468430
def __eq__(self, other: object) -> bool:
469-
"""Equality comparison."""
470431
if not isinstance(other, type(self)):
471432
return False
472433

@@ -482,23 +443,6 @@ async def get(
482443
prototype: BufferPrototype,
483444
byte_range: ByteRequest | None = None,
484445
) -> Buffer | None:
485-
"""Retrieve the value associated with a key.
486-
487-
Parameters
488-
----------
489-
key : str
490-
The key to retrieve.
491-
prototype : BufferPrototype
492-
The prototype of the output buffer.
493-
byte_range : ByteRequest, optional
494-
Optional byte range to retrieve. If not given, the full value is
495-
returned.
496-
497-
Returns
498-
-------
499-
Buffer or None
500-
The value, or ``None`` if the key does not exist.
501-
"""
502446
_validate_key(key)
503447
await self._ensure_open()
504448
assert self._conn is not None
@@ -535,39 +479,12 @@ async def get_partial_values(
535479
prototype: BufferPrototype,
536480
key_ranges: Iterable[tuple[str, ByteRequest | None]],
537481
) -> list[Buffer | None]:
538-
"""Retrieve possibly partial values from given key/range pairs.
539-
540-
Parameters
541-
----------
542-
prototype : BufferPrototype
543-
The prototype of the output buffer.
544-
key_ranges : Iterable[tuple[str, ByteRequest | None]]
545-
Ordered set of key and optional byte-range pairs.
546-
547-
Returns
548-
-------
549-
list[Buffer | None]
550-
A list with one entry per key/range pair, aligned with the
551-
order of ``key_ranges``.
552-
"""
553482
return await asyncio.gather(
554483
*[self.get(key, prototype, byte_range) for key, byte_range in key_ranges]
555484
)
556485

557486
@override
558487
async def exists(self, key: str) -> bool:
559-
"""Check if a key exists in the store.
560-
561-
Parameters
562-
----------
563-
key : str
564-
The key to check.
565-
566-
Returns
567-
-------
568-
bool
569-
``True`` if the key exists, ``False`` otherwise.
570-
"""
571488
_validate_key(key)
572489
await self._ensure_open()
573490
assert self._conn is not None
@@ -600,15 +517,6 @@ async def set(self, key: str, value: Buffer) -> None:
600517

601518
@override
602519
async def set_if_not_exists(self, key: str, value: Buffer) -> None:
603-
"""Store a (key, value) pair only if the key does not already exist.
604-
605-
Parameters
606-
----------
607-
key : str
608-
The key to store under.
609-
value : Buffer
610-
The value to store.
611-
"""
612520
self._check_writable()
613521
_validate_key(key)
614522
await self._ensure_open()
@@ -621,13 +529,6 @@ async def set_if_not_exists(self, key: str, value: Buffer) -> None:
621529

622530
@override
623531
async def delete(self, key: str) -> None:
624-
"""Remove a key from the store.
625-
626-
Parameters
627-
----------
628-
key : str
629-
The key to delete.
630-
"""
631532
self._check_writable()
632533
await self._ensure_open()
633534
assert self._conn is not None
@@ -636,32 +537,13 @@ async def delete(self, key: str) -> None:
636537

637538
@override
638539
async def list(self) -> AsyncIterator[str]:
639-
"""Retrieve all keys in the store.
640-
641-
Yields
642-
------
643-
str
644-
Each key in the store, in no particular order.
645-
"""
646540
await self._ensure_open()
647541
assert self._conn is not None
648542
async for row in self._conn.fetch_iter("SELECT k FROM zarr"):
649543
yield str(row[0])
650544

651545
@override
652546
async def list_prefix(self, prefix: str) -> AsyncIterator[str]:
653-
"""Retrieve all keys beginning with the given prefix.
654-
655-
Parameters
656-
----------
657-
prefix : str
658-
The prefix to match. An empty prefix returns all keys.
659-
660-
Yields
661-
------
662-
str
663-
Each key beginning with ``prefix``.
664-
"""
665547
await self._ensure_open()
666548
assert self._conn is not None
667549
params: Sequence[str] = ()
@@ -675,19 +557,6 @@ async def list_prefix(self, prefix: str) -> AsyncIterator[str]:
675557

676558
@override
677559
async def list_dir(self, prefix: str) -> AsyncIterator[str]:
678-
"""Retrieve all keys and immediate child prefixes with a given prefix.
679-
680-
Parameters
681-
----------
682-
prefix : str
683-
The prefix to match. An empty prefix returns immediate children
684-
of the store root.
685-
686-
Yields
687-
------
688-
str
689-
Each immediate child key or prefix (the latter ending with ``/``).
690-
"""
691560
# Even though prefix will be normalized in list_prefix(), this is
692561
# required for the removeprefix(prefix) call used below.
693562
if prefix != "" and not prefix[-1] == "/":
@@ -707,14 +576,6 @@ async def list_dir(self, prefix: str) -> AsyncIterator[str]:
707576

708577
@override
709578
async def delete_dir(self, prefix: str) -> None:
710-
"""Remove all keys beginning with the given prefix.
711-
712-
Parameters
713-
----------
714-
prefix : str
715-
The prefix of keys to delete. An empty prefix clears the entire
716-
store.
717-
"""
718579
self._check_writable()
719580
await self._ensure_open()
720581

@@ -739,23 +600,6 @@ async def delete_dir(self, prefix: str) -> None:
739600

740601
@override
741602
async def getsize(self, key: str) -> int:
742-
"""Return the size in bytes of a stored value.
743-
744-
Parameters
745-
----------
746-
key : str
747-
The key to look up.
748-
749-
Returns
750-
-------
751-
int
752-
The size of the value, in bytes.
753-
754-
Raises
755-
------
756-
FileNotFoundError
757-
If the key does not exist.
758-
"""
759603
_validate_key(key)
760604
await self._ensure_open()
761605
assert self._conn is not None
@@ -768,19 +612,6 @@ async def getsize(self, key: str) -> int:
768612

769613
@override
770614
async def getsize_prefix(self, prefix: str) -> int:
771-
"""Return the total size in bytes of all values under a prefix.
772-
773-
Parameters
774-
----------
775-
prefix : str
776-
The prefix of keys to measure. An empty prefix means all values
777-
in the store.
778-
779-
Returns
780-
-------
781-
int
782-
The sum of the sizes of all matching values, in bytes.
783-
"""
784615
await self._ensure_open()
785616
assert self._conn is not None
786617
params: Sequence[str] = ()

0 commit comments

Comments
 (0)