proto-db 2.0.0rc3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- proto_db/__init__.py +141 -0
- proto_db/cluster/__init__.py +1 -0
- proto_db/cluster/coordinator.py +4279 -0
- proto_db/cluster/lease.py +429 -0
- proto_db/cluster/persister.py +493 -0
- proto_db/cluster/protocol.py +408 -0
- proto_db/cluster/rootlog.py +723 -0
- proto_db/cluster/transport.py +565 -0
- proto_db/collections/__init__.py +1 -0
- proto_db/collections/avl.py +878 -0
- proto_db/collections/base.py +631 -0
- proto_db/collections/dictionaries.py +429 -0
- proto_db/collections/hash_dictionaries.py +187 -0
- proto_db/collections/lists.py +160 -0
- proto_db/collections/sets.py +411 -0
- proto_db/core/__init__.py +5 -0
- proto_db/core/atom.py +1233 -0
- proto_db/core/codec.py +735 -0
- proto_db/core/dbobject.py +125 -0
- proto_db/errors.py +164 -0
- proto_db/indexing/__init__.py +32 -0
- proto_db/indexing/base.py +338 -0
- proto_db/indexing/equality.py +35 -0
- proto_db/indexing/keyed.py +737 -0
- proto_db/indexing/keyspec.py +265 -0
- proto_db/indexing/range.py +58 -0
- proto_db/indexing/vector.py +429 -0
- proto_db/indexing/vector_backends.py +832 -0
- proto_db/interop/__init__.py +4 -0
- proto_db/interop/arrow.py +308 -0
- proto_db/query/__init__.py +15 -0
- proto_db/query/cache.py +533 -0
- proto_db/query/expressions.py +357 -0
- proto_db/query/linq.py +1179 -0
- proto_db/query/pager.py +294 -0
- proto_db/query/planner.py +343 -0
- proto_db/query/plans.py +1099 -0
- proto_db/query/terms.py +333 -0
- proto_db/runtime/__init__.py +5 -0
- proto_db/runtime/fsm.py +446 -0
- proto_db/runtime/parallel.py +458 -0
- proto_db/storage/__init__.py +1 -0
- proto_db/storage/base.py +125 -0
- proto_db/storage/cache.py +148 -0
- proto_db/storage/cloud.py +894 -0
- proto_db/storage/crc.py +114 -0
- proto_db/storage/file.py +842 -0
- proto_db/storage/format.py +228 -0
- proto_db/storage/logfile.py +338 -0
- proto_db/storage/memory.py +135 -0
- proto_db/storage/ownerlock.py +221 -0
- proto_db/storage/tiered.py +2353 -0
- proto_db/tools/__init__.py +1 -0
- proto_db/tools/notation.py +182 -0
- proto_db/tools/verify.py +329 -0
- proto_db/transactions.py +2302 -0
- proto_db/values.py +975 -0
- proto_db-2.0.0rc3.dist-info/METADATA +315 -0
- proto_db-2.0.0rc3.dist-info/RECORD +62 -0
- proto_db-2.0.0rc3.dist-info/WHEEL +5 -0
- proto_db-2.0.0rc3.dist-info/licenses/LICENSE +21 -0
- proto_db-2.0.0rc3.dist-info/top_level.txt +1 -0
proto_db/__init__.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""proto_db: an embedded, transactional, object-oriented database for Python.
|
|
2
|
+
|
|
3
|
+
This module is the public API of proto_db 2.0 (spec section 3, decision D15; the
|
|
4
|
+
exported surface is decision D47). Every name listed in ``__all__`` is re-exported
|
|
5
|
+
from the subpackage that defines it:
|
|
6
|
+
|
|
7
|
+
- transactions: :class:`ObjectSpace`, :class:`Database`, :class:`Transaction`
|
|
8
|
+
- atoms and records: :class:`Atom`, :class:`DBObject`, :class:`MutableObject`
|
|
9
|
+
- collections: :class:`List`, :class:`Dictionary`, :class:`RepeatedKeysDictionary`,
|
|
10
|
+
:class:`HashDictionary`, :class:`Set`, :class:`CountedSet`
|
|
11
|
+
- indexes: :class:`EqualityIndex`, :class:`RangeIndex`, :class:`VectorIndex`,
|
|
12
|
+
:class:`KeySpec` and the :class:`Index` base for custom indexes
|
|
13
|
+
- queries: :func:`from_collection` and ``F`` (LINQ front end), :class:`Term`,
|
|
14
|
+
:class:`And`, :class:`Or`, :class:`Not`, :func:`plan_query`
|
|
15
|
+
- storages: :class:`MemoryStorage`, :class:`FileStorage`, :class:`CloudStorage`
|
|
16
|
+
(with :class:`S3ObjectStore` / :class:`GCSObjectStore`), :class:`TieredStorage`
|
|
17
|
+
- clusters: :class:`ClusterCoordinator`, :class:`Peer`, :class:`TcpTransport`
|
|
18
|
+
- runtime services: :func:`parallel_scan`, :func:`parallel_filter`, :class:`FSM`
|
|
19
|
+
- Arrow/Parquet bridge: :func:`to_arrow`, :func:`to_parquet`, :func:`scan_parquet`
|
|
20
|
+
- the value model (:func:`canonical`, :func:`values_equal`, ``MISSING``) and the
|
|
21
|
+
exception hierarchy rooted at :class:`ProtoDBError` (D12)
|
|
22
|
+
|
|
23
|
+
Every name is resolved lazily, on first access (PEP 562): ``import proto_db``
|
|
24
|
+
imports no submodule, no optional third-party package (boto3, google-cloud-storage,
|
|
25
|
+
numpy, pyarrow, hnswlib) and starts no thread. Importing a name imports only the
|
|
26
|
+
subpackage that defines it; optional dependencies are imported later still, when a
|
|
27
|
+
feature that needs them is first used.
|
|
28
|
+
"""
|
|
29
|
+
from importlib import import_module
|
|
30
|
+
from typing import TYPE_CHECKING
|
|
31
|
+
|
|
32
|
+
__version__ = "2.0.0.dev0"
|
|
33
|
+
|
|
34
|
+
#: Public name -> module (relative to this package) that defines it.
|
|
35
|
+
_EXPORTS = {
|
|
36
|
+
# transactions
|
|
37
|
+
"ObjectSpace": "transactions", "Database": "transactions", "Transaction": "transactions",
|
|
38
|
+
"HistoryEntry": "transactions", "Snapshot": "transactions",
|
|
39
|
+
# atoms and records
|
|
40
|
+
"Atom": "core.atom", "AtomPointer": "core.atom", "PersistenceContext": "core.atom",
|
|
41
|
+
"register_atom_class": "core.atom", "DBObject": "core.dbobject", "MutableObject": "core.dbobject",
|
|
42
|
+
# collections
|
|
43
|
+
"IndexedCollection": "collections.base", "ConcurrentOptimized": "collections.base",
|
|
44
|
+
"List": "collections.lists", "Dictionary": "collections.dictionaries",
|
|
45
|
+
"RepeatedKeysDictionary": "collections.dictionaries", "HashDictionary": "collections.hash_dictionaries",
|
|
46
|
+
"Set": "collections.sets", "CountedSet": "collections.sets",
|
|
47
|
+
# indexes
|
|
48
|
+
"Index": "indexing.base", "KeySpec": "indexing.keyspec", "register_extractor": "indexing.keyspec",
|
|
49
|
+
"unregister_extractor": "indexing.keyspec",
|
|
50
|
+
"EqualityIndex": "indexing.equality", "RangeIndex": "indexing.range", "VectorIndex": "indexing.vector",
|
|
51
|
+
# queries
|
|
52
|
+
"Expression": "query.expressions", "Term": "query.terms", "NearQuery": "query.terms",
|
|
53
|
+
"And": "query.expressions", "Or": "query.expressions", "Not": "query.expressions",
|
|
54
|
+
"evaluate": "query.expressions", "QueryPlan": "query.plans", "plan_query": "query.planner",
|
|
55
|
+
"from_collection": "query.linq", "Queryable": "query.linq", "F": "query.linq", "Agg": "query.linq",
|
|
56
|
+
"QueryCache": "query.cache", "QueryResult": "query.cache", "Pager": "query.pager",
|
|
57
|
+
# storages
|
|
58
|
+
"SharedStorage": "storage.base", "MemoryStorage": "storage.memory", "FileStorage": "storage.file",
|
|
59
|
+
"CloudStorage": "storage.cloud", "ObjectStore": "storage.cloud", "S3ObjectStore": "storage.cloud",
|
|
60
|
+
"GCSObjectStore": "storage.cloud", "TieredStorage": "storage.tiered",
|
|
61
|
+
# clusters
|
|
62
|
+
"ClusterCoordinator": "cluster.coordinator", "Peer": "cluster.coordinator", "TcpTransport": "cluster.transport",
|
|
63
|
+
# runtime services
|
|
64
|
+
"parallel_scan": "runtime.parallel", "parallel_filter": "runtime.parallel", "ParallelConfig": "runtime.parallel",
|
|
65
|
+
"ParallelPool": "runtime.parallel", "FSM": "runtime.fsm", "Timer": "runtime.fsm",
|
|
66
|
+
# Arrow / Parquet bridge
|
|
67
|
+
"to_arrow": "interop.arrow", "to_parquet": "interop.arrow", "scan_parquet": "interop.arrow",
|
|
68
|
+
"from_parquet_to_rows": "interop.arrow",
|
|
69
|
+
# value model
|
|
70
|
+
"MISSING": "values", "canonical": "values", "values_equal": "values", "order_key": "values",
|
|
71
|
+
"hash_key": "values", "FrozenList": "values", "FrozenDict": "values",
|
|
72
|
+
# errors (D12); the *Exception names are the 0.1 spellings: deprecated aliases, removed in 2.1
|
|
73
|
+
"ProtoDBError": "errors", "ProtoValidationError": "errors", "ProtoUserError": "errors",
|
|
74
|
+
"ProtoCorruptionError": "errors", "ProtoMisfiledError": "errors", "ProtoNotSupportedError": "errors", "ProtoNotAuthorizedError": "errors",
|
|
75
|
+
"ProtoUnexpectedError": "errors", "ProtoOutcomeUnknownError": "errors", "ProtoBacklogFullError": "errors",
|
|
76
|
+
"ProtoLockingError": "errors", "ProtoConflictError": "errors", "ProtoTimeoutError": "errors",
|
|
77
|
+
"ProtoReferenceError": "errors", "ProtoStalePagerError": "errors", "ProtoClosedError": "errors",
|
|
78
|
+
"ProtoBaseException": "errors", "ProtoValidationException": "errors", "ProtoUserException": "errors",
|
|
79
|
+
"ProtoCorruptionException": "errors", "ProtoNotSupportedException": "errors",
|
|
80
|
+
"ProtoNotAuthorizedException": "errors", "ProtoUnexpectedException": "errors",
|
|
81
|
+
"ProtoLockingException": "errors",
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
__all__ = list(_EXPORTS)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def __getattr__(name):
|
|
88
|
+
"""Resolve a public name on first access (PEP 562) and cache it in the module namespace."""
|
|
89
|
+
module = _EXPORTS.get(name)
|
|
90
|
+
if module is None:
|
|
91
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
92
|
+
value = getattr(import_module(f".{module}", __name__), name)
|
|
93
|
+
globals()[name] = value
|
|
94
|
+
return value
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def __dir__():
|
|
98
|
+
"""The module's attributes, including the public names not resolved yet."""
|
|
99
|
+
return sorted(set(globals()) | set(_EXPORTS))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if TYPE_CHECKING: # pragma: no cover - static analysers only; never executed
|
|
103
|
+
from .cluster.coordinator import ClusterCoordinator, Peer
|
|
104
|
+
from .cluster.transport import TcpTransport
|
|
105
|
+
from .collections.base import ConcurrentOptimized, IndexedCollection
|
|
106
|
+
from .collections.dictionaries import Dictionary, RepeatedKeysDictionary
|
|
107
|
+
from .collections.hash_dictionaries import HashDictionary
|
|
108
|
+
from .collections.lists import List
|
|
109
|
+
from .collections.sets import CountedSet, Set
|
|
110
|
+
from .core.atom import Atom, AtomPointer, PersistenceContext, register_atom_class
|
|
111
|
+
from .core.dbobject import DBObject, MutableObject
|
|
112
|
+
from .errors import (ProtoBacklogFullError, ProtoBaseException, ProtoConflictError, ProtoCorruptionError,
|
|
113
|
+
ProtoCorruptionException, ProtoDBError, ProtoLockingError, ProtoLockingException,
|
|
114
|
+
ProtoMisfiledError,
|
|
115
|
+
ProtoNotAuthorizedError, ProtoNotAuthorizedException, ProtoNotSupportedError,
|
|
116
|
+
ProtoNotSupportedException, ProtoOutcomeUnknownError, ProtoReferenceError,
|
|
117
|
+
ProtoClosedError, ProtoStalePagerError, ProtoTimeoutError,
|
|
118
|
+
ProtoUnexpectedError, ProtoUnexpectedException, ProtoUserError, ProtoUserException,
|
|
119
|
+
ProtoValidationError, ProtoValidationException)
|
|
120
|
+
from .indexing.base import Index
|
|
121
|
+
from .indexing.equality import EqualityIndex
|
|
122
|
+
from .indexing.keyspec import KeySpec, register_extractor, unregister_extractor
|
|
123
|
+
from .indexing.range import RangeIndex
|
|
124
|
+
from .indexing.vector import VectorIndex
|
|
125
|
+
from .interop.arrow import from_parquet_to_rows, scan_parquet, to_arrow, to_parquet
|
|
126
|
+
from .query.cache import QueryCache, QueryResult
|
|
127
|
+
from .query.expressions import And, Expression, Not, Or, evaluate
|
|
128
|
+
from .query.linq import Agg, F, Queryable, from_collection
|
|
129
|
+
from .query.pager import Pager
|
|
130
|
+
from .query.planner import plan_query
|
|
131
|
+
from .query.plans import QueryPlan
|
|
132
|
+
from .query.terms import NearQuery, Term
|
|
133
|
+
from .runtime.fsm import FSM, Timer
|
|
134
|
+
from .runtime.parallel import ParallelConfig, ParallelPool, parallel_filter, parallel_scan
|
|
135
|
+
from .storage.base import SharedStorage
|
|
136
|
+
from .storage.cloud import CloudStorage, GCSObjectStore, ObjectStore, S3ObjectStore
|
|
137
|
+
from .storage.file import FileStorage
|
|
138
|
+
from .storage.memory import MemoryStorage
|
|
139
|
+
from .storage.tiered import TieredStorage
|
|
140
|
+
from .transactions import Database, HistoryEntry, ObjectSpace, Snapshot, Transaction
|
|
141
|
+
from .values import MISSING, FrozenDict, FrozenList, canonical, hash_key, order_key, values_equal
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Cluster coordination: majority-granted write lease and peer-to-peer root propagation (D44, D45)."""
|