scruby 2.1.2__py3-none-any.whl → 2.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
scruby/__init__.py CHANGED
@@ -15,10 +15,10 @@
15
15
  The library uses fractal-tree addressing and
16
16
  the search for documents based on the effect of a quantum loop.
17
17
 
18
- The size of each collection is 4096 branches,
18
+ The size of each collection is 16|256|4096|4294967296 branches,
19
19
  each branch can store one or more keys.
20
20
 
21
- The value of any key in collection can be obtained in 3 steps,
21
+ The value of any key in collection can be obtained in 1-8 steps,
22
22
  thereby achieving high performance.
23
23
 
24
24
  The effectiveness of the search for documents based on a quantum loop,
scruby/config.py CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  The settings class contains the following parameters:
8
8
 
9
- - `db_root` - Path to root directory of database. `Default = "ScrubyDB" (in root of project)`.
10
9
  - `db_id` - Database ID.
10
+ - `db_root` - Path to root directory of database. `Default = "ScrubyDB" (in root of project)`.
11
11
  - `HASH_REDUCE_LEFT` - The length of the hash reduction on the left side.
12
12
  - `7` - 16 branches in collection (is default).
13
13
  - `6` - 256 branches in collection.
@@ -34,14 +34,14 @@ from scruby.utils import add_to_env, get_from_env
34
34
  class ScrubyConfig:
35
35
  """Database settings."""
36
36
 
37
- # Path to root directory of database
38
- # By default = "ScrubyDB" (in root of project).
39
- db_root: ClassVar[str] = "ScrubyDB"
40
-
41
37
  # Database ID
42
38
  # Will be automatically assigned.
43
39
  db_id: ClassVar[str | None] = None
44
40
 
41
+ # Path to root directory of database
42
+ # By default = "ScrubyDB" (in root of project).
43
+ db_root: ClassVar[str] = "ScrubyDB"
44
+
45
45
  # The length of the hash reduction on the left side.
46
46
  # 7 = 16 branches in collection.
47
47
  # 6 = 256 branches in collection (is default).
@@ -134,3 +134,14 @@ class ScrubyConfig:
134
134
  + f"is not equal to the primary value {hash_reduce_left}."
135
135
  )
136
136
  raise ValueError(msg)
137
+
138
+ @classmethod
139
+ def restore(cls) -> None:
140
+ """Restore default parameter values."""
141
+ cls.db_id = None
142
+ cls.db_root = "ScrubyDB"
143
+ cls.HASH_REDUCE_LEFT = 7
144
+ cls.MAX_NUMBER_BRANCH = 16
145
+ cls.max_workers = None
146
+ cls.plugins = None
147
+ cls.sys_platform = sys.platform
scruby/db.py CHANGED
@@ -60,8 +60,8 @@ class Scruby(
60
60
  ) -> None:
61
61
  super().__init__()
62
62
  self._meta = _Meta
63
- self._db_root = ScrubyConfig.db_root
64
63
  self._db_id = ScrubyConfig.db_id
64
+ self._db_root = ScrubyConfig.db_root
65
65
  self._hash_reduce_left = ScrubyConfig.HASH_REDUCE_LEFT
66
66
  self._max_number_branch = ScrubyConfig.MAX_NUMBER_BRANCH
67
67
  self._max_workers = ScrubyConfig.max_workers
@@ -126,8 +126,8 @@ class Scruby(
126
126
  await meta_dir_path.mkdir(parents=True)
127
127
  meta = _Meta(
128
128
  collection_name=class_model.__name__,
129
- hash_reduce_left=ScrubyConfig.HASH_REDUCE_LEFT,
130
- max_number_branch=ScrubyConfig.MAX_NUMBER_BRANCH,
129
+ hash_reduce_left=instance.__dict__["_hash_reduce_left"],
130
+ max_number_branch=instance.__dict__["_max_number_branch"],
131
131
  counter_documents=0,
132
132
  )
133
133
  # Save metadata of collection.
@@ -245,6 +245,7 @@ class Scruby(
245
245
  DocCache.cache = {}
246
246
  with contextlib.suppress(FileNotFoundError):
247
247
  rmtree(ScrubyConfig.db_root)
248
+ ScrubyConfig.restore()
248
249
  return
249
250
 
250
251
  @staticmethod
scruby/mixins/count.py CHANGED
@@ -63,9 +63,9 @@ class Count:
63
63
  futures: list[Future] = [
64
64
  executor.submit(
65
65
  search_task_fn,
66
- branch_number,
67
66
  filter_fn,
68
67
  hash_reduce_left,
68
+ branch_number,
69
69
  class_model,
70
70
  stop_signal,
71
71
  )
@@ -41,8 +41,8 @@ class CustomTask:
41
41
  return custom_task_fn(
42
42
  search_task_fn=self._task_find,
43
43
  filter_fn=filter_fn,
44
- branch_numbers=range(self._max_number_branch),
45
44
  hash_reduce_left=hash_reduce_left,
45
+ branch_numbers=range(self._max_number_branch),
46
46
  class_model=self._class_model,
47
47
  max_workers=self._max_workers,
48
48
  stop_signal=Event(),
scruby/mixins/delete.py CHANGED
@@ -24,10 +24,10 @@ class Delete:
24
24
  @final
25
25
  @staticmethod
26
26
  async def _task_delete(
27
- branch_number: int,
28
27
  filter_fn: Callable,
29
- hash_reduce_left: int,
30
28
  db_root: str,
29
+ hash_reduce_left: int,
30
+ branch_number: int,
31
31
  class_model: Any,
32
32
  ) -> int:
33
33
  """Asynchronous task for find and delete documents.
@@ -107,10 +107,10 @@ class Delete:
107
107
  futures: list[Future] = [
108
108
  executor.submit(
109
109
  search_task_fn,
110
- branch_number,
111
110
  filter_fn,
112
- hash_reduce_left,
113
111
  db_root,
112
+ hash_reduce_left,
113
+ branch_number,
114
114
  class_model,
115
115
  )
116
116
  for branch_number in branch_numbers
scruby/mixins/find.py CHANGED
@@ -38,9 +38,9 @@ class Find:
38
38
  @final
39
39
  @staticmethod
40
40
  def _task_find(
41
- branch_number: int,
42
41
  filter_fn: Callable,
43
42
  hash_reduce_left: int,
43
+ branch_number: int,
44
44
  class_model: Any,
45
45
  stop_event: Event,
46
46
  ) -> list[Any] | None:
@@ -112,9 +112,9 @@ class Find:
112
112
  futures: list[Future] = [
113
113
  executor.submit(
114
114
  search_task_fn,
115
- branch_number,
116
115
  filter_fn,
117
116
  hash_reduce_left,
117
+ branch_number,
118
118
  class_model,
119
119
  stop_signal,
120
120
  )
@@ -200,9 +200,9 @@ class Find:
200
200
  futures: list[Future] = [
201
201
  executor.submit(
202
202
  search_task_fn,
203
- branch_number,
204
203
  filter_fn,
205
204
  hash_reduce_left,
205
+ branch_number,
206
206
  class_model,
207
207
  stop_signal,
208
208
  )
scruby/mixins/update.py CHANGED
@@ -25,10 +25,10 @@ class Update:
25
25
  @final
26
26
  @staticmethod
27
27
  async def _task_update(
28
- branch_number: int,
29
28
  filter_fn: Callable,
30
- hash_reduce_left: int,
31
29
  db_root: str,
30
+ hash_reduce_left: int,
31
+ branch_number: int,
32
32
  class_model: Any,
33
33
  new_data: dict[str, Any],
34
34
  ) -> int:
@@ -121,10 +121,10 @@ class Update:
121
121
  futures: list[Future] = [
122
122
  executor.submit(
123
123
  update_task_fn,
124
- branch_number,
125
124
  filter_fn,
126
- hash_reduce_left,
127
125
  db_root,
126
+ hash_reduce_left,
127
+ branch_number,
128
128
  class_model,
129
129
  copy.deepcopy(new_data),
130
130
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 2.1.2
3
+ Version: 2.2.1
4
4
  Summary: Asynchronous library for building and managing a hybrid database, by scheme of key-value.
5
5
  Project-URL: Bug Tracker, https://github.com/kebasyaty/scruby/issues
6
6
  Project-URL: Changelog, https://github.com/kebasyaty/scruby/blob/v2/CHANGELOG.md
@@ -0,0 +1,21 @@
1
+ scruby/__init__.py,sha256=DEtbZThadMKpKcGGjWyAFGu4IADg9ZYTb8WjfO_3Dqg,1300
2
+ scruby/aggregation.py,sha256=NBFxQqyRqUG2KIuD9fbl4uzSHJWTaskjiZ1YNBa-Zbo,3575
3
+ scruby/cache.py,sha256=hRj9Ix4XeYQzoAtav5lSXxuBZaxpqMzTg0sYAMBIEjM,3768
4
+ scruby/config.py,sha256=INAFqNAeF8BifIywjElC97rawfTLuqpRfieUdAO7A6k,5122
5
+ scruby/db.py,sha256=OtAwHtXoHaF_obqMwxn157EtVppO0tO6Dx2lWGFBEiA,9999
6
+ scruby/errors.py,sha256=lTWiHzyO5Es9Nkf7quODJjONGn6ifcL95qlpA4epQQM,1386
7
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ scruby/utils.py,sha256=ZwWxSyh_BAOQkXlIqXFOlX2lHVk9rfYGQiVqtTk8PpE,1865
9
+ scruby/mixins/__init__.py,sha256=nT79e80zXliuTGhR9CFosI2-3PQUCKwXbR7wPiFwgrU,669
10
+ scruby/mixins/collection.py,sha256=nTw0jnybox3iso0jzNoJiu61Hb-92zl84hdWhlWbik4,1792
11
+ scruby/mixins/count.py,sha256=CGpyOpsG25uC5utI2ByNxq2iTbJocj6w5tXrC1_cP40,2561
12
+ scruby/mixins/custom_task.py,sha256=DIry4gBlTdaqZqymar-RrHSdhEiC2tn2pl9jmbk56zw,1547
13
+ scruby/mixins/delete.py,sha256=InKVIud_ZYx9-CchUz_IygQDXMynNi4jQ0HKYeHC_R8,4328
14
+ scruby/mixins/find.py,sha256=oEZRE6RqIBdwvNr8iSYyod8hI6ibi_egJP0pyXmJiss,9169
15
+ scruby/mixins/keys.py,sha256=MvBy_8fQGROaQATK2qse2V8wR-xodPQG0KKZ2PK_t9U,10790
16
+ scruby/mixins/update.py,sha256=TyxvxB-gNijlfzTmhwrq0ydvu0C3R-RihW5h5tJ96bM,4964
17
+ scruby-2.2.1.dist-info/METADATA,sha256=Rpmh_TEK9wIRrJFR_U_U31H-pYgU0P7dgy2xpLTy9KU,13500
18
+ scruby-2.2.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
19
+ scruby-2.2.1.dist-info/licenses/GPL-3.0-LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
+ scruby-2.2.1.dist-info/licenses/MIT-LICENSE,sha256=mS0Wz0yGNB63gEcWEnuIb_lldDYV0sjRaO-o_GL6CWE,1074
21
+ scruby-2.2.1.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- scruby/__init__.py,sha256=40UhjME7WRJ-kHmqju4tMx9t1t6Sq6-EtL1LwgbTbcA,1280
2
- scruby/aggregation.py,sha256=NBFxQqyRqUG2KIuD9fbl4uzSHJWTaskjiZ1YNBa-Zbo,3575
3
- scruby/cache.py,sha256=hRj9Ix4XeYQzoAtav5lSXxuBZaxpqMzTg0sYAMBIEjM,3768
4
- scruby/config.py,sha256=Wf_mY-GpKhUvGmN7LBFMvRJ3bsYI0nVH6BjH9LWxosg,4802
5
- scruby/db.py,sha256=QRfC8BTMhlOlqTI2fYRtPsUjmtQUGyQX6eXATA9xHL4,9950
6
- scruby/errors.py,sha256=lTWiHzyO5Es9Nkf7quODJjONGn6ifcL95qlpA4epQQM,1386
7
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- scruby/utils.py,sha256=ZwWxSyh_BAOQkXlIqXFOlX2lHVk9rfYGQiVqtTk8PpE,1865
9
- scruby/mixins/__init__.py,sha256=nT79e80zXliuTGhR9CFosI2-3PQUCKwXbR7wPiFwgrU,669
10
- scruby/mixins/collection.py,sha256=nTw0jnybox3iso0jzNoJiu61Hb-92zl84hdWhlWbik4,1792
11
- scruby/mixins/count.py,sha256=LJHSfKgdyRgRXhz8ii_NBB-mu3ZBWr4_3_IJU6ANeMk,2561
12
- scruby/mixins/custom_task.py,sha256=vx1TyefM-P2OrXSIN0IXiGDuYiDekgNaOR66G0Eh6Fk,1547
13
- scruby/mixins/delete.py,sha256=SI_znHz_5zMnh8lEZxLXBbc3Nnewr7fBwnHfDD1syjw,4328
14
- scruby/mixins/find.py,sha256=BuioqvMEAVKPPch2bdPc1UxtSCBBXpnFjhINVfU7I7k,9169
15
- scruby/mixins/keys.py,sha256=MvBy_8fQGROaQATK2qse2V8wR-xodPQG0KKZ2PK_t9U,10790
16
- scruby/mixins/update.py,sha256=oLucFA6ckoPKpSHrGRYPxoEJnjGnXlcGLp0gfkwVECs,4964
17
- scruby-2.1.2.dist-info/METADATA,sha256=ZHGVK97VQoEW3VTFGNsjEMO7A7BON4ylGZOPV38X1EA,13500
18
- scruby-2.1.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
19
- scruby-2.1.2.dist-info/licenses/GPL-3.0-LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
- scruby-2.1.2.dist-info/licenses/MIT-LICENSE,sha256=mS0Wz0yGNB63gEcWEnuIb_lldDYV0sjRaO-o_GL6CWE,1074
21
- scruby-2.1.2.dist-info/RECORD,,
File without changes