scruby 0.10.1__py3-none-any.whl → 0.10.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/db.py CHANGED
@@ -394,3 +394,30 @@ class Scruby[T]:
394
394
  """Get an estimate of the number of documents in this collection using collection metadata."""
395
395
  meta = await self._get_meta()
396
396
  return meta.counter_documents
397
+
398
+ def count_documents(
399
+ self,
400
+ filter_fn: Callable,
401
+ max_workers: int | None = None,
402
+ timeout: float | None = None,
403
+ ) -> int:
404
+ """Count the number of documents a matching the filter in this collection."""
405
+ keys: range = range(1, self.__max_num_keys)
406
+ search_task_fn: Callable = self._search_task
407
+ length_reduction_hash: int = self.__length_reduction_hash
408
+ db_root: str = self.__db_root
409
+ class_model: T = self.__class_model
410
+ counter: int = 0
411
+ with concurrent.futures.ThreadPoolExecutor(max_workers) as executor:
412
+ for key in keys:
413
+ future = executor.submit(
414
+ search_task_fn,
415
+ key,
416
+ filter_fn,
417
+ length_reduction_hash,
418
+ db_root,
419
+ class_model,
420
+ )
421
+ if future.result(timeout) is not None:
422
+ counter += 1
423
+ return counter
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.10.1
3
+ Version: 0.10.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
@@ -0,0 +1,8 @@
1
+ scruby/__init__.py,sha256=wFwUS1KcLxfIopXOVS8gPue9fNzIIU2cVj_RgK5drz4,849
2
+ scruby/constants.py,sha256=GbB-O0qaVdi5EHUp-zRAppFXLR-oHxpXUFVAOCpS0C8,1022
3
+ scruby/db.py,sha256=LwSmkgFfxHLIKIJ6skE4FZ-Ad2GAItKbXYiMPBS8f18,15189
4
+ scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ scruby-0.10.2.dist-info/METADATA,sha256=cJT0AGNe98yqY0CChu-lUmxLy03jy99U_11YdHndrvk,10829
6
+ scruby-0.10.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ scruby-0.10.2.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
+ scruby-0.10.2.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- scruby/__init__.py,sha256=wFwUS1KcLxfIopXOVS8gPue9fNzIIU2cVj_RgK5drz4,849
2
- scruby/constants.py,sha256=GbB-O0qaVdi5EHUp-zRAppFXLR-oHxpXUFVAOCpS0C8,1022
3
- scruby/db.py,sha256=d4fVb4JhGaBU_YPxByT156UGHQPTwzSizBqOpCNhW8Y,14159
4
- scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- scruby-0.10.1.dist-info/METADATA,sha256=k2AaJn-JijNceNIB7s13D1cB3jr4p4mW6R1z7IuXp4g,10829
6
- scruby-0.10.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- scruby-0.10.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
8
- scruby-0.10.1.dist-info/RECORD,,