zlmdb 25.12.2__cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.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.
- zlmdb/__init__.py +416 -0
- zlmdb/_database.py +990 -0
- zlmdb/_errors.py +31 -0
- zlmdb/_flatc/__init__.py +105 -0
- zlmdb/_lmdb_vendor/__init__.py +37 -0
- zlmdb/_lmdb_vendor/__main__.py +25 -0
- zlmdb/_lmdb_vendor/_config.py +10 -0
- zlmdb/_lmdb_vendor/_lmdb_cffi.cpython-314t-aarch64-linux-gnu.so +0 -0
- zlmdb/_lmdb_vendor/cffi.py +2606 -0
- zlmdb/_lmdb_vendor/tool.py +670 -0
- zlmdb/_meta.py +27 -0
- zlmdb/_pmap.py +1667 -0
- zlmdb/_schema.py +137 -0
- zlmdb/_transaction.py +181 -0
- zlmdb/_types.py +1596 -0
- zlmdb/_version.py +27 -0
- zlmdb/cli.py +41 -0
- zlmdb/flatbuffers/__init__.py +60 -0
- zlmdb/flatbuffers/_git_version.py +24 -0
- zlmdb/flatbuffers/_version.py +17 -0
- zlmdb/flatbuffers/builder.py +824 -0
- zlmdb/flatbuffers/compat.py +89 -0
- zlmdb/flatbuffers/encode.py +43 -0
- zlmdb/flatbuffers/flexbuffers.py +1570 -0
- zlmdb/flatbuffers/number_types.py +182 -0
- zlmdb/flatbuffers/packer.py +42 -0
- zlmdb/flatbuffers/reflection/AdvancedFeatures.py +10 -0
- zlmdb/flatbuffers/reflection/BaseType.py +25 -0
- zlmdb/flatbuffers/reflection/Enum.py +252 -0
- zlmdb/flatbuffers/reflection/EnumVal.py +144 -0
- zlmdb/flatbuffers/reflection/Field.py +325 -0
- zlmdb/flatbuffers/reflection/KeyValue.py +84 -0
- zlmdb/flatbuffers/reflection/Object.py +260 -0
- zlmdb/flatbuffers/reflection/RPCCall.py +195 -0
- zlmdb/flatbuffers/reflection/Schema.py +301 -0
- zlmdb/flatbuffers/reflection/SchemaFile.py +112 -0
- zlmdb/flatbuffers/reflection/Service.py +213 -0
- zlmdb/flatbuffers/reflection/Type.py +148 -0
- zlmdb/flatbuffers/reflection/__init__.py +0 -0
- zlmdb/flatbuffers/reflection.fbs +156 -0
- zlmdb/flatbuffers/table.py +129 -0
- zlmdb/flatbuffers/util.py +47 -0
- zlmdb/py.typed +0 -0
- zlmdb/tests/conftest.py +9 -0
- zlmdb/tests/lmdb/__init__.py +0 -0
- zlmdb/tests/lmdb/address_book.py +287 -0
- zlmdb/tests/lmdb/crash_test.py +339 -0
- zlmdb/tests/lmdb/cursor_test.py +333 -0
- zlmdb/tests/lmdb/env_test.py +919 -0
- zlmdb/tests/lmdb/getmulti_test.py +92 -0
- zlmdb/tests/lmdb/iteration_test.py +258 -0
- zlmdb/tests/lmdb/package_test.py +70 -0
- zlmdb/tests/lmdb/test_lmdb.py +188 -0
- zlmdb/tests/lmdb/testlib.py +185 -0
- zlmdb/tests/lmdb/tool_test.py +60 -0
- zlmdb/tests/lmdb/txn_test.py +575 -0
- zlmdb/tests/orm/MNodeLog.py +853 -0
- zlmdb/tests/orm/__init__.py +0 -0
- zlmdb/tests/orm/_schema_fbs.py +215 -0
- zlmdb/tests/orm/_schema_mnode_log.py +1202 -0
- zlmdb/tests/orm/_schema_py2.py +250 -0
- zlmdb/tests/orm/_schema_py3.py +307 -0
- zlmdb/tests/orm/_test_flatbuffers.py +144 -0
- zlmdb/tests/orm/_test_serialization.py +144 -0
- zlmdb/tests/orm/test_basic.py +217 -0
- zlmdb/tests/orm/test_etcd.py +275 -0
- zlmdb/tests/orm/test_pmap_indexes.py +466 -0
- zlmdb/tests/orm/test_pmap_types.py +90 -0
- zlmdb/tests/orm/test_pmaps.py +295 -0
- zlmdb/tests/orm/test_select.py +619 -0
- zlmdb-25.12.2.dist-info/METADATA +280 -0
- zlmdb-25.12.2.dist-info/RECORD +76 -0
- zlmdb-25.12.2.dist-info/WHEEL +7 -0
- zlmdb-25.12.2.dist-info/entry_points.txt +3 -0
- zlmdb-25.12.2.dist-info/licenses/LICENSE +167 -0
- zlmdb-25.12.2.dist-info/licenses/NOTICE +41 -0
zlmdb/__init__.py
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# The MIT License (MIT)
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) typedef int GmbH
|
|
6
|
+
#
|
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
# furnished to do so, subject to the following conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
|
15
|
+
# all copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
# THE SOFTWARE.
|
|
24
|
+
#
|
|
25
|
+
###############################################################################
|
|
26
|
+
"""ZLMDB - Object-relational zero-copy in-memory database layer for LMDB."""
|
|
27
|
+
|
|
28
|
+
import sys
|
|
29
|
+
import uuid
|
|
30
|
+
|
|
31
|
+
from typing import Dict # noqa
|
|
32
|
+
|
|
33
|
+
# =============================================================================
|
|
34
|
+
# Vendored library aliasing
|
|
35
|
+
# =============================================================================
|
|
36
|
+
# Register vendored flatbuffers runtime in sys.modules so that code doing
|
|
37
|
+
# `import flatbuffers` resolves to our vendored copy. This ensures:
|
|
38
|
+
# 1. No conflicts with separately installed flatbuffers packages
|
|
39
|
+
# 2. Generated code in zlmdb.flatbuffers.reflection can import flatbuffers
|
|
40
|
+
# 3. Consistent behavior across all zlmdb modules
|
|
41
|
+
#
|
|
42
|
+
# Note: This aliasing only affects imports that happen AFTER zlmdb is imported.
|
|
43
|
+
# =============================================================================
|
|
44
|
+
from zlmdb import flatbuffers # noqa: F401
|
|
45
|
+
|
|
46
|
+
sys.modules.setdefault("flatbuffers", flatbuffers)
|
|
47
|
+
# Also register submodules that might be imported directly
|
|
48
|
+
sys.modules.setdefault("flatbuffers.compat", flatbuffers.compat)
|
|
49
|
+
sys.modules.setdefault("flatbuffers.builder", flatbuffers.builder)
|
|
50
|
+
sys.modules.setdefault("flatbuffers.table", flatbuffers.table)
|
|
51
|
+
sys.modules.setdefault("flatbuffers.util", flatbuffers.util)
|
|
52
|
+
sys.modules.setdefault("flatbuffers.number_types", flatbuffers.number_types)
|
|
53
|
+
sys.modules.setdefault("flatbuffers.packer", flatbuffers.packer)
|
|
54
|
+
sys.modules.setdefault("flatbuffers.encode", flatbuffers.encode)
|
|
55
|
+
|
|
56
|
+
# Re-export vendored LMDB for backwards compatibility
|
|
57
|
+
# Users can do: `from zlmdb import lmdb` or `import zlmdb.lmdb as lmdb`
|
|
58
|
+
from zlmdb import _lmdb_vendor
|
|
59
|
+
|
|
60
|
+
lmdb = _lmdb_vendor # noqa: F401
|
|
61
|
+
|
|
62
|
+
# Also register zlmdb.lmdb in sys.modules for backward compatibility
|
|
63
|
+
# This allows `import zlmdb.lmdb as lmdb` to work
|
|
64
|
+
sys.modules.setdefault("zlmdb.lmdb", _lmdb_vendor)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def setup_flatbuffers_import():
|
|
68
|
+
"""
|
|
69
|
+
Register vendored flatbuffers in sys.modules so `import flatbuffers` works.
|
|
70
|
+
|
|
71
|
+
This function should be called by downstream packages (e.g. cfxdb) that have
|
|
72
|
+
generated flatbuffers code which does `import flatbuffers`. By calling this
|
|
73
|
+
function early in their initialization, they ensure that:
|
|
74
|
+
|
|
75
|
+
1. `import flatbuffers` resolves to zlmdb's vendored copy
|
|
76
|
+
2. No conflicts with separately installed flatbuffers packages
|
|
77
|
+
3. Consistent behavior across all modules
|
|
78
|
+
|
|
79
|
+
Example usage in downstream package __init__.py::
|
|
80
|
+
|
|
81
|
+
import zlmdb
|
|
82
|
+
zlmdb.setup_flatbuffers_import()
|
|
83
|
+
|
|
84
|
+
# Now generated code can do `import flatbuffers`
|
|
85
|
+
from .gen import MyTable
|
|
86
|
+
"""
|
|
87
|
+
sys.modules.setdefault("flatbuffers", flatbuffers)
|
|
88
|
+
sys.modules.setdefault("flatbuffers.compat", flatbuffers.compat)
|
|
89
|
+
sys.modules.setdefault("flatbuffers.builder", flatbuffers.builder)
|
|
90
|
+
sys.modules.setdefault("flatbuffers.table", flatbuffers.table)
|
|
91
|
+
sys.modules.setdefault("flatbuffers.util", flatbuffers.util)
|
|
92
|
+
sys.modules.setdefault("flatbuffers.number_types", flatbuffers.number_types)
|
|
93
|
+
sys.modules.setdefault("flatbuffers.packer", flatbuffers.packer)
|
|
94
|
+
sys.modules.setdefault("flatbuffers.encode", flatbuffers.encode)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def check_autobahn_flatbuffers_version_in_sync() -> str:
|
|
98
|
+
"""
|
|
99
|
+
Check that zlmdb and autobahn have the same vendored flatbuffers version.
|
|
100
|
+
|
|
101
|
+
This is important for applications like Crossbar.io that use both zlmdb
|
|
102
|
+
(for data-at-rest) and autobahn (for data-in-transit) with FlatBuffers
|
|
103
|
+
serialization. When sending a FlatBuffers database record as a WAMP
|
|
104
|
+
application payload, both libraries must use compatible FlatBuffers
|
|
105
|
+
runtimes to avoid subtle serialization issues.
|
|
106
|
+
|
|
107
|
+
:returns: The flatbuffers git version (e.g. "v25.9.23-2-g95053e6a") if both are in sync.
|
|
108
|
+
:raises RuntimeError: If the versions differ.
|
|
109
|
+
:raises ImportError: If autobahn is not installed.
|
|
110
|
+
|
|
111
|
+
Example::
|
|
112
|
+
|
|
113
|
+
import zlmdb
|
|
114
|
+
version = zlmdb.check_autobahn_flatbuffers_version_in_sync()
|
|
115
|
+
print(f"FlatBuffers version: {version}")
|
|
116
|
+
"""
|
|
117
|
+
import autobahn.flatbuffers
|
|
118
|
+
|
|
119
|
+
zlmdb_version = flatbuffers.version()
|
|
120
|
+
autobahn_version = autobahn.flatbuffers.version()
|
|
121
|
+
|
|
122
|
+
if zlmdb_version != autobahn_version:
|
|
123
|
+
raise RuntimeError(
|
|
124
|
+
f"FlatBuffers version mismatch: zlmdb has {zlmdb_version!r}, "
|
|
125
|
+
f"autobahn has {autobahn_version!r}. Both should be the same for "
|
|
126
|
+
f"reliable data-at-rest/data-in-transit interoperability."
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
return zlmdb_version
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
from ._version import __version__
|
|
133
|
+
|
|
134
|
+
from ._errors import NullValueConstraint
|
|
135
|
+
|
|
136
|
+
from ._pmap import (
|
|
137
|
+
PersistentMap,
|
|
138
|
+
MapSlotUuidUuid,
|
|
139
|
+
MapUuidString,
|
|
140
|
+
MapUuidOid,
|
|
141
|
+
MapUuidUuid,
|
|
142
|
+
MapUuidJson,
|
|
143
|
+
MapUuidCbor,
|
|
144
|
+
MapUuidPickle,
|
|
145
|
+
MapUuidFlatBuffers,
|
|
146
|
+
MapUuidTimestampFlatBuffers,
|
|
147
|
+
MapUuidBytes20Uint8FlatBuffers,
|
|
148
|
+
MapUuidBytes20Uint8UuidFlatBuffers,
|
|
149
|
+
MapUuidBytes20Bytes20Uint8UuidFlatBuffers,
|
|
150
|
+
MapUuidTimestampCbor,
|
|
151
|
+
MapTimestampFlatBuffers,
|
|
152
|
+
MapTimestampStringFlatBuffers,
|
|
153
|
+
MapTimestampUuidFlatBuffers,
|
|
154
|
+
MapTimestampUuidStringFlatBuffers,
|
|
155
|
+
MapUuidTimestampUuidFlatBuffers,
|
|
156
|
+
MapUint64TimestampUuid,
|
|
157
|
+
MapTimestampUuidCbor,
|
|
158
|
+
MapUuidTimestampUuid,
|
|
159
|
+
MapUuidStringUuid,
|
|
160
|
+
MapUuidUuidStringUuid,
|
|
161
|
+
MapUuidUuidUuidStringUuid,
|
|
162
|
+
MapUuidStringOid,
|
|
163
|
+
MapUuidUuidCbor,
|
|
164
|
+
MapUuidUuidSet,
|
|
165
|
+
MapUuidUuidUuid,
|
|
166
|
+
MapUuidUuidUuidUuid,
|
|
167
|
+
MapUuidUuidUuidUuidUuid,
|
|
168
|
+
MapUuidTimestampBytes32,
|
|
169
|
+
MapUuidUuidFlatBuffers,
|
|
170
|
+
MapUuidUuidStringFlatBuffers,
|
|
171
|
+
MapUuidStringFlatBuffers,
|
|
172
|
+
MapStringString,
|
|
173
|
+
MapStringOid,
|
|
174
|
+
MapStringOidOid,
|
|
175
|
+
MapStringUuid,
|
|
176
|
+
MapStringStringUuid,
|
|
177
|
+
MapStringStringStringUuid,
|
|
178
|
+
MapStringJson,
|
|
179
|
+
MapStringCbor,
|
|
180
|
+
MapStringPickle,
|
|
181
|
+
MapStringFlatBuffers,
|
|
182
|
+
MapStringTimestampCbor,
|
|
183
|
+
MapTimestampStringCbor,
|
|
184
|
+
MapOidString,
|
|
185
|
+
MapOidOid,
|
|
186
|
+
MapOidUuid,
|
|
187
|
+
MapOidJson,
|
|
188
|
+
MapOidCbor,
|
|
189
|
+
MapOidPickle,
|
|
190
|
+
MapOidFlatBuffers,
|
|
191
|
+
MapOidOidFlatBuffers,
|
|
192
|
+
MapOid3FlatBuffers,
|
|
193
|
+
MapOidOidSet,
|
|
194
|
+
MapOidStringOid,
|
|
195
|
+
MapOidOidOid,
|
|
196
|
+
MapOidTimestampOid,
|
|
197
|
+
MapOidTimestampFlatBuffers,
|
|
198
|
+
MapOidTimestampStringOid,
|
|
199
|
+
MapUint16UuidTimestampFlatBuffers,
|
|
200
|
+
MapBytes32Uuid,
|
|
201
|
+
MapBytes32Timestamp,
|
|
202
|
+
MapBytes32Bytes32,
|
|
203
|
+
MapBytes32FlatBuffers,
|
|
204
|
+
MapBytes32UuidFlatBuffers,
|
|
205
|
+
MapUuidBytes32FlatBuffers,
|
|
206
|
+
MapBytes32Bytes32FlatBuffers,
|
|
207
|
+
MapBytes32StringFlatBuffers,
|
|
208
|
+
MapTimestampBytes32FlatBuffers,
|
|
209
|
+
MapBytes20Uuid,
|
|
210
|
+
MapBytes20Bytes16,
|
|
211
|
+
MapBytes20Bytes20,
|
|
212
|
+
MapBytes20Bytes20Timestamp,
|
|
213
|
+
MapBytes20TimestampBytes20,
|
|
214
|
+
MapBytes20TimestampUuid,
|
|
215
|
+
MapBytes16FlatBuffers,
|
|
216
|
+
MapBytes16TimestampUuid,
|
|
217
|
+
MapBytes16TimestampUuidFlatBuffers,
|
|
218
|
+
MapBytes20FlatBuffers,
|
|
219
|
+
MapBytes20Bytes20FlatBuffers,
|
|
220
|
+
MapBytes20StringFlatBuffers,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
from ._transaction import Transaction, TransactionStats
|
|
224
|
+
from ._database import Database
|
|
225
|
+
from ._schema import Schema
|
|
226
|
+
|
|
227
|
+
__all__ = (
|
|
228
|
+
"__version__",
|
|
229
|
+
"flatbuffers", # Re-exported vendored flatbuffers (zlmdb._flatbuffers_vendor)
|
|
230
|
+
"setup_flatbuffers_import", # Helper for downstream packages
|
|
231
|
+
"check_autobahn_flatbuffers_version_in_sync", # Version sync check with autobahn
|
|
232
|
+
"lmdb", # Re-exported vendored LMDB (zlmdb._lmdb_vendor)
|
|
233
|
+
"Schema",
|
|
234
|
+
"Database",
|
|
235
|
+
"Transaction",
|
|
236
|
+
"TransactionStats",
|
|
237
|
+
"MapSlotUuidUuid",
|
|
238
|
+
"table",
|
|
239
|
+
#
|
|
240
|
+
# Errors
|
|
241
|
+
#
|
|
242
|
+
"NullValueConstraint",
|
|
243
|
+
#
|
|
244
|
+
# UUID pmaps
|
|
245
|
+
#
|
|
246
|
+
# UUID (uint128) based pmap types for object containers
|
|
247
|
+
"MapUuidString",
|
|
248
|
+
"MapUuidOid",
|
|
249
|
+
"MapUuidJson",
|
|
250
|
+
"MapUuidCbor",
|
|
251
|
+
"MapUuidPickle",
|
|
252
|
+
"MapUuidFlatBuffers",
|
|
253
|
+
# UUID/Timestamp-combined pmap types for flatbuffers values
|
|
254
|
+
"MapUuidTimestampFlatBuffers",
|
|
255
|
+
"MapTimestampUuidFlatBuffers",
|
|
256
|
+
"MapTimestampFlatBuffers",
|
|
257
|
+
"MapTimestampStringFlatBuffers",
|
|
258
|
+
"MapTimestampUuidStringFlatBuffers",
|
|
259
|
+
"MapUuidTimestampUuidFlatBuffers",
|
|
260
|
+
"MapUuidBytes20Uint8FlatBuffers",
|
|
261
|
+
"MapUuidBytes20Uint8UuidFlatBuffers",
|
|
262
|
+
"MapUuidBytes20Bytes20Uint8UuidFlatBuffers",
|
|
263
|
+
"MapUint16UuidTimestampFlatBuffers",
|
|
264
|
+
# UUID (uint128) based pmap types for indexes
|
|
265
|
+
"MapUuidUuid",
|
|
266
|
+
"MapUuidStringUuid",
|
|
267
|
+
"MapUuidUuidStringUuid",
|
|
268
|
+
"MapUuidUuidUuidStringUuid",
|
|
269
|
+
"MapUint64TimestampUuid",
|
|
270
|
+
# more UUID (uint128) based pmap types for indexes
|
|
271
|
+
"MapUuidUuidSet",
|
|
272
|
+
"MapUuidStringOid",
|
|
273
|
+
# UUID-UUID based pmap types
|
|
274
|
+
"MapUuidUuidFlatBuffers",
|
|
275
|
+
"MapUuidStringFlatBuffers",
|
|
276
|
+
"MapUuidUuidCbor",
|
|
277
|
+
"MapUuidUuidUuid",
|
|
278
|
+
"MapUuidUuidUuidUuid",
|
|
279
|
+
"MapUuidUuidUuidUuidUuid",
|
|
280
|
+
"MapUuidTimestampUuid",
|
|
281
|
+
"MapUuidTimestampBytes32",
|
|
282
|
+
"MapUuidTimestampCbor",
|
|
283
|
+
"MapTimestampUuidCbor",
|
|
284
|
+
#
|
|
285
|
+
# String pmaps
|
|
286
|
+
#
|
|
287
|
+
# String (utf8) based pmap types for object containers
|
|
288
|
+
"MapStringUuid",
|
|
289
|
+
"MapStringStringUuid",
|
|
290
|
+
"MapStringStringStringUuid",
|
|
291
|
+
"MapStringOid",
|
|
292
|
+
"MapStringOidOid",
|
|
293
|
+
"MapStringJson",
|
|
294
|
+
"MapStringCbor",
|
|
295
|
+
"MapStringPickle",
|
|
296
|
+
"MapStringFlatBuffers",
|
|
297
|
+
"MapStringTimestampCbor",
|
|
298
|
+
"MapTimestampStringCbor",
|
|
299
|
+
# String (utf8) based pmap types for indexes
|
|
300
|
+
"MapStringString",
|
|
301
|
+
#
|
|
302
|
+
# OID pmaps
|
|
303
|
+
#
|
|
304
|
+
# OID (uint64) based pmap types for object containers
|
|
305
|
+
"MapOidString",
|
|
306
|
+
"MapOidUuid",
|
|
307
|
+
"MapOidJson",
|
|
308
|
+
"MapOidCbor",
|
|
309
|
+
"MapOidPickle",
|
|
310
|
+
"MapOidFlatBuffers",
|
|
311
|
+
"MapOidOidFlatBuffers",
|
|
312
|
+
"MapOidTimestampFlatBuffers",
|
|
313
|
+
"MapOid3FlatBuffers",
|
|
314
|
+
# OID (uint64) based pmap types for indexes
|
|
315
|
+
"MapOidOid",
|
|
316
|
+
"MapOidOidSet",
|
|
317
|
+
"MapOidStringOid",
|
|
318
|
+
"MapOidOidOid",
|
|
319
|
+
"MapOidTimestampOid",
|
|
320
|
+
"MapOidTimestampStringOid",
|
|
321
|
+
#
|
|
322
|
+
# Bytes32 pmaps
|
|
323
|
+
#
|
|
324
|
+
"MapBytes32Uuid",
|
|
325
|
+
"MapBytes32Timestamp",
|
|
326
|
+
"MapBytes32Bytes32",
|
|
327
|
+
"MapBytes32FlatBuffers",
|
|
328
|
+
"MapBytes32UuidFlatBuffers",
|
|
329
|
+
"MapUuidBytes32FlatBuffers",
|
|
330
|
+
"MapBytes32Bytes32FlatBuffers",
|
|
331
|
+
"MapBytes32StringFlatBuffers",
|
|
332
|
+
"MapTimestampBytes32FlatBuffers",
|
|
333
|
+
"MapUuidUuidStringFlatBuffers",
|
|
334
|
+
#
|
|
335
|
+
# Bytes20 pmaps
|
|
336
|
+
#
|
|
337
|
+
"MapBytes20Uuid",
|
|
338
|
+
"MapBytes20Bytes16",
|
|
339
|
+
"MapBytes20Bytes20",
|
|
340
|
+
"MapBytes20Bytes20Timestamp",
|
|
341
|
+
"MapBytes20TimestampBytes20",
|
|
342
|
+
"MapBytes20TimestampUuid",
|
|
343
|
+
"MapBytes20FlatBuffers",
|
|
344
|
+
"MapBytes20Bytes20FlatBuffers",
|
|
345
|
+
"MapBytes20StringFlatBuffers",
|
|
346
|
+
#
|
|
347
|
+
# Bytes16 pmaps
|
|
348
|
+
#
|
|
349
|
+
"MapBytes16FlatBuffers",
|
|
350
|
+
"MapBytes16TimestampUuid",
|
|
351
|
+
"MapBytes16TimestampUuidFlatBuffers",
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
TABLES_BY_UUID: Dict[uuid.UUID, PersistentMap] = {}
|
|
355
|
+
"""
|
|
356
|
+
Map of table UUIDs to persistent maps stored in slots in a KV store.
|
|
357
|
+
"""
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def table(oid, marshal=None, parse=None, build=None, cast=None, compress=None):
|
|
361
|
+
if type(oid) == str:
|
|
362
|
+
oid = uuid.UUID(oid)
|
|
363
|
+
|
|
364
|
+
assert isinstance(oid, uuid.UUID)
|
|
365
|
+
assert marshal is None or callable(marshal)
|
|
366
|
+
assert parse is None or callable(parse)
|
|
367
|
+
assert build is None or callable(build)
|
|
368
|
+
assert cast is None or callable(cast)
|
|
369
|
+
assert compress is None or compress in [
|
|
370
|
+
PersistentMap.COMPRESS_ZLIB,
|
|
371
|
+
PersistentMap.COMPRESS_SNAPPY,
|
|
372
|
+
]
|
|
373
|
+
|
|
374
|
+
def decorate(o):
|
|
375
|
+
if oid in TABLES_BY_UUID:
|
|
376
|
+
assert TABLES_BY_UUID[oid]._zlmdb_oid == oid, "{} != {}".format(
|
|
377
|
+
TABLES_BY_UUID[oid]._zlmdb_oid, oid
|
|
378
|
+
)
|
|
379
|
+
assert TABLES_BY_UUID[oid]._zlmdb_marshal == marshal, "{} != {}".format(
|
|
380
|
+
TABLES_BY_UUID[oid]._zlmdb_marshal, marshal
|
|
381
|
+
)
|
|
382
|
+
assert TABLES_BY_UUID[oid]._zlmdb_parse == parse, "{} != {}".format(
|
|
383
|
+
TABLES_BY_UUID[oid]._zlmdb_parse, parse
|
|
384
|
+
)
|
|
385
|
+
assert TABLES_BY_UUID[oid]._zlmdb_build == build, "{} != {}".format(
|
|
386
|
+
TABLES_BY_UUID[oid]._zlmdb_build, build
|
|
387
|
+
)
|
|
388
|
+
assert TABLES_BY_UUID[oid]._zlmdb_cast == cast, "{} != {}".format(
|
|
389
|
+
TABLES_BY_UUID[oid]._zlmdb_cast, cast
|
|
390
|
+
)
|
|
391
|
+
assert TABLES_BY_UUID[oid]._zlmdb_compress == compress, "{} != {}".format(
|
|
392
|
+
TABLES_BY_UUID[oid]._zlmdb_compress, compress
|
|
393
|
+
)
|
|
394
|
+
return
|
|
395
|
+
assert oid not in TABLES_BY_UUID, (
|
|
396
|
+
"oid {} already in map (pointing to {})".format(oid, TABLES_BY_UUID[oid])
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
# slot UUID that is mapped to a slot index later when attaching to db
|
|
400
|
+
o._zlmdb_oid = oid
|
|
401
|
+
|
|
402
|
+
# for CBOR/JSON
|
|
403
|
+
o._zlmdb_marshal = marshal
|
|
404
|
+
o._zlmdb_parse = parse
|
|
405
|
+
|
|
406
|
+
# for Flatbuffers
|
|
407
|
+
o._zlmdb_build = build
|
|
408
|
+
o._zlmdb_cast = cast
|
|
409
|
+
|
|
410
|
+
# for value compression
|
|
411
|
+
o._zlmdb_compress = compress
|
|
412
|
+
|
|
413
|
+
TABLES_BY_UUID[oid] = o
|
|
414
|
+
return o
|
|
415
|
+
|
|
416
|
+
return decorate
|