rdbpython 0.2.6__tar.gz → 0.2.7__tar.gz

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.
Files changed (58) hide show
  1. {rdbpython-0.2.6 → rdbpython-0.2.7}/PKG-INFO +12 -2
  2. rdbpython-0.2.7/README.md +61 -0
  3. {rdbpython-0.2.6 → rdbpython-0.2.7}/pyproject.toml +9 -7
  4. {rdbpython-0.2.6 → rdbpython-0.2.7}/scripts/build-rocksdb-linux.sh +2 -1
  5. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/db.pxd +1 -1
  6. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/lib_rocksdb.pxd +15 -0
  7. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/lib_rocksdb.pyx +338 -108
  8. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpython.egg-info/PKG-INFO +12 -2
  9. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpython.egg-info/SOURCES.txt +1 -0
  10. rdbpython-0.2.7/tests/functional/test_lifetime.py +483 -0
  11. rdbpython-0.2.6/README.md +0 -51
  12. {rdbpython-0.2.6 → rdbpython-0.2.7}/LICENSE.md +0 -0
  13. {rdbpython-0.2.6 → rdbpython-0.2.7}/MANIFEST.in +0 -0
  14. {rdbpython-0.2.6 → rdbpython-0.2.7}/scripts/build-rocksdb-macos.sh +0 -0
  15. {rdbpython-0.2.6 → rdbpython-0.2.7}/scripts/rocksdb-cstdint.patch +0 -0
  16. {rdbpython-0.2.6 → rdbpython-0.2.7}/setup.cfg +0 -0
  17. {rdbpython-0.2.6 → rdbpython-0.2.7}/setup.py +0 -0
  18. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/__init__.py +0 -0
  19. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/backup.pxd +0 -0
  20. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/cache.pxd +0 -0
  21. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/comparator.pxd +0 -0
  22. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/env.pxd +0 -0
  23. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/errors.py +0 -0
  24. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/filter_policy.pxd +0 -0
  25. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/include/rdb_include/comparator_wrapper.hpp +0 -0
  26. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/include/rdb_include/filter_policy_wrapper.hpp +0 -0
  27. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/include/rdb_include/memtable_factories.hpp +0 -0
  28. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/include/rdb_include/merge_operator_wrapper.hpp +0 -0
  29. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/include/rdb_include/slice_transform_wrapper.hpp +0 -0
  30. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/include/rdb_include/utils.hpp +0 -0
  31. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/include/rdb_include/write_batch_iter_helper.hpp +0 -0
  32. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/interfaces.py +0 -0
  33. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/iterator.pxd +0 -0
  34. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/lib_rocksdb.pyi +0 -0
  35. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/lib_utils.py +0 -0
  36. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/logger.pxd +0 -0
  37. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/memtablerep.pxd +0 -0
  38. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/merge_operator.pxd +0 -0
  39. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/merge_operators.py +0 -0
  40. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/options.pxd +0 -0
  41. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/slice_.pxd +0 -0
  42. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/slice_transform.pxd +0 -0
  43. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/snapshot.pxd +0 -0
  44. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/status.pxd +0 -0
  45. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/std_memory.pxd +0 -0
  46. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/table_factory.pxd +0 -0
  47. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/transaction.pxd +0 -0
  48. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpy/universal_compaction.pxd +0 -0
  49. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpython.egg-info/dependency_links.txt +0 -0
  50. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpython.egg-info/not-zip-safe +0 -0
  51. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpython.egg-info/requires.txt +0 -0
  52. {rdbpython-0.2.6 → rdbpython-0.2.7}/src/rdbpython.egg-info/top_level.txt +0 -0
  53. {rdbpython-0.2.6 → rdbpython-0.2.7}/tests/conftest.py +0 -0
  54. {rdbpython-0.2.6 → rdbpython-0.2.7}/tests/functional/__init__.py +0 -0
  55. {rdbpython-0.2.6 → rdbpython-0.2.7}/tests/functional/test_db.py +0 -0
  56. {rdbpython-0.2.6 → rdbpython-0.2.7}/tests/functional/test_memtable.py +0 -0
  57. {rdbpython-0.2.6 → rdbpython-0.2.7}/tests/functional/test_options.py +0 -0
  58. {rdbpython-0.2.6 → rdbpython-0.2.7}/tests/functional/test_transaction.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdbpython
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: Python bindings for RocksDB with Cython
5
5
  Author-email: Gor Arakelyan <gorarkln@gmail.com>
6
6
  Maintainer-email: Gor Arakelyan <gorarkln@gmail.com>
@@ -10,7 +10,7 @@ Project-URL: Documentation, https://github.com/nustackdev/rdbpy#readme
10
10
  Project-URL: Repository, https://github.com/nustackdev/rdbpy
11
11
  Project-URL: Issues, https://github.com/nustackdev/rdbpy/issues
12
12
  Project-URL: PyPI, https://pypi.org/project/rdbpython/
13
- Keywords: rocksdb,database,key-value,storage,embedded,cython
13
+ Keywords: nustack,python,rocksdb,key-value-store,embedded-database,transactions,bindings,storage
14
14
  Classifier: Development Status :: 3 - Alpha
15
15
  Classifier: Intended Audience :: Developers
16
16
  Classifier: Operating System :: OS Independent
@@ -80,6 +80,16 @@ while it.valid():
80
80
  it.next()
81
81
  ```
82
82
 
83
+ ## Lifetimes and threads
84
+
85
+ Iterators, snapshots and transactions point into native state owned by their parent:
86
+
87
+ - `Transaction.commit()`, `rollback()`, `close()` and a successful `rollback_to_save_point()` invalidate every iterator created from that transaction. So does `TransactionDB.begin_transaction(reuse=txn)`.
88
+ - `DB.close()` / `TransactionDB.close()` invalidate every iterator and snapshot of the DB and roll back any transaction that is still open.
89
+ - Using an invalidated iterator, or a DB after `close()`, raises `RuntimeError`. Dropping an invalidated object is safe, in any order, including when gc frees it.
90
+
91
+ Threads: a transaction and its iterators belong to one thread and must not be shared between threads. rdbpy does no locking of its own and releases the GIL inside RocksDB calls, so ending a transaction, or closing a DB, while another thread is still inside a call on it or on its iterators is undefined behaviour and can crash. Close a DB only after every thread is done with it. A finalizer (a generator's `finally`, `__del__`) that ends a transaction runs on whichever thread triggers gc, so it counts as using the transaction from that thread. gc merely freeing objects on another thread is safe.
92
+
83
93
  ## Development
84
94
 
85
95
  ```bash
@@ -0,0 +1,61 @@
1
+ # rdbpy
2
+
3
+ Python bindings for RocksDB with Cython - **batteries included!**
4
+
5
+ **No RocksDB installation required** - everything is bundled in the wheel for Linux and macOS (Intel + Apple Silicon).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install rdbpython
11
+ ```
12
+
13
+ That's it! No need to install RocksDB or any compression libraries manually.
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ import rdbpy
19
+
20
+ # Open database
21
+ options = rdbpy.Options(create_if_missing=True)
22
+ db = rdbpy.DB('/path/to/db', options)
23
+
24
+ # Put/Get
25
+ db.put(b'key', b'value')
26
+ value = db.get(b'key')
27
+
28
+ # Iterate
29
+ it = db.iterkeys()
30
+ it.seek_to_first()
31
+ while it.valid():
32
+ print(it.key())
33
+ it.next()
34
+ ```
35
+
36
+ ## Lifetimes and threads
37
+
38
+ Iterators, snapshots and transactions point into native state owned by their parent:
39
+
40
+ - `Transaction.commit()`, `rollback()`, `close()` and a successful `rollback_to_save_point()` invalidate every iterator created from that transaction. So does `TransactionDB.begin_transaction(reuse=txn)`.
41
+ - `DB.close()` / `TransactionDB.close()` invalidate every iterator and snapshot of the DB and roll back any transaction that is still open.
42
+ - Using an invalidated iterator, or a DB after `close()`, raises `RuntimeError`. Dropping an invalidated object is safe, in any order, including when gc frees it.
43
+
44
+ Threads: a transaction and its iterators belong to one thread and must not be shared between threads. rdbpy does no locking of its own and releases the GIL inside RocksDB calls, so ending a transaction, or closing a DB, while another thread is still inside a call on it or on its iterators is undefined behaviour and can crash. Close a DB only after every thread is done with it. A finalizer (a generator's `finally`, `__del__`) that ends a transaction runs on whichever thread triggers gc, so it counts as using the transaction from that thread. gc merely freeing objects on another thread is safe.
45
+
46
+ ## Development
47
+
48
+ ```bash
49
+ # Setup
50
+ make install
51
+
52
+ # Build
53
+ make build
54
+
55
+ # Test
56
+ make test
57
+ ```
58
+
59
+ ## License
60
+
61
+ Apache-2.0
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
10
10
  # ============================================================================
11
11
  [project]
12
12
  name = "rdbpython"
13
- version = "0.2.6"
13
+ version = "0.2.7"
14
14
  description = "Python bindings for RocksDB with Cython"
15
15
  readme = "README.md"
16
16
  license = "Apache-2.0"
@@ -21,12 +21,14 @@ maintainers = [
21
21
  {name = "Gor Arakelyan", email = "gorarkln@gmail.com"}
22
22
  ]
23
23
  keywords = [
24
+ "nustack",
25
+ "python",
24
26
  "rocksdb",
25
- "database",
26
- "key-value",
27
+ "key-value-store",
28
+ "embedded-database",
29
+ "transactions",
30
+ "bindings",
27
31
  "storage",
28
- "embedded",
29
- "cython"
30
32
  ]
31
33
  classifiers = [
32
34
  "Development Status :: 3 - Alpha",
@@ -241,7 +243,7 @@ directory = "tests/reports/coverage"
241
243
  # ============================================================================
242
244
  [tool.ruff]
243
245
  line-length = 100
244
- target-version = "py312"
246
+ target-version = "py39"
245
247
  src = ["src", "tests"]
246
248
  extend-exclude = [
247
249
  ".venv",
@@ -317,7 +319,7 @@ docstring-code-line-length = 80
317
319
  # Type Checking - mypy
318
320
  # ============================================================================
319
321
  [tool.mypy]
320
- python_version = "3.12"
322
+ python_version = "3.9"
321
323
  warn_return_any = true
322
324
  warn_unused_configs = true
323
325
  disallow_untyped_defs = false
@@ -142,6 +142,7 @@ tar xzf "rocksdb-${ROCKSDB_VERSION}.tar.gz"
142
142
  cd "rocksdb-${ROCKSDB_VERSION}"
143
143
 
144
144
  # Apply patch to fix missing <cstdint> include for newer GCC versions
145
+ # (GCC 13+ needs it in more headers; the build also force-includes it below)
145
146
  echo "Applying cstdint patch..."
146
147
  SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || realpath "${BASH_SOURCE[0]}" 2>/dev/null || echo "${BASH_SOURCE[0]}")")"
147
148
  if [ -f "$SCRIPT_DIR/rocksdb-cstdint.patch" ]; then
@@ -160,7 +161,7 @@ make static_lib shared_lib -j$(nproc) \
160
161
  USE_RTTI=1 \
161
162
  DISABLE_WARNING_AS_ERROR=1 \
162
163
  DEBUG_LEVEL=0 \
163
- EXTRA_CXXFLAGS="$CXXFLAGS" \
164
+ EXTRA_CXXFLAGS="$CXXFLAGS -include cstdint" \
164
165
  EXTRA_LDFLAGS="$LDFLAGS"
165
166
 
166
167
  # Install
@@ -113,7 +113,7 @@ cdef extern from "rocksdb/db.h" namespace "rocksdb":
113
113
  const options.ReadOptions&,
114
114
  ColumnFamilyHandle*) nogil except+
115
115
 
116
- void NewIterators(
116
+ Status NewIterators(
117
117
  const options.ReadOptions&,
118
118
  vector[ColumnFamilyHandle*]&,
119
119
  vector[Iterator*]*) nogil except+
@@ -622,6 +622,13 @@ cdef class DB(IDB):
622
622
  cdef db.DB* db
623
623
  cdef list cf_handles
624
624
  cdef list cf_options
625
+ cdef set _iterators
626
+ cdef set _snapshots
627
+ # Used by TransactionDB, declared here so it is still set when
628
+ # DB.__dealloc__ calls TransactionDB.close() after TransactionDB's own
629
+ # fields were cleared.
630
+ cdef set _transactions
631
+ cdef int _check_open(self) except -1
625
632
  # def __cinit__(self, db_name, Options opts, dict column_families = *, read_only=False)
626
633
  # def __dealloc__(self)
627
634
  cpdef void close(self)
@@ -668,10 +675,14 @@ cdef class TransactionDB(DB):
668
675
  cpdef void close(self)
669
676
 
670
677
 
678
+ @cython.no_gc_clear
671
679
  cdef class Transaction(object):
672
680
  cdef transaction.Transaction* txn
673
681
  cdef TransactionDB db
674
682
  cdef bint closed
683
+ cdef set _iterators
684
+
685
+ cdef void _release(self)
675
686
 
676
687
  cdef void _ensure_open(self)
677
688
  cpdef void close(self)
@@ -717,12 +728,16 @@ cdef class Iterator:
717
728
  cpdef void skip_back(self)
718
729
 
719
730
 
731
+ @cython.no_gc_clear
720
732
  cdef class BaseIterator(Iterator):
721
733
  cdef iterator.Iterator* ptr
722
734
  cdef DB db
723
735
  cdef ColumnFamilyHandle handle
724
736
  cdef object owner
725
737
 
738
+ cdef int _check_valid(self) except -1
739
+ cdef void _invalidate(self)
740
+
726
741
  # def __cinit__(self, DB db, ColumnFamilyHandle handle = None)
727
742
  # def __dealloc__(self)
728
743
  # def __iter__(self)