scruby 0.7.0__py3-none-any.whl → 0.7.2__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/constants.py CHANGED
@@ -3,18 +3,18 @@
3
3
  The module contains the following variables:
4
4
 
5
5
  - `DB_ROOT` - Path to root directory of database. `By default = "ScrubyDB"` (*in root of project*).
6
- - `LENGTH_SEPARATED_HASH` - Length of separated hash for create path inside collection.
7
- - `0` - 4294967296 keys (by default).
8
- - `2` - 16777216 keys.
9
- - `4` - 65536 keys.
10
- - `6` - 256 keys (main purpose is tests).
6
+ - `LENGTH_REDUCTION_HASH` - The length of the hash reduction on the left side.
7
+ - `0` - 4294967296 branches in collection (by default).
8
+ - `2` - 16777216 branches in collectionю
9
+ - `4` - 65536 branches in collectionю
10
+ - `6` - 256 branches in collection (main purpose is tests).
11
11
  """
12
12
 
13
13
  from __future__ import annotations
14
14
 
15
15
  __all__ = (
16
16
  "DB_ROOT",
17
- "LENGTH_SEPARATED_HASH",
17
+ "LENGTH_REDUCTION_HASH",
18
18
  )
19
19
 
20
20
  from typing import Literal
@@ -23,9 +23,9 @@ from typing import Literal
23
23
  # By default = "ScrubyDB" (in root of project).
24
24
  DB_ROOT: str = "ScrubyDB"
25
25
 
26
- # Length of separated hash for create path inside collection.
27
- # 0 = 4294967296 keys (by default).
28
- # 2 = 16777216 keys.
29
- # 4 = 65536 keys.
30
- # 6 = 256 keys (main purpose is tests).
31
- LENGTH_SEPARATED_HASH: Literal[0, 2, 4, 6] = 0
26
+ # The length of the hash reduction on the left side.
27
+ # 0 = 4294967296 branches in collection (by default).
28
+ # 2 = 16777216 branches in collectionю
29
+ # 4 = 65536 branches in collectionю
30
+ # 6 = 256 branches in collection (main purpose is tests).
31
+ LENGTH_REDUCTION_HASH: Literal[0, 2, 4, 6] = 0
scruby/db.py CHANGED
@@ -33,9 +33,9 @@ class Scruby[T]:
33
33
  ) -> None:
34
34
  self.__class_model = class_model
35
35
  self.__db_root = constants.DB_ROOT
36
- self.__length_hash = constants.LENGTH_SEPARATED_HASH
36
+ self.__length_reduction_hash = constants.LENGTH_REDUCTION_HASH
37
37
  # The maximum number of keys.
38
- match self.__length_hash:
38
+ match self.__length_reduction_hash:
39
39
  case 0:
40
40
  self.__max_num_keys = 4294967296
41
41
  case 2:
@@ -58,7 +58,7 @@ class Scruby[T]:
58
58
  if len(key) == 0:
59
59
  raise KeyError("The key should not be empty.")
60
60
  # Key to crc32 sum.
61
- key_as_hash: str = f"{zlib.crc32(key.encode('utf-8')):08x}"[self.__length_hash :]
61
+ key_as_hash: str = f"{zlib.crc32(key.encode('utf-8')):08x}"[self.__length_reduction_hash :]
62
62
  # Convert crc32 sum in the segment of path.
63
63
  separated_hash: str = "/".join(list(key_as_hash))
64
64
  # The path of the branch to the database.
@@ -170,12 +170,12 @@ class Scruby[T]:
170
170
  def search_task(
171
171
  key: int,
172
172
  filter_fn: Callable,
173
- length_hash: str,
173
+ length_reduction_hash: str,
174
174
  db_root: str,
175
175
  class_model: T,
176
176
  ) -> dict[str, Any] | None:
177
177
  """Search task."""
178
- key_as_hash: str = f"{key:08x}"[length_hash:]
178
+ key_as_hash: str = f"{key:08x}"[length_reduction_hash:]
179
179
  separated_hash: str = "/".join(list(key_as_hash))
180
180
  leaf_path: SyncPath = SyncPath(
181
181
  *(
@@ -204,7 +204,7 @@ class Scruby[T]:
204
204
 
205
205
  The search is based on the effect of a quantum loop.
206
206
  The search effectiveness depends on the number of processor threads.
207
- Ideally, hundreds and even thousands of streams are required.
207
+ Ideally, hundreds and even thousands of threads are required.
208
208
 
209
209
  Args:
210
210
  filter_fn: A function that execute the conditions of filtering.
@@ -216,7 +216,7 @@ class Scruby[T]:
216
216
  """
217
217
  keys: range = range(1, self.__max_num_keys)
218
218
  search_task_fn: Callable = self.search_task
219
- length_hash: int = self.__length_hash
219
+ length_reduction_hash: int = self.__length_reduction_hash
220
220
  db_root: str = self.__db_root
221
221
  class_model: T = self.__class_model
222
222
  with concurrent.futures.ThreadPoolExecutor(max_workers) as executor:
@@ -225,7 +225,7 @@ class Scruby[T]:
225
225
  search_task_fn,
226
226
  key,
227
227
  filter_fn,
228
- length_hash,
228
+ length_reduction_hash,
229
229
  db_root,
230
230
  class_model,
231
231
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.7.0
3
+ Version: 0.7.2
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
@@ -160,7 +160,7 @@ if __name__ == "__main__":
160
160
 
161
161
  The search is based on the effect of a quantum loop.
162
162
  The search effectiveness depends on the number of processor threads.
163
- Ideally, hundreds and even thousands of streams are required.
163
+ Ideally, hundreds and even thousands of threads are required.
164
164
  """
165
165
 
166
166
  import anyio
@@ -171,7 +171,8 @@ from scruby import Scruby, constants
171
171
  from pprint import pprint as pp
172
172
 
173
173
  constants.DB_ROOT = "ScrubyDB" # By default = "ScrubyDB"
174
- constants.LENGTH_SEPARATED_HASH = 6 # 256 keys (main purpose is tests).
174
+ constants.LENGTH_REDUCTION_HASH = 6 # 256 branches in collection
175
+ # (main purpose is tests).
175
176
 
176
177
  class User(BaseModel):
177
178
  """Model of User."""
@@ -0,0 +1,8 @@
1
+ scruby/__init__.py,sha256=myX7sG-7oAQZGdgfZtTGXYCCraTeuwi7SjBoltftpnM,648
2
+ scruby/constants.py,sha256=GbB-O0qaVdi5EHUp-zRAppFXLR-oHxpXUFVAOCpS0C8,1022
3
+ scruby/db.py,sha256=84DRrw21jiAmEsxjOOJnAfFvfE8hNdaJ-TB9BQtM0CQ,8114
4
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ scruby-0.7.2.dist-info/METADATA,sha256=b_02kOWP7dScGNwKtvVwQrv7CPiIHHIJ33OxMMz5Ink,8673
6
+ scruby-0.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ scruby-0.7.2.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
+ scruby-0.7.2.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- scruby/__init__.py,sha256=myX7sG-7oAQZGdgfZtTGXYCCraTeuwi7SjBoltftpnM,648
2
- scruby/constants.py,sha256=1Po5FSYj1qst8F05L4cPyKsDHNmReXDx_IKYgNa06eI,892
3
- scruby/db.py,sha256=qelkW6MzI4HQOtkXDb8qOJHfqsads3vILSnddboQEOc,8034
4
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- scruby-0.7.0.dist-info/METADATA,sha256=uH-rBdWc5tDUhFxTYac6Z3EDua6z-H-mWBXo9gB47Mc,8616
6
- scruby-0.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- scruby-0.7.0.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
- scruby-0.7.0.dist-info/RECORD,,
File without changes