scruby 0.14.1__py3-none-any.whl → 0.14.3__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/aggregation.py CHANGED
@@ -41,11 +41,11 @@ class Counter:
41
41
  """Aggregation class for calculating the number of documents.
42
42
 
43
43
  Args:
44
- max: The maximum counter value.
44
+ limit: The maximum counter value.
45
45
  """
46
46
 
47
- def __init__(self, max: int = 1000) -> None:
48
- self.max = max
47
+ def __init__(self, limit: int = 1000) -> None:
48
+ self.limit = limit
49
49
  self.counter = 0
50
50
 
51
51
  def check(self) -> bool:
@@ -54,7 +54,7 @@ class Counter:
54
54
  Returns:
55
55
  Boolean value. If `True`, the maximum value is achieved.
56
56
  """
57
- return self.counter >= self.max
57
+ return self.counter >= self.limit
58
58
 
59
59
  def next(self) -> None:
60
60
  """Increment the counter on one."""
scruby/db.py CHANGED
@@ -335,7 +335,7 @@ class Scruby[T]:
335
335
  def find_many(
336
336
  self,
337
337
  filter_fn: Callable,
338
- db_query_docs_limit: int = 1000,
338
+ limit_docs: int = 1000,
339
339
  max_workers: int | None = None,
340
340
  timeout: float | None = None,
341
341
  ) -> list[T] | None:
@@ -347,7 +347,7 @@ class Scruby[T]:
347
347
 
348
348
  Args:
349
349
  filter_fn: A function that execute the conditions of filtering.
350
- db_query_docs_limit: Limiting the number of request results. By default = 1000.
350
+ limit_docs: Limiting the number of documents. By default = 1000.
351
351
  max_workers: The maximum number of processes that can be used to
352
352
  execute the given calls. If None or not given then as many
353
353
  worker processes will be created as the machine has processors.
@@ -360,11 +360,11 @@ class Scruby[T]:
360
360
  db_root: str = self.__db_root
361
361
  class_model: T = self.__class_model
362
362
  counter: int = 0
363
+ docs: list[T] = []
363
364
  with concurrent.futures.ThreadPoolExecutor(max_workers) as executor:
364
- results = []
365
365
  for branch_number in branch_numbers:
366
- if counter == db_query_docs_limit:
367
- break
366
+ if counter >= limit_docs:
367
+ return docs or None
368
368
  future = executor.submit(
369
369
  search_task_fn,
370
370
  branch_number,
@@ -375,9 +375,9 @@ class Scruby[T]:
375
375
  )
376
376
  doc = future.result(timeout)
377
377
  if doc is not None:
378
- results.append(doc)
378
+ docs.append(doc)
379
379
  counter += 1
380
- return results or None
380
+ return docs or None
381
381
 
382
382
  def collection_name(self) -> str:
383
383
  """Get collection name."""
@@ -538,12 +538,16 @@ class Scruby[T]:
538
538
  docs.append(class_model.model_validate_json(val))
539
539
  return docs
540
540
 
541
- def run_custom_task(self, custom_task: Callable) -> Any:
541
+ def run_custom_task(self, custom_task_fn: Callable, limit_docs: int = 1000) -> Any:
542
542
  """Running custom task.
543
543
 
544
544
  This method running a task created on the basis of a quantum loop.
545
545
  Effectiveness running task depends on the number of processor threads.
546
546
  Ideally, hundreds and even thousands of threads are required.
547
+
548
+ Args:
549
+ custom_task_fn: A function that execute the custom task.
550
+ limit_docs: Limiting the number of documents. By default = 1000.
547
551
  """
548
552
  kwargs = {
549
553
  "get_docs_fn": self._task_get_docs,
@@ -551,5 +555,6 @@ class Scruby[T]:
551
555
  "hash_reduce_left": self.__hash_reduce_left,
552
556
  "db_root": self.__db_root,
553
557
  "class_model": self.__class_model,
558
+ "limit_docs": limit_docs,
554
559
  }
555
- return custom_task(**kwargs)
560
+ return custom_task_fn(**kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.14.1
3
+ Version: 0.14.3
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
@@ -0,0 +1,10 @@
1
+ scruby/__init__.py,sha256=GOVcjXmcOEDBbJQJDJlQq-x3M-VGJaMSN278EXsl2po,884
2
+ scruby/aggregation.py,sha256=x_9ZJQHJHDISxRvddS5A2Hb0saIcfPTh1Veyf2KgX8A,2919
3
+ scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
4
+ scruby/db.py,sha256=p-5sNZTMNRhNUnIksl4Ksjc7xMYwLRQ2CaS1vWR1e_g,21110
5
+ scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
6
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ scruby-0.14.3.dist-info/METADATA,sha256=7MypNDVzms8gqeDzxkoKiWjc7_K-M6jefuEACPZqOB4,10925
8
+ scruby-0.14.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ scruby-0.14.3.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
10
+ scruby-0.14.3.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- scruby/__init__.py,sha256=GOVcjXmcOEDBbJQJDJlQq-x3M-VGJaMSN278EXsl2po,884
2
- scruby/aggregation.py,sha256=fOsfMyCm28frKOFHmWzuGU81QPeJTJfs4EVIIroxOcQ,2909
3
- scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
4
- scruby/db.py,sha256=OXtMqq9y6RQkHHWOgFVXqI96v7g58SIoLUq-h09WxjI,20899
5
- scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
6
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- scruby-0.14.1.dist-info/METADATA,sha256=cnKZxapHkg2CRAFX_M1AgMiZ5oDNvW0nSjaTnlnryLw,10925
8
- scruby-0.14.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- scruby-0.14.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
10
- scruby-0.14.1.dist-info/RECORD,,