{ "info": { "author": "linkin", "author_email": "yooleak@outlook.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# [bloompy](https://pypi.org/project/bloompy/)\n\nAn implementation of 4 kinds of Bloom Filter in Python3.[Chinese Edition](https://github.com/01ly/bloompy/blob/master/zh-cn.md)\n> bloompy includes the standard BloomFilter,CountingBloomFilter,ScalableBloomFilter,ScalableCountingBloomFilter.\n> It's Update from **pybloom**.\n\n## Installation\n\n> pip install bloompy\n\n## Usage\n\nThere's 4 kinds of BloomFilter you can use by bloompy.\n* **standard bloom filter**\n\nthe standard one can only query or add elements in it. \n```python\n>>> import bloompy\n>>> bf = bloompy.BloomFilter(error_rate=0.001,element_num=10**3)\n\n# query the status of the element inside the bf immediately \n# and add it into the bf.False returned indicates the element\n# does not inside the filter.\n>>> bf.add(1) \nFalse\n>>> bf.add(1)\nTrue\n>>> 1 in bf\nTrue\n>>> bf.exists(1)\nTrue\n>>> bf.add([1,2,3])\nFalse\n>>> bf.add([1,2,3])\nTrue\n>>> [1,2,3] in bf\nTrue\n>>> bf.exists([1,2,3])\nTrue\n\n# store the bf into a file.\n>>> bf.tofile('filename.suffix')\n\n# recover a bf from a file.Auto recognize which kind of filters it is.\n>>> recovered_bf = bloompy.get_filter_fromfile('filename.suffix')\n\n# or you can use a classmethod 'fromfile' of the BloomFilter Class to get\n# a BloomFilter instance from a file.Same as other kind of filter Classes .\n>>> recovered_bf = bloompy.BloomFilter.fromfile('filename.suffix')\n\n# return the total number of the elements inside the bf.\n>>> bf.count\n2\n\n# the capacity of the current filter.\n>>> bf.capacity\n1000\n\n# the bits array of the current filter. \n>>> bf.bit_array\nbitarray('00....')\n\n# the total length of the bitarray.\n>>> bf.bit_num\n14400\n\n# the hash seeds inside the filter.\n# they are prime numbers by default.It's modifiable.\n>>> bf.seeds\n[2, 3, 5, 7, 11,...]\n\n# the amount of hash functions \n>>> bf.hash_num\n10\n\n```\n* **counting bloom filter**\n\nThe counting bloom filter is a subclass of the standard bloom filter.But it supports the **delete** operation.\nIt is set inside that 4bits represent a **bit** of the standard bf. So it costs more momery than the standard bf,\nit's 4 times the standard one.\n```python\n>>> import bloompy\n>>> cbf = bloompy.CountingBloomFilter(error_rate=0.001,element_num=10**3)\n\n# same as the standard bf at add operation.\n>>> cbf.add(12)\nFalse\n>>> cbf.add(12)\nTrue\n>>> 12 in cbf\nTrue\n>>> cbf.count\n1\n\n# query the status of the element inside the cbf immediately \n# if the element inside the cbf,delete it.\n>>> cbf.delete(12)\nTrue\n>>> cbf.delete(12)\nFalse\n>>> 12 in cbf\nFalse\n>>> cbf.count\n0\n\n# recover a cbf from a file.Same as the bf.\n>>> recovered_cbf = bloompy.CountingBloomFilter.fromfile('filename.suffix')\n```\nYou can do any operations of the BloomFilter on it as well. \n\n\n* **scalable bloom filter**\n\nAuto increase the capacity of the filter if the current amount of inserted elements is up to the limits.\nIt's set 2times the pre capacity inside by default.\n```python\n>>> import bloompy\n>>> sbf = bloompy.ScalableBloomFilter(error_rate=0.001,initial_capacity=10**3)\n\n# at first, the sbf is at 1000 capacity limits.\n>>> len(sbf)\n0\n>>> 12 in sbf\nFalse\n>>> sbf.add(12)\nFalse\n>>> 12 in sbf \nTrue\n>>> len(sbf)\n1\n>>> sbf.filters\n[]\n>>> sbf.capacity\n1000\n\n# when the amount of inserting elements surpass the limits 1000.\n# the sbf appends a new filter inside it which capacity 2times 1000.\n>>> for i in range(1000):\n sbf.add(i)\n>>> 600 in sbf\nTrue\n>>> len(sbf)\n2\n>>> sbf.filters\n[, ]\n>>> sbf.capacity\n3000\n\n# recover a sbf from a file.Same as bf.\n>>> recovered_sbf = bloompy.ScalableBloomFilter.fromfile('filename.suffix')\n```\nYou can do any operations of the BloomFilter on it as well. \n\n* **scalable counting bloom filter**\n\nIt's a subclass of the ScalableBloomFilter.But it supports the **delete** operation.\nYou can do any operations of the ScalableBloomFilter on it as well. \n```python\n>>> import bloompy\n>>> scbf = bloompy.SCBloomFilter(error_rate=0.001,initial_capacity=10**3)\n\n>>> scbf.add(1)\nFalse\n>>> 1 in scbf\nTrue\n>>> scbf.delete(1)\nTrue\n>>> 1 in scbf\nFalse\n>>> len(scbf)\n1\n>>> scbf.filters\n[]\n\n# add elements in sbf to make it at a capacity limits\n>>> for i in range(1100):\n scbf.add(i)\n>>> len(scbf)\n2\n>>> scbf.filters\n[, ]\n\n# recover a scbf from a file.Same as bf.\n>>> recovered_scbf = bloompy.SCBloomFilter.fromfile('filename.suffix')\n```\n## Store and recover\n\nAs shown in the standard bloom filter.You can store a filter in 2 ways:\n- classmethod 'fromfile'\n- get_filter_fromfile()\n\n> if you do clearly know that there is a BloomFilter stored in a file.\n> you can recover it with:\n> \n> ``` bloompy.BloomeFilter.fromfile('filename.suffix') ```\n> \n> or it's a CountingBloomFilter inside it:\n> \n> ```bloompy.CountingBloomFilter.fromfile('filename.suffix')```\n>\n> Same as others. \n> \n> But if you don't know what kind of filter it is stored in the file.Use:\n> \n> ```bloompy.get_filter_fromfile('filename.suffix') ```\n> \n> It will auto recognize the filter stored inside a file.Then you can do something with it.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/01ly/bloompy", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "bloompy", "package_url": "https://pypi.org/project/bloompy/", "platform": "", "project_url": "https://pypi.org/project/bloompy/", "project_urls": { "Homepage": "https://github.com/01ly/bloompy" }, "release_url": "https://pypi.org/project/bloompy/0.1.1/", "requires_dist": [ "bitarray (>=0.8.3)", "mmh3 (>=2.5.1)" ], "requires_python": "", "summary": "Implementation of Bloom Filter.", "version": "0.1.1" }, "last_serial": 4547422, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "63265fb12ad2742a962eda44373dd574", "sha256": "9aacda17de0856783a16570fc16ae13e7a8869fc56fe7eb8bab16537fb7921c3" }, "downloads": -1, "filename": "bloompy-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "63265fb12ad2742a962eda44373dd574", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7470, "upload_time": "2018-11-29T01:58:53", "url": "https://files.pythonhosted.org/packages/c0/ed/2d1587439c4e44104a4be3f1ab99777ad64f62e7c60c1dc0bf4462059649/bloompy-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "003ce95abdb964bead6039b5bad5ce41", "sha256": "942e2f3c160200011d051114305f34dc7b17be2897c9a24d3043fa7abec967bf" }, "downloads": -1, "filename": "bloompy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "003ce95abdb964bead6039b5bad5ce41", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6709, "upload_time": "2018-11-29T01:58:55", "url": "https://files.pythonhosted.org/packages/1e/dc/278cd9f1039c42f3d6d4c78171d496c7c3145b9a50008cbb282c0ecf2871/bloompy-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "51c61ca159999ab1cdadd81630044173", "sha256": "d8fa5eb94a7ce40adcc2b123aa046cde852af639527facd70645ed133462b761" }, "downloads": -1, "filename": "bloompy-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "51c61ca159999ab1cdadd81630044173", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7590, "upload_time": "2018-11-30T14:46:03", "url": "https://files.pythonhosted.org/packages/1e/4e/b911d74d2f6e60efe846792e37fd2e8a2b893c901dd368735cf064cd3ae3/bloompy-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "33aa88910fd4aa14f26fc0e0d5e297bf", "sha256": "36a2941981bf5bee998834b2ad5796130c008a210426ae6e7b99e43e7a04a312" }, "downloads": -1, "filename": "bloompy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "33aa88910fd4aa14f26fc0e0d5e297bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6841, "upload_time": "2018-11-30T14:46:05", "url": "https://files.pythonhosted.org/packages/c5/7a/5511d84309b2799d9d61434a00093b6786453549f2ee6e0f8ec9445c7c61/bloompy-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "51c61ca159999ab1cdadd81630044173", "sha256": "d8fa5eb94a7ce40adcc2b123aa046cde852af639527facd70645ed133462b761" }, "downloads": -1, "filename": "bloompy-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "51c61ca159999ab1cdadd81630044173", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7590, "upload_time": "2018-11-30T14:46:03", "url": "https://files.pythonhosted.org/packages/1e/4e/b911d74d2f6e60efe846792e37fd2e8a2b893c901dd368735cf064cd3ae3/bloompy-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "33aa88910fd4aa14f26fc0e0d5e297bf", "sha256": "36a2941981bf5bee998834b2ad5796130c008a210426ae6e7b99e43e7a04a312" }, "downloads": -1, "filename": "bloompy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "33aa88910fd4aa14f26fc0e0d5e297bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6841, "upload_time": "2018-11-30T14:46:05", "url": "https://files.pythonhosted.org/packages/c5/7a/5511d84309b2799d9d61434a00093b6786453549f2ee6e0f8ec9445c7c61/bloompy-0.1.1.tar.gz" } ] }