scruby 0.11.0__py3-none-any.whl → 0.12.0__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.

Potentially problematic release.


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

scruby/__init__.py CHANGED
@@ -1,8 +1,7 @@
1
- """A fast key-value storage library.
1
+ """Asynchronous library for building and managing a hybrid database, by scheme of key-value.
2
2
 
3
- Scruby is a fast key-value storage asynchronous library that provides an
4
- ordered mapping from string keys to string values.
5
- The library uses fractal-tree addressing.
3
+ The library uses fractal-tree addressing and
4
+ the search for documents based on the effect of a quantum loop.
6
5
 
7
6
  The database consists of collections.
8
7
  The maximum size of the one collection is 16**8=4294967296 branches,
@@ -11,7 +10,8 @@ each branch can store one or more keys.
11
10
  The value of any key in collection can be obtained in 8 steps,
12
11
  thereby achieving high performance.
13
12
 
14
- In the future, to search by value of key, the use of a quantum loop is supposed.
13
+ The effectiveness of the search for documents based on a quantum loop,
14
+ requires a large number of processor threads.
15
15
  """
16
16
 
17
17
  from __future__ import annotations
scruby/db.py CHANGED
@@ -467,7 +467,7 @@ class Scruby[T]:
467
467
  def _task_delete(
468
468
  branch_number: int,
469
469
  filter_fn: Callable,
470
- hash_reduce_left: str,
470
+ hash_reduce_left: int,
471
471
  db_root: str,
472
472
  class_model: T,
473
473
  ) -> int:
@@ -539,3 +539,48 @@ class Scruby[T]:
539
539
  if counter < 0:
540
540
  self._sync_counter_documents(counter)
541
541
  return abs(counter)
542
+
543
+ @staticmethod
544
+ def _task_get_docs(
545
+ branch_number: int,
546
+ hash_reduce_left: int,
547
+ db_root: str,
548
+ class_model: T,
549
+ ) -> list[Any]:
550
+ """Get documents for custom task.
551
+
552
+ This method is for internal use.
553
+ """
554
+ branch_number_as_hash: str = f"{branch_number:08x}"[hash_reduce_left:]
555
+ separated_hash: str = "/".join(list(branch_number_as_hash))
556
+ leaf_path: SyncPath = SyncPath(
557
+ *(
558
+ db_root,
559
+ class_model.__name__,
560
+ separated_hash,
561
+ "leaf.json",
562
+ ),
563
+ )
564
+ docs = []
565
+ if leaf_path.exists():
566
+ data_json: bytes = leaf_path.read_bytes()
567
+ data: dict[str, str] = orjson.loads(data_json) or {}
568
+ for _, val in data.items():
569
+ docs.append(class_model.model_validate_json(val))
570
+ return docs
571
+
572
+ def run_custom_task(self, custom_task: Callable) -> Any:
573
+ """Running custom task.
574
+
575
+ This method running a task created on the basis of a quantum loop.
576
+ Effectiveness running task depends on the number of processor threads.
577
+ Ideally, hundreds and even thousands of threads are required.
578
+ """
579
+ kwargs = {
580
+ "get_docs_fn": self._task_get_docs,
581
+ "branch_numbers": range(1, self.__max_branch_number),
582
+ "hash_reduce_left": self.__hash_reduce_left,
583
+ "db_root": self.__db_root,
584
+ "class_model": self.__class_model,
585
+ }
586
+ return custom_task(**kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.11.0
3
+ Version: 0.12.0
4
4
  Summary: A fast key-value storage library.
5
5
  Project-URL: Homepage, https://github.com/kebasyaty/scruby
6
6
  Project-URL: Repository, https://github.com/kebasyaty/scruby
@@ -43,7 +43,7 @@ Description-Content-Type: text/markdown
43
43
  </p>
44
44
  <p>
45
45
  <h1>Scruby</h1>
46
- <h3>A fast key-value storage library.</h3>
46
+ <h3>Asynchronous library for building and managing a hybrid database,<br>by scheme of key-value.</h3>
47
47
  <p align="center">
48
48
  <a href="https://github.com/kebasyaty/scruby/actions/workflows/test.yml" alt="Build Status"><img src="https://github.com/kebasyaty/scruby/actions/workflows/test.yml/badge.svg" alt="Build Status"></a>
49
49
  <a href="https://kebasyaty.github.io/scruby/" alt="Docs"><img src="https://img.shields.io/badge/docs-available-brightgreen.svg" alt="Docs"></a>
@@ -65,20 +65,23 @@ Description-Content-Type: text/markdown
65
65
  <a href="https://github.com/kebasyaty/scruby/releases/" alt="GitHub release"><img src="https://img.shields.io/github/release/kebasyaty/scruby" alt="GitHub release"></a>
66
66
  </p>
67
67
  <p align="center">
68
- Scruby is a fast key-value storage asynchronous library that provides an
69
- <br>
70
- ordered mapping from string keys to string values.
71
- <br>
72
- The library uses fractal-tree addressing.
73
- <br>
74
- The database consists of collections.
75
- <br>
76
- The maximum size of the one collection is 16**8=4294967296 branches,
77
- each branch can store one or more keys.
78
- <br>
79
- The value of any key in collection can be obtained in 8 steps, thereby achieving high performance.
80
- <br>
81
- In the future, to search by value of key, the use of a quantum loop is supposed.
68
+ The library uses fractal-tree addressing and
69
+ <br>
70
+ the search for documents based on the effect of a quantum loop.
71
+ <br>
72
+ The database consists of collections.
73
+ <br>
74
+ The maximum size of the one collection is 16\*\*8=4294967296 branches,
75
+ <br>
76
+ each branch can store one or more keys.
77
+ <br>
78
+ The value of any key in collection can be obtained in 8 steps,
79
+ <br>
80
+ thereby achieving high performance.
81
+ <br>
82
+ The effectiveness of the search for documents based on a quantum loop,
83
+ <br>
84
+ requires a large number of processor threads.
82
85
  </p>
83
86
  </p>
84
87
  </div>
@@ -117,6 +120,7 @@ from scruby import Scruby, constants
117
120
 
118
121
  constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
119
122
 
123
+
120
124
  class User(BaseModel):
121
125
  """Model of User."""
122
126
  first_name: str
@@ -125,6 +129,7 @@ class User(BaseModel):
125
129
  email: EmailStr
126
130
  phone: Annotated[PhoneNumber, PhoneNumberValidator(number_format="E164")]
127
131
 
132
+
128
133
  async def main() -> None:
129
134
  """Example."""
130
135
  # Get collection of `User`.
@@ -154,6 +159,7 @@ async def main() -> None:
154
159
  # Hint: The main purpose is tests.
155
160
  await Scruby.napalm()
156
161
 
162
+
157
163
  if __name__ == "__main__":
158
164
  anyio.run(main)
159
165
  ```
@@ -176,7 +182,8 @@ from pprint import pprint as pp
176
182
 
177
183
  constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
178
184
  constants.HASH_REDUCE_LEFT = 6 # 256 branches in collection
179
- # (main purpose is tests).
185
+ # (main purpose is tests).
186
+
180
187
 
181
188
  class User(BaseModel):
182
189
  """Model of User."""
@@ -186,6 +193,7 @@ class User(BaseModel):
186
193
  email: EmailStr
187
194
  phone: Annotated[PhoneNumber, PhoneNumberValidator(number_format="E164")]
188
195
 
196
+
189
197
  async def main() -> None:
190
198
  """Example."""
191
199
  # Get collection of `User`.
@@ -225,6 +233,7 @@ async def main() -> None:
225
233
  # Hint: The main purpose is tests.
226
234
  await Scruby.napalm()
227
235
 
236
+
228
237
  if __name__ == "__main__":
229
238
  anyio.run(main)
230
239
  ```
@@ -247,7 +256,8 @@ from pprint import pprint as pp
247
256
 
248
257
  constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
249
258
  constants.HASH_REDUCE_LEFT = 6 # 256 branches in collection
250
- # (main purpose is tests).
259
+ # (main purpose is tests).
260
+
251
261
 
252
262
  class User(BaseModel):
253
263
  """Model of User."""
@@ -257,6 +267,7 @@ class User(BaseModel):
257
267
  email: EmailStr
258
268
  phone: Annotated[PhoneNumber, PhoneNumberValidator(number_format="E164")]
259
269
 
270
+
260
271
  async def main() -> None:
261
272
  """Example."""
262
273
  # Get collection of `User`.
@@ -286,6 +297,7 @@ async def main() -> None:
286
297
  # Hint: The main purpose is tests.
287
298
  await Scruby.napalm()
288
299
 
300
+
289
301
  if __name__ == "__main__":
290
302
  anyio.run(main)
291
303
  ```
@@ -0,0 +1,9 @@
1
+ scruby/__init__.py,sha256=GOVcjXmcOEDBbJQJDJlQq-x3M-VGJaMSN278EXsl2po,884
2
+ scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
3
+ scruby/db.py,sha256=fFJKCvvDmHKXzQubghG2DoRV7xumd460sHGqCDCCgh0,21877
4
+ scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
5
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ scruby-0.12.0.dist-info/METADATA,sha256=Ok-HJBIDsQ-DktJRjoIORaC91Vbc8qt9UPc-VN9k57Q,10925
7
+ scruby-0.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ scruby-0.12.0.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
9
+ scruby-0.12.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- scruby/__init__.py,sha256=wFwUS1KcLxfIopXOVS8gPue9fNzIIU2cVj_RgK5drz4,849
2
- scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
3
- scruby/db.py,sha256=Q7J4OKS2emiF0KzZClSjpBBLjohnccZ81T4pgoWNxqA,20269
4
- scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
5
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- scruby-0.11.0.dist-info/METADATA,sha256=yS9LDAYAqmxxn8cXHKbO7BmPEsX4o7th3VVFtgr9aoo,10824
7
- scruby-0.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- scruby-0.11.0.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
9
- scruby-0.11.0.dist-info/RECORD,,