zlmdb 25.10.1__cp314-cp314-win_amd64.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.

Potentially problematic release.


This version of zlmdb might be problematic. Click here for more details.

Files changed (86) hide show
  1. flatbuffers/__init__.py +19 -0
  2. flatbuffers/_version.py +17 -0
  3. flatbuffers/builder.py +776 -0
  4. flatbuffers/compat.py +86 -0
  5. flatbuffers/encode.py +42 -0
  6. flatbuffers/flexbuffers.py +1527 -0
  7. flatbuffers/number_types.py +181 -0
  8. flatbuffers/packer.py +42 -0
  9. flatbuffers/reflection/AdvancedFeatures.py +10 -0
  10. flatbuffers/reflection/BaseType.py +24 -0
  11. flatbuffers/reflection/Enum.py +169 -0
  12. flatbuffers/reflection/EnumVal.py +96 -0
  13. flatbuffers/reflection/Field.py +208 -0
  14. flatbuffers/reflection/KeyValue.py +56 -0
  15. flatbuffers/reflection/Object.py +175 -0
  16. flatbuffers/reflection/RPCCall.py +131 -0
  17. flatbuffers/reflection/Schema.py +206 -0
  18. flatbuffers/reflection/SchemaFile.py +77 -0
  19. flatbuffers/reflection/Service.py +145 -0
  20. flatbuffers/reflection/Type.py +98 -0
  21. flatbuffers/reflection/__init__.py +0 -0
  22. flatbuffers/table.py +129 -0
  23. flatbuffers/util.py +43 -0
  24. zlmdb/__init__.py +312 -0
  25. zlmdb/_database.py +990 -0
  26. zlmdb/_errors.py +31 -0
  27. zlmdb/_meta.py +27 -0
  28. zlmdb/_pmap.py +1667 -0
  29. zlmdb/_schema.py +137 -0
  30. zlmdb/_transaction.py +181 -0
  31. zlmdb/_types.py +1596 -0
  32. zlmdb/_version.py +27 -0
  33. zlmdb/cli.py +41 -0
  34. zlmdb/flatbuffers/__init__.py +5 -0
  35. zlmdb/flatbuffers/reflection/AdvancedFeatures.py +10 -0
  36. zlmdb/flatbuffers/reflection/BaseType.py +25 -0
  37. zlmdb/flatbuffers/reflection/Enum.py +252 -0
  38. zlmdb/flatbuffers/reflection/EnumVal.py +144 -0
  39. zlmdb/flatbuffers/reflection/Field.py +325 -0
  40. zlmdb/flatbuffers/reflection/KeyValue.py +84 -0
  41. zlmdb/flatbuffers/reflection/Object.py +260 -0
  42. zlmdb/flatbuffers/reflection/RPCCall.py +195 -0
  43. zlmdb/flatbuffers/reflection/Schema.py +301 -0
  44. zlmdb/flatbuffers/reflection/SchemaFile.py +112 -0
  45. zlmdb/flatbuffers/reflection/Service.py +213 -0
  46. zlmdb/flatbuffers/reflection/Type.py +148 -0
  47. zlmdb/flatbuffers/reflection/__init__.py +0 -0
  48. zlmdb/flatbuffers/reflection.fbs +152 -0
  49. zlmdb/lmdb/__init__.py +37 -0
  50. zlmdb/lmdb/__main__.py +25 -0
  51. zlmdb/lmdb/_config.py +10 -0
  52. zlmdb/lmdb/cffi.py +2606 -0
  53. zlmdb/lmdb/tool.py +670 -0
  54. zlmdb/tests/lmdb/__init__.py +0 -0
  55. zlmdb/tests/lmdb/address_book.py +287 -0
  56. zlmdb/tests/lmdb/crash_test.py +339 -0
  57. zlmdb/tests/lmdb/cursor_test.py +333 -0
  58. zlmdb/tests/lmdb/env_test.py +919 -0
  59. zlmdb/tests/lmdb/getmulti_test.py +92 -0
  60. zlmdb/tests/lmdb/iteration_test.py +258 -0
  61. zlmdb/tests/lmdb/package_test.py +70 -0
  62. zlmdb/tests/lmdb/test_lmdb.py +188 -0
  63. zlmdb/tests/lmdb/testlib.py +185 -0
  64. zlmdb/tests/lmdb/tool_test.py +60 -0
  65. zlmdb/tests/lmdb/txn_test.py +575 -0
  66. zlmdb/tests/orm/MNodeLog.py +853 -0
  67. zlmdb/tests/orm/__init__.py +0 -0
  68. zlmdb/tests/orm/_schema_fbs.py +215 -0
  69. zlmdb/tests/orm/_schema_mnode_log.py +1201 -0
  70. zlmdb/tests/orm/_schema_py2.py +250 -0
  71. zlmdb/tests/orm/_schema_py3.py +307 -0
  72. zlmdb/tests/orm/_test_flatbuffers.py +144 -0
  73. zlmdb/tests/orm/_test_serialization.py +144 -0
  74. zlmdb/tests/orm/test_basic.py +217 -0
  75. zlmdb/tests/orm/test_etcd.py +275 -0
  76. zlmdb/tests/orm/test_pmap_indexes.py +466 -0
  77. zlmdb/tests/orm/test_pmap_types.py +90 -0
  78. zlmdb/tests/orm/test_pmaps.py +295 -0
  79. zlmdb/tests/orm/test_select.py +619 -0
  80. zlmdb-25.10.1.dist-info/METADATA +264 -0
  81. zlmdb-25.10.1.dist-info/RECORD +86 -0
  82. zlmdb-25.10.1.dist-info/WHEEL +5 -0
  83. zlmdb-25.10.1.dist-info/entry_points.txt +2 -0
  84. zlmdb-25.10.1.dist-info/licenses/LICENSE +137 -0
  85. zlmdb-25.10.1.dist-info/licenses/NOTICE +41 -0
  86. zlmdb-25.10.1.dist-info/top_level.txt +2 -0
zlmdb/_pmap.py ADDED
@@ -0,0 +1,1667 @@
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
+ """Persistent mappings."""
27
+
28
+ import struct
29
+ import sys
30
+ import uuid
31
+ import zlib
32
+ from typing import Optional, List, Callable, Any, Tuple, Dict
33
+
34
+ from zlmdb import _types, _errors
35
+ from zlmdb._transaction import Transaction
36
+
37
+ try:
38
+ import snappy
39
+ except ImportError:
40
+ HAS_SNAPPY = False
41
+ else:
42
+ HAS_SNAPPY = True
43
+
44
+ if sys.version_info < (3,):
45
+ from UserDict import DictMixin as MutableMapping
46
+
47
+ _NATIVE_PICKLE_PROTOCOL = 2
48
+ else:
49
+ from collections.abc import MutableMapping
50
+
51
+ _NATIVE_PICKLE_PROTOCOL = 4
52
+
53
+
54
+ class Index(object):
55
+ """
56
+ Holds book-keeping metadata for indexes on tables (pmaps).
57
+ """
58
+
59
+ def __init__(self, name, fkey, pmap, nullable=False, unique=True):
60
+ """
61
+
62
+ :param name: Index name.
63
+ :type name: str
64
+
65
+ :param fkey: Function that extracts the indexed value from the indexed table.
66
+ :type fkey: callable
67
+
68
+ :param pmap: Persistent map for index storage.
69
+ :type pmap: :class:`zlmdb._pmap.PersistentMap`
70
+
71
+ :param nullable: Whether the indexed table column is allowed to
72
+ take ``None`` values.
73
+ :type nullable: bool
74
+
75
+ :param unique: Whether the indexed table column must take unique values.
76
+ :type unique: bool
77
+ """
78
+ self._name = name
79
+ self._fkey = fkey
80
+ self._pmap = pmap
81
+ self._nullable = nullable
82
+ self._unique = unique
83
+
84
+ @property
85
+ def name(self):
86
+ """
87
+ Index name property.
88
+
89
+ :return: Name of the index (on the indexed table).
90
+ :rtype: str
91
+ """
92
+ return self._name
93
+
94
+ @property
95
+ def fkey(self):
96
+ """
97
+ Indexed value extractor property.
98
+
99
+ :return: Function to extract indexed value from the indexed table.
100
+ :rtype: callable
101
+ """
102
+ return self._fkey
103
+
104
+ @property
105
+ def pmap(self):
106
+ """
107
+ Index table (pmap) property.
108
+
109
+ :return: Persistent map for index storage.
110
+ :rtype: :class:`zlmdb._pmap.PersistentMap`
111
+ """
112
+ return self._pmap
113
+
114
+ @property
115
+ def nullable(self):
116
+ """
117
+ Index nullable property.
118
+
119
+ :return: Whether the indexed table column is allowed to
120
+ take ``None`` values.
121
+ :rtype: bool
122
+ """
123
+ return self._nullable
124
+
125
+ @property
126
+ def unique(self):
127
+ """
128
+ Index uniqueness property-
129
+
130
+ :return: Whether the indexed table column must take unique values.
131
+ :rtype: bool
132
+ """
133
+ return self._unique
134
+
135
+
136
+ def is_null(value):
137
+ """
138
+ Check if the scalar value or tuple/list value is NULL.
139
+
140
+ :param value: Value to check.
141
+ :type value: a scalar or tuple or list
142
+
143
+ :return: Returns ``True`` if and only if the value is NULL (scalar value is None
144
+ or _any_ tuple/list elements are None).
145
+ :rtype: bool
146
+ """
147
+ if type(value) in (tuple, list):
148
+ for v in value:
149
+ if v is None:
150
+ return True
151
+ return False
152
+ else:
153
+ return value is None
154
+
155
+
156
+ def qual(obj):
157
+ """
158
+ Return fully qualified name of a class.
159
+ """
160
+ return "{}.{}".format(obj.__class__.__module__, obj.__class__.__name__)
161
+
162
+
163
+ class PersistentMap(MutableMapping):
164
+ """
165
+ Abstract base class for persistent maps stored in LMDB.
166
+ """
167
+
168
+ COMPRESS_ZLIB = 1
169
+ COMPRESS_SNAPPY = 2
170
+
171
+ # these are filled by table decorate @zlmdb.table
172
+ _zlmdb_oid: Optional[uuid.UUID] = None
173
+ _zlmdb_marshal: Optional[Callable] = None
174
+ _zlmdb_parse: Optional[Callable] = None
175
+ _zlmdb_build: Optional[Callable] = None
176
+ _zlmdb_cast: Optional[Callable] = None
177
+ _zlmdb_compress: Optional[int] = None
178
+
179
+ def __init__(self, slot: Optional[int], compress: Optional[int] = None):
180
+ """
181
+
182
+ :param slot:
183
+ :param compress:
184
+ """
185
+ assert slot is None or type(slot) == int
186
+ assert compress is None or compress in [
187
+ PersistentMap.COMPRESS_ZLIB,
188
+ PersistentMap.COMPRESS_SNAPPY,
189
+ ]
190
+
191
+ self._slot = slot
192
+
193
+ if compress:
194
+ if compress not in [
195
+ PersistentMap.COMPRESS_ZLIB,
196
+ PersistentMap.COMPRESS_SNAPPY,
197
+ ]:
198
+ raise Exception("invalid compression mode")
199
+ if compress == PersistentMap.COMPRESS_SNAPPY and not HAS_SNAPPY:
200
+ raise Exception(
201
+ "snappy compression requested, but snappy is not installed"
202
+ )
203
+ if compress == PersistentMap.COMPRESS_ZLIB:
204
+ self._compress = zlib.compress
205
+ self._decompress = zlib.decompress
206
+ elif compress == PersistentMap.COMPRESS_SNAPPY:
207
+ self._compress = snappy.compress
208
+ self._decompress = snappy.uncompress
209
+ else:
210
+ raise Exception("logic error")
211
+ else:
212
+ self._compress = lambda data: data # type: ignore
213
+ self._decompress = lambda data: data # type: ignore
214
+
215
+ # if this pmap is an index, the table-pmap the index-pmap is attached to
216
+ self._index_attached_to = None
217
+
218
+ # if this pmap is NOT an index, any indexes attached to this (table-)pmap
219
+ self._indexes: Dict[str, Index] = {}
220
+
221
+ def indexes(self) -> List[str]:
222
+ """
223
+
224
+ :return:
225
+ """
226
+ return sorted(self._indexes.keys())
227
+
228
+ def is_index(self) -> bool:
229
+ """
230
+ Flag indicating whether this pmap is used as an index.
231
+
232
+ :return:
233
+ """
234
+ return self._index_attached_to is not None
235
+
236
+ def attach_index(
237
+ self,
238
+ name: str,
239
+ pmap: "PersistentMap",
240
+ fkey: Callable,
241
+ nullable: bool = False,
242
+ unique: bool = True,
243
+ ):
244
+ """
245
+
246
+ :param name:
247
+ :param pmap:
248
+ :param fkey:
249
+ :param nullable:
250
+ :param unique:
251
+ """
252
+ if self._index_attached_to:
253
+ raise Exception(
254
+ "cannot attach an index to an index (this pmap is already an index attached to {})".format(
255
+ self._index_attached_to
256
+ )
257
+ )
258
+ if pmap._index_attached_to:
259
+ raise Exception(
260
+ "index already attached (to {})".format(pmap._index_attached_to)
261
+ )
262
+ if name in self._indexes:
263
+ raise Exception('index with name "{}" already exists'.format(name))
264
+
265
+ self._indexes[name] = Index(name, fkey, pmap, nullable, unique)
266
+ pmap._index_attached_to = self # type: ignore
267
+
268
+ def detach_index(self, name: str):
269
+ """
270
+
271
+ :param name:
272
+ """
273
+ if name in self._indexes:
274
+ del self._indexes[name]
275
+
276
+ def _serialize_key(self, key):
277
+ raise Exception("must be implemented in derived class")
278
+
279
+ def _deserialize_key(self, data):
280
+ raise Exception("must be implemented in derived class")
281
+
282
+ def _serialize_value(self, value):
283
+ raise Exception("must be implemented in derived class")
284
+
285
+ def _deserialize_value(self, data):
286
+ raise Exception("must be implemented in derived class")
287
+
288
+ def __contains__(self, txn_key):
289
+ """
290
+
291
+ :param txn_key:
292
+ :return:
293
+ """
294
+ assert type(txn_key) == tuple and len(txn_key) == 2
295
+ txn, key = txn_key
296
+ assert isinstance(txn, Transaction)
297
+
298
+ _key = struct.pack(">H", self._slot) + self._serialize_key(key)
299
+ _data = txn.get(_key)
300
+
301
+ return _data is not None
302
+
303
+ def __getitem__(self, txn_key):
304
+ """
305
+
306
+ :param txn_key:
307
+ :return:
308
+ """
309
+ assert type(txn_key) == tuple and len(txn_key) == 2
310
+ txn, key = txn_key
311
+ assert isinstance(txn, Transaction)
312
+
313
+ _key = struct.pack(">H", self._slot) + self._serialize_key(key)
314
+ _data = txn.get(_key)
315
+
316
+ if _data:
317
+ if self._decompress:
318
+ _data = self._decompress(_data)
319
+ return self._deserialize_value(_data)
320
+ else:
321
+ return None
322
+
323
+ def __setitem__(self, txn_key, value):
324
+ """
325
+
326
+ :param txn_key:
327
+ :param value:
328
+ :return:
329
+ """
330
+ assert type(txn_key) == tuple and len(txn_key) == 2
331
+ txn, key = txn_key
332
+ assert isinstance(txn, Transaction)
333
+
334
+ _key = struct.pack(">H", self._slot) + self._serialize_key(key)
335
+ _data = self._serialize_value(value)
336
+
337
+ if self._compress:
338
+ _data = self._compress(_data)
339
+
340
+ # if there are indexes defined, get existing object (if any),
341
+ # so that we can properly maintain the indexes, should indexed
342
+ # columns be set to NULL, in which case we need to delete the
343
+ # respective index record
344
+ _old_value = None
345
+ if self._indexes:
346
+ _old_data = txn.get(_key)
347
+ if _old_data:
348
+ if self._decompress:
349
+ _old_data = self._decompress(_old_data)
350
+ _old_value = self._deserialize_value(_old_data)
351
+
352
+ # insert data record
353
+ txn.put(_key, _data)
354
+
355
+ # insert records into indexes
356
+ for index in self._indexes.values():
357
+ # extract indexed column value, which will become the index record key
358
+ _fkey = index.fkey(value)
359
+
360
+ if _old_value:
361
+ _fkey_old = index.fkey(_old_value)
362
+
363
+ if not is_null(_fkey_old) and _fkey_old != _fkey:
364
+ _idx_key = struct.pack(
365
+ ">H", index.pmap._slot
366
+ ) + index.pmap._serialize_key(_fkey_old)
367
+ txn.delete(_idx_key)
368
+
369
+ if is_null(_fkey):
370
+ if not index.nullable:
371
+ raise _errors.NullValueConstraint(
372
+ 'cannot insert NULL value into non-nullable index "{}::{}"'.format(
373
+ qual(self), index.name
374
+ )
375
+ )
376
+ else:
377
+ _key = struct.pack(">H", index.pmap._slot) + index.pmap._serialize_key(
378
+ _fkey
379
+ )
380
+ _data = index.pmap._serialize_value(key)
381
+ txn.put(_key, _data)
382
+
383
+ def __delitem__(self, txn_key):
384
+ """
385
+
386
+ :param txn_key:
387
+ :return:
388
+ """
389
+ assert type(txn_key) == tuple and len(txn_key) == 2
390
+ txn, key = txn_key
391
+ assert isinstance(txn, Transaction)
392
+
393
+ _key = struct.pack(">H", self._slot) + self._serialize_key(key)
394
+
395
+ # delete records from indexes
396
+ if self._indexes:
397
+ value = self.__getitem__(txn_key)
398
+ if value:
399
+ for index in self._indexes.values():
400
+ _idx_key = struct.pack(
401
+ ">H", index.pmap._slot
402
+ ) + index.pmap._serialize_key(index.fkey(value))
403
+ txn.delete(_idx_key)
404
+
405
+ # delete actual data record
406
+ txn.delete(_key)
407
+
408
+ def __len__(self):
409
+ raise NotImplementedError()
410
+
411
+ def __iter__(self):
412
+ raise NotImplementedError()
413
+
414
+ def select(
415
+ self,
416
+ txn: Transaction,
417
+ from_key: Any = None,
418
+ to_key: Any = None,
419
+ return_keys: bool = True,
420
+ return_values: bool = True,
421
+ reverse: bool = False,
422
+ limit: Optional[int] = None,
423
+ ) -> "PersistentMapIterator":
424
+ """
425
+ Select all records (key-value pairs) in table, optionally within a given key range.
426
+
427
+ :param txn: The transaction in which to run.
428
+
429
+ :param from_key: Return records starting from (and including) this key.
430
+
431
+ :param to_key: Return records up to (but not including) this key.
432
+
433
+ :param return_keys: If ``True`` (default), return keys of records.
434
+
435
+ :param return_values: If ``True`` (default), return values of records.
436
+
437
+ :param reverse: If ``True``, return records in reverse order.
438
+
439
+ :param limit: Limit number of records returned.
440
+
441
+ :return:
442
+ """
443
+ assert type(return_keys) == bool
444
+ assert type(return_values) == bool
445
+ assert type(reverse) == bool
446
+ assert limit is None or (type(limit) == int and limit > 0 and limit < 10000000)
447
+
448
+ return PersistentMapIterator(
449
+ txn,
450
+ self,
451
+ from_key=from_key,
452
+ to_key=to_key,
453
+ return_keys=return_keys,
454
+ return_values=return_values,
455
+ reverse=reverse,
456
+ limit=limit,
457
+ )
458
+
459
+ def count(self, txn: Transaction, prefix: Any = None) -> int:
460
+ """
461
+ Count number of records in the persistent map. When no prefix
462
+ is given, the total number of records is returned. When a prefix
463
+ is given, only the number of records with keys that have this
464
+ prefix are counted.
465
+
466
+ :param txn: The transaction in which to run.
467
+
468
+ :param prefix: The key prefix of records to count.
469
+
470
+ :returns: The number of records.
471
+ """
472
+ assert txn._txn
473
+
474
+ key_from = struct.pack(">H", self._slot)
475
+ if prefix:
476
+ key_from += self._serialize_key(prefix)
477
+ kfl = len(key_from)
478
+
479
+ cnt = 0
480
+ cursor = txn._txn.cursor()
481
+ has_more = cursor.set_range(key_from)
482
+ while has_more:
483
+ _key = cursor.key()
484
+ _prefix = _key[:kfl]
485
+ if _prefix != key_from:
486
+ break
487
+ cnt += 1
488
+ has_more = cursor.next()
489
+
490
+ return cnt
491
+
492
+ def count_range(self, txn: Transaction, from_key: Any, to_key: Any) -> int:
493
+ """
494
+ Counter number of records in the perstistent map with keys
495
+ within the given range.
496
+
497
+ :param txn: The transaction in which to run.
498
+
499
+ :param from_key: Count records starting and including from this key.
500
+
501
+ :param to_key: End counting records before this key.
502
+
503
+ :returns: The number of records.
504
+ """
505
+ assert txn._txn
506
+
507
+ key_from = struct.pack(">H", self._slot) + self._serialize_key(from_key)
508
+ to_key = struct.pack(">H", self._slot) + self._serialize_key(to_key)
509
+
510
+ cnt = 0
511
+ cursor = txn._txn.cursor()
512
+ has_more = cursor.set_range(key_from)
513
+ while has_more:
514
+ if cursor.key() >= to_key:
515
+ break
516
+ cnt += 1
517
+ has_more = cursor.next()
518
+
519
+ return cnt
520
+
521
+ def truncate(self, txn: Transaction, rebuild_indexes: bool = True) -> int:
522
+ """
523
+
524
+ :param txn:
525
+ :param rebuild_indexes:
526
+ :return:
527
+ """
528
+ assert txn._txn
529
+ assert self._slot
530
+
531
+ key_from = struct.pack(">H", self._slot)
532
+ key_to = struct.pack(">H", self._slot + 1)
533
+ cursor = txn._txn.cursor()
534
+ cnt = 0
535
+ if cursor.set_range(key_from):
536
+ key = cursor.key()
537
+ while key < key_to:
538
+ if not cursor.delete(dupdata=True):
539
+ break
540
+ cnt += 1
541
+ if txn._stats:
542
+ txn._stats.dels += 1
543
+ if rebuild_indexes:
544
+ deleted, _ = self.rebuild_indexes(txn)
545
+ cnt += deleted
546
+ return cnt
547
+
548
+ def rebuild_indexes(self, txn: Transaction) -> Tuple[int, int]:
549
+ """
550
+
551
+ :param txn:
552
+ :return:
553
+ """
554
+ assert txn._txn
555
+
556
+ total_deleted = 0
557
+ total_inserted = 0
558
+ for name in sorted(self._indexes.keys()):
559
+ deleted, inserted = self.rebuild_index(txn, name)
560
+ total_deleted += deleted
561
+ total_inserted += inserted
562
+ return total_deleted, total_inserted
563
+
564
+ def rebuild_index(self, txn: Transaction, name: str) -> Tuple[int, int]:
565
+ """
566
+
567
+ :param txn:
568
+ :param name:
569
+ :return:
570
+ """
571
+ assert txn._txn
572
+ assert self._slot
573
+
574
+ if name in self._indexes:
575
+ index = self._indexes[name]
576
+
577
+ deleted = index.pmap.truncate(txn)
578
+
579
+ key_from = struct.pack(">H", self._slot)
580
+ key_to = struct.pack(">H", self._slot + 1)
581
+ cursor = txn._txn.cursor()
582
+ inserted = 0
583
+ if cursor.set_range(key_from):
584
+ while cursor.key() < key_to:
585
+ data = cursor.value()
586
+ if data:
587
+ value = self._deserialize_value(data)
588
+
589
+ _key = struct.pack(
590
+ ">H", index.pmap._slot
591
+ ) + index.pmap._serialize_key(index.fkey(value))
592
+ _data = index.pmap._serialize_value(value.oid)
593
+
594
+ txn.put(_key, _data)
595
+ inserted += 1
596
+ if not cursor.next():
597
+ break
598
+ return deleted, inserted
599
+ else:
600
+ raise Exception('no index "{}" attached'.format(name))
601
+
602
+
603
+ class PersistentMapIterator(object):
604
+ """
605
+ Iterator that walks over zLMDB database records.
606
+ """
607
+
608
+ def __init__(
609
+ self,
610
+ txn: Transaction,
611
+ pmap: PersistentMap,
612
+ from_key: Any = None,
613
+ to_key: Any = None,
614
+ return_keys: bool = True,
615
+ return_values: bool = True,
616
+ reverse: bool = False,
617
+ limit: Optional[int] = None,
618
+ ):
619
+ """
620
+
621
+ :param txn:
622
+ :param pmap:
623
+ :param from_key:
624
+ :param to_key:
625
+ :param return_keys:
626
+ :param return_values:
627
+ :param reverse:
628
+ :param limit:
629
+ """
630
+ self._txn = txn
631
+ self._pmap = pmap
632
+ assert pmap._slot
633
+
634
+ if from_key:
635
+ self._from_key = struct.pack(">H", pmap._slot) + pmap._serialize_key(
636
+ from_key
637
+ )
638
+ else:
639
+ self._from_key = struct.pack(">H", pmap._slot)
640
+
641
+ if to_key:
642
+ self._to_key = struct.pack(">H", pmap._slot) + pmap._serialize_key(to_key)
643
+ else:
644
+ self._to_key = struct.pack(">H", pmap._slot + 1)
645
+
646
+ self._reverse = reverse
647
+
648
+ self._return_keys = return_keys
649
+ self._return_values = return_values
650
+
651
+ self._limit = limit
652
+ self._read = 0
653
+
654
+ self._cursor = None
655
+ self._found = None
656
+
657
+ def __iter__(self) -> "PersistentMapIterator":
658
+ assert self._txn._txn
659
+ self._cursor = self._txn._txn.cursor()
660
+ assert self._cursor
661
+
662
+ # https://lmdb.readthedocs.io/en/release/#lmdb.Cursor.set_range
663
+ if self._reverse:
664
+ # seek to the first record starting from to_key (and going reverse)
665
+ self._found = self._cursor.set_range(self._to_key)
666
+
667
+ if self._found:
668
+ # to_key is _not_ inclusive, so we move on one record
669
+ self._found = self._cursor.prev()
670
+ else:
671
+ self._found = self._cursor.last()
672
+ else:
673
+ # seek to the first record starting from from_key
674
+ self._found = self._cursor.set_range(self._from_key)
675
+
676
+ return self
677
+
678
+ def __next__(self):
679
+ """
680
+
681
+ :return: Return either ``(key, value)``, ``key`` or ``value``, depending on ``return_keys``
682
+ and ``return_values``.
683
+ """
684
+ # stop criteria: no more records or limit reached
685
+ if not self._found or (self._limit and self._read >= self._limit):
686
+ raise StopIteration
687
+ self._read += 1
688
+
689
+ # stop criteria: end of key-range reached
690
+ _key = self._cursor.key()
691
+ if self._reverse:
692
+ if _key < self._from_key:
693
+ raise StopIteration
694
+ else:
695
+ if _key >= self._to_key:
696
+ raise StopIteration
697
+
698
+ # read actual app key-value (before moving cursor)
699
+ _key = self._pmap._deserialize_key(_key[2:])
700
+
701
+ if self._return_values:
702
+ _data = self._cursor.value()
703
+ if _data:
704
+ if self._pmap._decompress:
705
+ _data = self._pmap._decompress(_data)
706
+ _data = self._pmap._deserialize_value(_data)
707
+ else:
708
+ _data = None
709
+
710
+ # move the cursor
711
+ if self._reverse:
712
+ self._found = self._cursor.prev()
713
+ else:
714
+ self._found = self._cursor.next()
715
+
716
+ # return app key-value
717
+ if self._return_keys and self._return_values:
718
+ return _key, _data
719
+ elif self._return_values:
720
+ return _data
721
+ elif self._return_keys:
722
+ return _key
723
+ else:
724
+ return None
725
+
726
+ next = __next__ # Python 2
727
+
728
+
729
+ #
730
+ # Key: UUID -> Value: String, OID, UUID, JSON, CBOR, Pickle, FlatBuffers
731
+ #
732
+
733
+
734
+ class MapSlotUuidUuid(
735
+ _types._SlotUuidKeysMixin, _types._UuidValuesMixin, PersistentMap
736
+ ):
737
+ """
738
+ Persistent map with (slot, UUID) and UUID values.
739
+ """
740
+
741
+ def __init__(self, slot=None, compress=None):
742
+ PersistentMap.__init__(self, slot=slot, compress=compress)
743
+
744
+
745
+ class MapUuidString(_types._UuidKeysMixin, _types._StringValuesMixin, PersistentMap):
746
+ """
747
+ Persistent map with UUID (16 bytes) keys and string (utf8) values.
748
+ """
749
+
750
+ def __init__(self, slot=None, compress=None):
751
+ PersistentMap.__init__(self, slot=slot, compress=compress)
752
+
753
+
754
+ class MapUuidOid(_types._UuidKeysMixin, _types._OidValuesMixin, PersistentMap):
755
+ """
756
+ Persistent map with UUID (16 bytes) keys and OID (uint64) values.
757
+ """
758
+
759
+ def __init__(self, slot=None, compress=None):
760
+ PersistentMap.__init__(self, slot=slot, compress=compress)
761
+
762
+
763
+ class MapUuidUuid(_types._UuidKeysMixin, _types._UuidValuesMixin, PersistentMap):
764
+ """
765
+ Persistent map with UUID (16 bytes) keys and UUID (16 bytes) values.
766
+ """
767
+
768
+ def __init__(self, slot=None, compress=None):
769
+ PersistentMap.__init__(self, slot=slot, compress=compress)
770
+
771
+
772
+ class MapUuidUuidCbor(
773
+ _types._UuidUuidKeysMixin, _types._CborValuesMixin, PersistentMap
774
+ ):
775
+ """
776
+ Persistent map with (UUID, UUID) keys and CBOR values.
777
+ """
778
+
779
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
780
+ PersistentMap.__init__(self, slot=slot, compress=compress)
781
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
782
+
783
+
784
+ class MapUuidTimestampBytes32(
785
+ _types._UuidTimestampKeysMixin, _types._Bytes32ValuesMixin, PersistentMap
786
+ ):
787
+ """
788
+ Persistent map with (UUID, Timestamp) keys and Bytes32 values.
789
+ """
790
+
791
+ def __init__(self, slot=None, compress=None):
792
+ PersistentMap.__init__(self, slot=slot, compress=compress)
793
+
794
+
795
+ class MapUint64TimestampUuid(
796
+ _types._Uint64TimestampKeysMixin, _types._UuidValuesMixin, PersistentMap
797
+ ):
798
+ """
799
+ Persistent map with (Uint64, Timestamp) keys and UUID values.
800
+ """
801
+
802
+ def __init__(self, slot=None, compress=None):
803
+ PersistentMap.__init__(self, slot=slot, compress=compress)
804
+
805
+
806
+ class MapUuidUuidUuid(
807
+ _types._UuidUuidKeysMixin, _types._UuidValuesMixin, PersistentMap
808
+ ):
809
+ """
810
+ Persistent map with (UUID, UUID) keys and UUID values.
811
+ """
812
+
813
+ def __init__(self, slot=None, compress=None):
814
+ PersistentMap.__init__(self, slot=slot, compress=compress)
815
+
816
+
817
+ class MapUuidTimestampUuid(
818
+ _types._UuidTimestampKeysMixin, _types._UuidValuesMixin, PersistentMap
819
+ ):
820
+ """
821
+ Persistent map with (UUID, timestamp) keys and UUID values.
822
+ """
823
+
824
+ def __init__(self, slot=None, compress=None):
825
+ PersistentMap.__init__(self, slot=slot, compress=compress)
826
+
827
+
828
+ class MapUuidStringUuid(
829
+ _types._UuidStringKeysMixin, _types._UuidValuesMixin, PersistentMap
830
+ ):
831
+ """
832
+ Persistent map with (UUID, string) keys and UUID values.
833
+ """
834
+
835
+ def __init__(self, slot=None, compress=None):
836
+ PersistentMap.__init__(self, slot=slot, compress=compress)
837
+
838
+
839
+ class MapUuidUuidStringUuid(
840
+ _types._UuidUuidStringKeysMixin, _types._UuidValuesMixin, PersistentMap
841
+ ):
842
+ """
843
+ Persistent map with (UUID, UUID, string) keys and UUID values.
844
+ """
845
+
846
+ def __init__(self, slot=None, compress=None):
847
+ PersistentMap.__init__(self, slot=slot, compress=compress)
848
+
849
+
850
+ class MapUuidUuidUuidStringUuid(
851
+ _types._UuidUuidUuidStringKeysMixin, _types._UuidValuesMixin, PersistentMap
852
+ ):
853
+ """
854
+ Persistent map with (UUID, UUID, UUID, string) keys and UUID values.
855
+ """
856
+
857
+ def __init__(self, slot=None, compress=None):
858
+ PersistentMap.__init__(self, slot=slot, compress=compress)
859
+
860
+
861
+ class MapUuidUuidUuidUuid(
862
+ _types._UuidUuidUuidKeysMixin, _types._UuidValuesMixin, PersistentMap
863
+ ):
864
+ """
865
+ Persistent map with (UUID, UUID, UUID) keys and UUID values.
866
+ """
867
+
868
+ def __init__(self, slot=None, compress=None):
869
+ PersistentMap.__init__(self, slot=slot, compress=compress)
870
+
871
+
872
+ class MapUuidUuidUuidUuidUuid(
873
+ _types._UuidUuidUuidUuidKeysMixin, _types._UuidValuesMixin, PersistentMap
874
+ ):
875
+ """
876
+ Persistent map with (UUID, UUID, UUID, UUID) keys and UUID values.
877
+ """
878
+
879
+ def __init__(self, slot=None, compress=None):
880
+ PersistentMap.__init__(self, slot=slot, compress=compress)
881
+
882
+
883
+ class MapUuidStringOid(
884
+ _types._UuidStringKeysMixin, _types._OidValuesMixin, PersistentMap
885
+ ):
886
+ """
887
+ Persistent map with (UUID, string) keys and Oid values.
888
+ """
889
+
890
+ def __init__(self, slot=None, compress=None):
891
+ PersistentMap.__init__(self, slot=slot, compress=compress)
892
+
893
+
894
+ class MapUuidUuidSet(_types._UuidKeysMixin, _types._UuidSetValuesMixin, PersistentMap):
895
+ """
896
+ Persistent map with (UUID, string) keys and UUID values.
897
+ """
898
+
899
+ def __init__(self, slot=None, compress=None):
900
+ PersistentMap.__init__(self, slot=slot, compress=compress)
901
+
902
+
903
+ class MapUuidJson(_types._UuidKeysMixin, _types._JsonValuesMixin, PersistentMap):
904
+ """
905
+ Persistent map with UUID (16 bytes) keys and JSON values.
906
+ """
907
+
908
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
909
+ PersistentMap.__init__(self, slot=slot, compress=compress)
910
+ _types._JsonValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
911
+
912
+
913
+ class MapUuidCbor(_types._UuidKeysMixin, _types._CborValuesMixin, PersistentMap):
914
+ """
915
+ Persistent map with UUID (16 bytes) keys and CBOR values.
916
+ """
917
+
918
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
919
+ PersistentMap.__init__(self, slot=slot, compress=compress)
920
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
921
+
922
+
923
+ class MapUuidPickle(_types._UuidKeysMixin, _types._PickleValuesMixin, PersistentMap):
924
+ """
925
+ Persistent map with UUID (16 bytes) keys and Python Pickle values.
926
+ """
927
+
928
+ def __init__(self, slot=None, compress=None):
929
+ PersistentMap.__init__(self, slot=slot, compress=compress)
930
+
931
+
932
+ class MapUuidFlatBuffers(
933
+ _types._UuidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
934
+ ):
935
+ """
936
+ Persistent map with UUID (16 bytes) keys and FlatBuffers values.
937
+ """
938
+
939
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
940
+ PersistentMap.__init__(self, slot=slot, compress=compress)
941
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
942
+
943
+
944
+ class MapUuidTimestampFlatBuffers(
945
+ _types._UuidTimestampKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
946
+ ):
947
+ """
948
+ Persistent map with (UUID, Timestamp) keys and FlatBuffers values.
949
+ """
950
+
951
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
952
+ PersistentMap.__init__(self, slot=slot, compress=compress)
953
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
954
+
955
+
956
+ class MapTimestampFlatBuffers(
957
+ _types._TimestampKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
958
+ ):
959
+ """
960
+ Persistent map with Timestamp keys and FlatBuffers values.
961
+ """
962
+
963
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
964
+ PersistentMap.__init__(self, slot=slot, compress=compress)
965
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
966
+
967
+
968
+ class MapTimestampUuidFlatBuffers(
969
+ _types._TimestampUuidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
970
+ ):
971
+ """
972
+ Persistent map with (Timestamp, UUID) keys and FlatBuffers values.
973
+ """
974
+
975
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
976
+ PersistentMap.__init__(self, slot=slot, compress=compress)
977
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
978
+
979
+
980
+ class MapUuidTimestampUuidFlatBuffers(
981
+ _types._UuidTimestampUuidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
982
+ ):
983
+ """
984
+ Persistent map with (UUID, Timestamp, UUID) keys and FlatBuffers values.
985
+ """
986
+
987
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
988
+ PersistentMap.__init__(self, slot=slot, compress=compress)
989
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
990
+
991
+
992
+ class MapUint16UuidTimestampFlatBuffers(
993
+ _types._Uint16UuidTimestampKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
994
+ ):
995
+ """
996
+ Persistent map with (uint16, UUID, Timestamp) keys and FlatBuffers values.
997
+ """
998
+
999
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1000
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1001
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1002
+
1003
+
1004
+ class MapUuidBytes20Uint8FlatBuffers(
1005
+ _types._UuidBytes20Uint8KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1006
+ ):
1007
+ """
1008
+ Persistent map with (UUID, bytes[20], uint8) keys and FlatBuffers values.
1009
+ """
1010
+
1011
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1012
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1013
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1014
+
1015
+
1016
+ class MapUuidBytes20Uint8UuidFlatBuffers(
1017
+ _types._UuidBytes20Uint8UuidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1018
+ ):
1019
+ """
1020
+ Persistent map with (UUID, bytes[20], uint8, UUID) keys and FlatBuffers values.
1021
+ """
1022
+
1023
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1024
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1025
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1026
+
1027
+
1028
+ class MapUuidBytes20Bytes20Uint8UuidFlatBuffers(
1029
+ _types._UuidBytes20Bytes20Uint8UuidKeysMixin,
1030
+ _types._FlatBuffersValuesMixin,
1031
+ PersistentMap,
1032
+ ):
1033
+ """
1034
+ Persistent map with (UUID, bytes[20], bytes[20], uint8, UUID) keys and FlatBuffers values.
1035
+ """
1036
+
1037
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1038
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1039
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1040
+
1041
+
1042
+ class MapTimestampUuidStringFlatBuffers(
1043
+ _types._TimestampUuidStringKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1044
+ ):
1045
+ """
1046
+ Persistent map with (Timestamp, UUID, String) keys and FlatBuffers values.
1047
+ """
1048
+
1049
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1050
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1051
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1052
+
1053
+
1054
+ class MapTimestampBytes32FlatBuffers(
1055
+ _types._TimestampBytes32KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1056
+ ):
1057
+ """
1058
+ Persistent map with (Timestamp, Bytes32) keys and FlatBuffers values.
1059
+ """
1060
+
1061
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1062
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1063
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1064
+
1065
+
1066
+ class MapTimestampStringFlatBuffers(
1067
+ _types._TimestampStringKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1068
+ ):
1069
+ """
1070
+ Persistent map with (Timestamp, String) keys and FlatBuffers values.
1071
+ """
1072
+
1073
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1074
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1075
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1076
+
1077
+
1078
+ class MapUuidTimestampCbor(
1079
+ _types._UuidTimestampKeysMixin, _types._CborValuesMixin, PersistentMap
1080
+ ):
1081
+ """
1082
+ Persistent map with (UUID, Timestamp) keys and CBOR values.
1083
+ """
1084
+
1085
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1086
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1087
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1088
+
1089
+
1090
+ class MapTimestampUuidCbor(
1091
+ _types._TimestampUuidKeysMixin, _types._CborValuesMixin, PersistentMap
1092
+ ):
1093
+ """
1094
+ Persistent map with (Timestamp, UUID) keys and CBOR values.
1095
+ """
1096
+
1097
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1098
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1099
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1100
+
1101
+
1102
+ class MapStringTimestampCbor(
1103
+ _types._StringTimestampKeysMixin, _types._CborValuesMixin, PersistentMap
1104
+ ):
1105
+ """
1106
+ Persistent map with (String, Timestamp) keys and CBOR values.
1107
+ """
1108
+
1109
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1110
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1111
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1112
+
1113
+
1114
+ class MapTimestampStringCbor(
1115
+ _types._TimestampStringKeysMixin, _types._CborValuesMixin, PersistentMap
1116
+ ):
1117
+ """
1118
+ Persistent map with (Timestamp, String) keys and CBOR values.
1119
+ """
1120
+
1121
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1122
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1123
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1124
+
1125
+
1126
+ #
1127
+ # Key: String -> Value: String, OID, UUID, JSON, CBOR, Pickle, FlatBuffers
1128
+ #
1129
+
1130
+
1131
+ class MapStringString(
1132
+ _types._StringKeysMixin, _types._StringValuesMixin, PersistentMap
1133
+ ):
1134
+ """
1135
+ Persistent map with string (utf8) keys and string (utf8) values.
1136
+ """
1137
+
1138
+ def __init__(self, slot=None, compress=None):
1139
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1140
+
1141
+
1142
+ class MapStringOid(_types._StringKeysMixin, _types._OidValuesMixin, PersistentMap):
1143
+ """
1144
+ Persistent map with string (utf8) keys and OID (uint64) values.
1145
+ """
1146
+
1147
+ def __init__(self, slot=None, compress=None):
1148
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1149
+
1150
+
1151
+ class MapStringOidOid(
1152
+ _types._StringOidKeysMixin, _types._OidValuesMixin, PersistentMap
1153
+ ):
1154
+ """
1155
+ Persistent map with (string:utf8, OID:uint64) keys and OID:uint64 values.
1156
+ """
1157
+
1158
+ def __init__(self, slot=None, compress=None):
1159
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1160
+
1161
+
1162
+ class MapStringUuid(_types._StringKeysMixin, _types._UuidValuesMixin, PersistentMap):
1163
+ """
1164
+ Persistent map with string (utf8) keys and UUID (16 bytes) values.
1165
+ """
1166
+
1167
+ def __init__(self, slot=None, compress=None):
1168
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1169
+
1170
+
1171
+ class MapStringStringUuid(
1172
+ _types._StringStringKeysMixin, _types._UuidValuesMixin, PersistentMap
1173
+ ):
1174
+ """
1175
+ Persistent map with (string, string) keys and UUID (16 bytes) values.
1176
+ """
1177
+
1178
+ def __init__(self, slot=None, compress=None):
1179
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1180
+
1181
+
1182
+ class MapStringStringStringUuid(
1183
+ _types._StringStringStringKeysMixin, _types._UuidValuesMixin, PersistentMap
1184
+ ):
1185
+ """
1186
+ Persistent map with (string, string, string) keys and UUID (16 bytes) values.
1187
+ """
1188
+
1189
+ def __init__(self, slot=None, compress=None):
1190
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1191
+
1192
+
1193
+ class MapStringJson(_types._StringKeysMixin, _types._JsonValuesMixin, PersistentMap):
1194
+ """
1195
+ Persistent map with string (utf8) keys and JSON values.
1196
+ """
1197
+
1198
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1199
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1200
+ _types._JsonValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1201
+
1202
+
1203
+ class MapStringCbor(_types._StringKeysMixin, _types._CborValuesMixin, PersistentMap):
1204
+ """
1205
+ Persistent map with string (utf8) keys and CBOR values.
1206
+ """
1207
+
1208
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1209
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1210
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1211
+
1212
+
1213
+ class MapStringPickle(
1214
+ _types._StringKeysMixin, _types._PickleValuesMixin, PersistentMap
1215
+ ):
1216
+ """
1217
+ Persistent map with string (utf8) keys and Python pickle values.
1218
+ """
1219
+
1220
+ def __init__(self, slot=None, compress=None):
1221
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1222
+
1223
+
1224
+ class MapStringFlatBuffers(
1225
+ _types._StringKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1226
+ ):
1227
+ """
1228
+ Persistent map with string (utf8) keys and FlatBuffers values.
1229
+ """
1230
+
1231
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1232
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1233
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1234
+
1235
+
1236
+ #
1237
+ # Key: OID -> Value: String, OID, UUID, JSON, CBOR, Pickle, FlatBuffers
1238
+ #
1239
+
1240
+
1241
+ class MapOidString(_types._OidKeysMixin, _types._StringValuesMixin, PersistentMap):
1242
+ """
1243
+ Persistent map with OID (uint64) keys and string (utf8) values.
1244
+ """
1245
+
1246
+ def __init__(self, slot=None, compress=None):
1247
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1248
+
1249
+
1250
+ class MapOidOid(_types._OidKeysMixin, _types._OidValuesMixin, PersistentMap):
1251
+ """
1252
+ Persistent map with OID (uint64) keys and OID (uint64) values.
1253
+ """
1254
+
1255
+ def __init__(self, slot=None, compress=None):
1256
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1257
+
1258
+
1259
+ class MapOidUuid(_types._OidKeysMixin, _types._UuidValuesMixin, PersistentMap):
1260
+ """
1261
+ Persistent map with OID (uint64) keys and UUID (16 bytes) values.
1262
+ """
1263
+
1264
+ def __init__(self, slot=None, compress=None):
1265
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1266
+
1267
+
1268
+ class MapOidJson(_types._OidKeysMixin, _types._JsonValuesMixin, PersistentMap):
1269
+ """
1270
+ Persistent map with OID (uint64) keys and JSON values.
1271
+ """
1272
+
1273
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1274
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1275
+ _types._JsonValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1276
+
1277
+
1278
+ class MapOidCbor(_types._OidKeysMixin, _types._CborValuesMixin, PersistentMap):
1279
+ """
1280
+ Persistent map with OID (uint64) keys and CBOR values.
1281
+ """
1282
+
1283
+ def __init__(self, slot=None, compress=None, marshal=None, unmarshal=None):
1284
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1285
+ _types._CborValuesMixin.__init__(self, marshal=marshal, unmarshal=unmarshal)
1286
+
1287
+
1288
+ class MapOidPickle(_types._OidKeysMixin, _types._PickleValuesMixin, PersistentMap):
1289
+ """
1290
+ Persistent map with OID (uint64) keys and Python pickle values.
1291
+ """
1292
+
1293
+ def __init__(self, slot=None, compress=None):
1294
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1295
+
1296
+
1297
+ class MapOidFlatBuffers(
1298
+ _types._OidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1299
+ ):
1300
+ """
1301
+ Persistent map with OID (uint64) keys and FlatBuffers values.
1302
+ """
1303
+
1304
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1305
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1306
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1307
+
1308
+
1309
+ class MapOidOidFlatBuffers(
1310
+ _types._OidOidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1311
+ ):
1312
+ """
1313
+ Persistent map with (OID, OID) / (uint64, uint64) keys and FlatBuffers values.
1314
+ """
1315
+
1316
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1317
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1318
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1319
+
1320
+
1321
+ class MapOid3FlatBuffers(
1322
+ _types._Oid3KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1323
+ ):
1324
+ """
1325
+ Persistent map with (OID, OID, OID) / (uint64, uint64, uint64) keys and FlatBuffers values.
1326
+ """
1327
+
1328
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1329
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1330
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1331
+
1332
+
1333
+ class MapOidOidSet(_types._OidKeysMixin, _types._OidSetValuesMixin, PersistentMap):
1334
+ """
1335
+ Persistent map with OID (uint64) keys and OID-set (set of unique uint64) values.
1336
+ """
1337
+
1338
+ def __init__(self, slot=None, compress=None):
1339
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1340
+
1341
+
1342
+ class MapOidStringOid(
1343
+ _types._OidStringKeysMixin, _types._OidValuesMixin, PersistentMap
1344
+ ):
1345
+ """
1346
+ Persistent map with (OID, string) keys and OID values.
1347
+ """
1348
+
1349
+ def __init__(self, slot=None, compress=None):
1350
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1351
+
1352
+
1353
+ class MapOidOidOid(_types._OidOidKeysMixin, _types._OidValuesMixin, PersistentMap):
1354
+ """
1355
+ Persistent map with (OID, OID) keys and OID values.
1356
+ """
1357
+
1358
+ def __init__(self, slot=None, compress=None):
1359
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1360
+
1361
+
1362
+ class MapOidTimestampOid(
1363
+ _types._OidTimestampKeysMixin, _types._OidValuesMixin, PersistentMap
1364
+ ):
1365
+ """
1366
+ Persistent map with (OID, Timestamp) keys and OID values, where Timestamp is a np.datetime64[ns].
1367
+ """
1368
+
1369
+ def __init__(self, slot=None, compress=None):
1370
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1371
+
1372
+
1373
+ class MapOidTimestampFlatBuffers(
1374
+ _types._OidTimestampKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1375
+ ):
1376
+ """
1377
+ Persistent map with (OID, Timestamp) keys and Flatbuffers values, where Timestamp is a np.datetime64[ns].
1378
+ """
1379
+
1380
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1381
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1382
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1383
+
1384
+
1385
+ class MapOidTimestampStringOid(
1386
+ _types._OidTimestampStringKeysMixin, _types._OidValuesMixin, PersistentMap
1387
+ ):
1388
+ """
1389
+ Persistent map with (OID, Timestamp, String) keys and OID values, where Timestamp is a np.datetime64[ns].
1390
+ """
1391
+
1392
+ def __init__(self, slot=None, compress=None):
1393
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1394
+
1395
+
1396
+ #
1397
+ # Key types: Bytes32, (Bytes32, Bytes32), (Bytes32, String), ...
1398
+ # Value type: FlatBuffers
1399
+ #
1400
+
1401
+
1402
+ class MapBytes32Uuid(_types._Bytes32KeysMixin, _types._UuidValuesMixin, PersistentMap):
1403
+ """
1404
+ Persistent map with Bytes32 keys and UUID values.
1405
+ """
1406
+
1407
+ def __init__(self, slot=None, compress=None):
1408
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1409
+
1410
+
1411
+ class MapBytes32Timestamp(
1412
+ _types._Bytes32KeysMixin, _types._TimestampValuesMixin, PersistentMap
1413
+ ):
1414
+ """
1415
+ Persistent map with Bytes32 keys and Timestamp values.
1416
+ """
1417
+
1418
+ def __init__(self, slot=None, compress=None):
1419
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1420
+
1421
+
1422
+ class MapBytes32Bytes32(
1423
+ _types._Bytes32KeysMixin, _types._Bytes32ValuesMixin, PersistentMap
1424
+ ):
1425
+ """
1426
+ Persistent map with Bytes32 keys and Bytes32 values.
1427
+ """
1428
+
1429
+ def __init__(self, slot=None, compress=None):
1430
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1431
+
1432
+
1433
+ class MapBytes32FlatBuffers(
1434
+ _types._Bytes32KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1435
+ ):
1436
+ """
1437
+ Persistent map with Bytes32 keys and Flatbuffers values.
1438
+ """
1439
+
1440
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1441
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1442
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1443
+
1444
+
1445
+ class MapBytes32UuidFlatBuffers(
1446
+ _types._Bytes32UuidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1447
+ ):
1448
+ """
1449
+ Persistent map with (Bytes32, UUID) keys and Flatbuffers values.
1450
+ """
1451
+
1452
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1453
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1454
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1455
+
1456
+
1457
+ class MapUuidBytes32FlatBuffers(
1458
+ _types._UuidBytes32KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1459
+ ):
1460
+ """
1461
+ Persistent map with (UUID, Bytes32) keys and Flatbuffers values.
1462
+ """
1463
+
1464
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1465
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1466
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1467
+
1468
+
1469
+ class MapUuidUuidStringFlatBuffers(
1470
+ _types._UuidUuidStringKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1471
+ ):
1472
+ """
1473
+ Persistent map with (UUID, UUID, String) keys and Flatbuffers values.
1474
+ """
1475
+
1476
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1477
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1478
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1479
+
1480
+
1481
+ class MapUuidUuidFlatBuffers(
1482
+ _types._UuidUuidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1483
+ ):
1484
+ """
1485
+ Persistent map with (UUID, UUID) keys and Flatbuffers values.
1486
+ """
1487
+
1488
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1489
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1490
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1491
+
1492
+
1493
+ class MapUuidStringFlatBuffers(
1494
+ _types._UuidStringKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1495
+ ):
1496
+ """
1497
+ Persistent map with (UUID, String) keys and Flatbuffers values.
1498
+ """
1499
+
1500
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1501
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1502
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1503
+
1504
+
1505
+ class MapBytes32Bytes32FlatBuffers(
1506
+ _types._Bytes32Bytes32KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1507
+ ):
1508
+ """
1509
+ Persistent map with (Bytes32, Bytes32) keys and Flatbuffers values.
1510
+ """
1511
+
1512
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1513
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1514
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1515
+
1516
+
1517
+ class MapBytes32StringFlatBuffers(
1518
+ _types._Bytes32StringKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1519
+ ):
1520
+ """
1521
+ Persistent map with (Bytes32, String) keys and Flatbuffers values.
1522
+ """
1523
+
1524
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1525
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1526
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1527
+
1528
+
1529
+ #
1530
+ # Key types: Bytes20, (Bytes20, Bytes20), (Bytes20, String)
1531
+ # Value type: FlatBuffers
1532
+ #
1533
+
1534
+
1535
+ class MapBytes20Bytes20(
1536
+ _types._Bytes20KeysMixin, _types._Bytes20ValuesMixin, PersistentMap
1537
+ ):
1538
+ """
1539
+ Persistent map with Bytes20 keys and Bytes20 values.
1540
+ """
1541
+
1542
+ def __init__(self, slot=None, compress=None):
1543
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1544
+
1545
+
1546
+ class MapBytes20Bytes20Timestamp(
1547
+ _types._Bytes20KeysMixin, _types._Bytes20TimestampValuesMixin, PersistentMap
1548
+ ):
1549
+ """
1550
+ Persistent map with Bytes20 keys and (Bytes20, Timestamp) values.
1551
+ """
1552
+
1553
+ def __init__(self, slot=None, compress=None):
1554
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1555
+
1556
+
1557
+ class MapBytes20TimestampBytes20(
1558
+ _types._Bytes20TimestampKeysMixin, _types._Bytes20ValuesMixin, PersistentMap
1559
+ ):
1560
+ """
1561
+ Persistent map with (Bytes20, Timestamp) keys and Bytes20 values.
1562
+ """
1563
+
1564
+ def __init__(self, slot=None, compress=None):
1565
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1566
+
1567
+
1568
+ class MapBytes20TimestampUuid(
1569
+ _types._Bytes20TimestampKeysMixin, _types._UuidValuesMixin, PersistentMap
1570
+ ):
1571
+ """
1572
+ Persistent map with (Bytes20, Timestamp) keys and UUID values.
1573
+ """
1574
+
1575
+ def __init__(self, slot=None, compress=None):
1576
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1577
+
1578
+
1579
+ class MapBytes20Uuid(_types._Bytes20KeysMixin, _types._UuidValuesMixin, PersistentMap):
1580
+ """
1581
+ Persistent map with Bytes20 keys and UUID values.
1582
+ """
1583
+
1584
+ def __init__(self, slot=None, compress=None):
1585
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1586
+
1587
+
1588
+ class MapBytes20Bytes16(
1589
+ _types._Bytes20KeysMixin, _types._Bytes16ValuesMixin, PersistentMap
1590
+ ):
1591
+ """
1592
+ Persistent map with Bytes20 keys and Bytes16 values.
1593
+ """
1594
+
1595
+ def __init__(self, slot=None, compress=None):
1596
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1597
+
1598
+
1599
+ class MapBytes20FlatBuffers(
1600
+ _types._Bytes20KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1601
+ ):
1602
+ """
1603
+ Persistent map with Bytes20 keys and Flatbuffers values.
1604
+ """
1605
+
1606
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1607
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1608
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1609
+
1610
+
1611
+ class MapBytes16FlatBuffers(
1612
+ _types._Bytes16KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1613
+ ):
1614
+ """
1615
+ Persistent map with Bytes16 keys and Flatbuffers values.
1616
+ """
1617
+
1618
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1619
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1620
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1621
+
1622
+
1623
+ class MapBytes16TimestampUuid(
1624
+ _types._Bytes16TimestampKeysMixin, _types._UuidValuesMixin, PersistentMap
1625
+ ):
1626
+ """
1627
+ Persistent map with (Bytes20, Timestamp) keys and UUID values.
1628
+ """
1629
+
1630
+ def __init__(self, slot=None, compress=None):
1631
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1632
+
1633
+
1634
+ class MapBytes16TimestampUuidFlatBuffers(
1635
+ _types._Bytes16TimestampUuidKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1636
+ ):
1637
+ """
1638
+ Persistent map with (Bytes20, Timestamp, UUID) keys and Flatbuffers values.
1639
+ """
1640
+
1641
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1642
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1643
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1644
+
1645
+
1646
+ class MapBytes20Bytes20FlatBuffers(
1647
+ _types._Bytes20Bytes20KeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1648
+ ):
1649
+ """
1650
+ Persistent map with (Bytes20, Bytes20) keys and Flatbuffers values.
1651
+ """
1652
+
1653
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1654
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1655
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)
1656
+
1657
+
1658
+ class MapBytes20StringFlatBuffers(
1659
+ _types._Bytes20StringKeysMixin, _types._FlatBuffersValuesMixin, PersistentMap
1660
+ ):
1661
+ """
1662
+ Persistent map with (Bytes20, String) keys and Flatbuffers values.
1663
+ """
1664
+
1665
+ def __init__(self, slot=None, compress=None, build=None, cast=None):
1666
+ PersistentMap.__init__(self, slot=slot, compress=compress)
1667
+ _types._FlatBuffersValuesMixin.__init__(self, build=build, cast=cast)