BloomFilter-py 0.0.6__tar.gz → 0.2.0__tar.gz
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.
- bloomfilter-py-0.2.0/LICENSE +21 -0
- bloomfilter-py-0.2.0/PKG-INFO +119 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/README.md +35 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/bloomfilter/bloomfilter.py +37 -4
- bloomfilter-py-0.2.0/bloomfilter_py.egg-info/PKG-INFO +119 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/bloomfilter_py.egg-info/SOURCES.txt +1 -0
- bloomfilter-py-0.2.0/bloomfilter_py.egg-info/requires.txt +2 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/setup.py +6 -4
- bloomfilter-py-0.0.6/PKG-INFO +0 -82
- bloomfilter-py-0.0.6/bloomfilter_py.egg-info/PKG-INFO +0 -82
- bloomfilter-py-0.0.6/bloomfilter_py.egg-info/requires.txt +0 -2
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/bloomfilter/__init__.py +0 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/bloomfilter/bloomfilter_strategy.py +0 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/bloomfilter_py.egg-info/dependency_links.txt +0 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/bloomfilter_py.egg-info/not-zip-safe +0 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/bloomfilter_py.egg-info/top_level.txt +0 -0
- {bloomfilter-py-0.0.6 → bloomfilter-py-0.2.0}/setup.cfg +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 OldPanda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: bloomfilter-py
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Yet another bloomfilter implementation in Python
|
|
5
|
+
Home-page: https://github.com/OldPanda/bloomfilter-py
|
|
6
|
+
Author: OldPanda
|
|
7
|
+
Author-email: me@old-panda.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.7
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
|
|
25
|
+
# bloomfilter-py
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
[](https://codecov.io/gh/OldPanda/bloomfilter-py)
|
|
29
|
+
[](https://pepy.tech/project/bloomfilter-py)
|
|
30
|
+
|
|
31
|
+
## Overview
|
|
32
|
+
Yet another Bloomfilter implementation in Python, compatible with Java's Guava library.
|
|
33
|
+
|
|
34
|
+
I was looking for a Python library which is capable of reading what Bloomfilter of Java's Guava library serializes and is also able to output byte array which is recognizable by Java. But unfortunately failed. Hence I developed this library by borrowing how Guava implements Bloomfilter serialization/deserialization a lot to deal with Bloomfilters on both Python and Java sides.
|
|
35
|
+
|
|
36
|
+
As for Bloomfilter usage in Java world, please refer to [this post](https://www.baeldung.com/guava-bloom-filter).
|
|
37
|
+
|
|
38
|
+
Here's a brief [introduction](https://en.wikipedia.org/wiki/Bloom_filter) to Bloomfilter.
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
* Python 3.7+
|
|
42
|
+
|
|
43
|
+
This library is not tested under Python 3.6 and lower versions.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
```
|
|
47
|
+
pip install bloomfilter-py
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage Examples
|
|
51
|
+
|
|
52
|
+
### Basic Usage
|
|
53
|
+
```Python
|
|
54
|
+
>>> from bloomfilter import BloomFilter
|
|
55
|
+
>>> bloom_filter = BloomFilter(expected_insertions=500, err_rate=0.01)
|
|
56
|
+
>>> for i in range(100):
|
|
57
|
+
... bloom_filter.put(i)
|
|
58
|
+
...
|
|
59
|
+
>>> 1 in bloom_filter
|
|
60
|
+
True
|
|
61
|
+
>>> 100 in bloom_filter
|
|
62
|
+
False
|
|
63
|
+
>>>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Serialize Bloomfilter
|
|
67
|
+
You can easily serialize `BloomFilter` instance to a byte array
|
|
68
|
+
```Python
|
|
69
|
+
>>> dumps = bloom_filter.dumps()
|
|
70
|
+
>>> with open("dumps.out", "wb") as f:
|
|
71
|
+
... f.write(dumps)
|
|
72
|
+
...
|
|
73
|
+
>>>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
or to a hex string
|
|
77
|
+
```Python
|
|
78
|
+
>>> hex_str = bloom_filter.dumps_to_hex()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
or to a base64 encoded bytes
|
|
82
|
+
```Python
|
|
83
|
+
base64_bytes = bloom_filter.dumps_to_base64()
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Deserialize Bloomfilter
|
|
87
|
+
And you can easily initialize a `BloomFilter` instance from a byte array
|
|
88
|
+
```Python
|
|
89
|
+
>>> with open("dumps.out", "rb") as f:
|
|
90
|
+
... bf = BloomFilter.loads(f.read())
|
|
91
|
+
...
|
|
92
|
+
>>> 1 in bf
|
|
93
|
+
True
|
|
94
|
+
>>> 100 in bf
|
|
95
|
+
False
|
|
96
|
+
>>>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
or from a hex string
|
|
100
|
+
```Python
|
|
101
|
+
>>> bf = BloomFilter.loads_from_hex(hex_str)
|
|
102
|
+
>>> 1 in bf
|
|
103
|
+
True
|
|
104
|
+
>>> 100 in bf
|
|
105
|
+
False
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
or from a base64 encoded bytes
|
|
109
|
+
```Python
|
|
110
|
+
>>> bf = BloomFilter.loads_from_base64(base64_bytes)
|
|
111
|
+
>>> 100 in bf
|
|
112
|
+
False
|
|
113
|
+
>>> 200 in bf
|
|
114
|
+
False
|
|
115
|
+
>>> 1 in bf
|
|
116
|
+
True
|
|
117
|
+
>>> 99 in bf
|
|
118
|
+
True
|
|
119
|
+
```
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|

|
|
3
3
|

|
|
4
4
|
[](https://codecov.io/gh/OldPanda/bloomfilter-py)
|
|
5
|
+
[](https://pepy.tech/project/bloomfilter-py)
|
|
5
6
|
|
|
6
7
|
## Overview
|
|
7
8
|
Yet another Bloomfilter implementation in Python, compatible with Java's Guava library.
|
|
@@ -39,6 +40,7 @@ False
|
|
|
39
40
|
```
|
|
40
41
|
|
|
41
42
|
### Serialize Bloomfilter
|
|
43
|
+
You can easily serialize `BloomFilter` instance to a byte array
|
|
42
44
|
```Python
|
|
43
45
|
>>> dumps = bloom_filter.dumps()
|
|
44
46
|
>>> with open("dumps.out", "wb") as f:
|
|
@@ -47,7 +49,18 @@ False
|
|
|
47
49
|
>>>
|
|
48
50
|
```
|
|
49
51
|
|
|
52
|
+
or to a hex string
|
|
53
|
+
```Python
|
|
54
|
+
>>> hex_str = bloom_filter.dumps_to_hex()
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
or to a base64 encoded bytes
|
|
58
|
+
```Python
|
|
59
|
+
base64_bytes = bloom_filter.dumps_to_base64()
|
|
60
|
+
```
|
|
61
|
+
|
|
50
62
|
### Deserialize Bloomfilter
|
|
63
|
+
And you can easily initialize a `BloomFilter` instance from a byte array
|
|
51
64
|
```Python
|
|
52
65
|
>>> with open("dumps.out", "rb") as f:
|
|
53
66
|
... bf = BloomFilter.loads(f.read())
|
|
@@ -58,3 +71,25 @@ True
|
|
|
58
71
|
False
|
|
59
72
|
>>>
|
|
60
73
|
```
|
|
74
|
+
|
|
75
|
+
or from a hex string
|
|
76
|
+
```Python
|
|
77
|
+
>>> bf = BloomFilter.loads_from_hex(hex_str)
|
|
78
|
+
>>> 1 in bf
|
|
79
|
+
True
|
|
80
|
+
>>> 100 in bf
|
|
81
|
+
False
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
or from a base64 encoded bytes
|
|
85
|
+
```Python
|
|
86
|
+
>>> bf = BloomFilter.loads_from_base64(base64_bytes)
|
|
87
|
+
>>> 100 in bf
|
|
88
|
+
False
|
|
89
|
+
>>> 200 in bf
|
|
90
|
+
False
|
|
91
|
+
>>> 1 in bf
|
|
92
|
+
True
|
|
93
|
+
>>> 99 in bf
|
|
94
|
+
True
|
|
95
|
+
```
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import base64
|
|
1
2
|
import math
|
|
2
3
|
|
|
3
4
|
from bitarray import bitarray
|
|
@@ -42,11 +43,11 @@ class BloomFilter(object):
|
|
|
42
43
|
self.strategy = strategy
|
|
43
44
|
|
|
44
45
|
@classmethod
|
|
45
|
-
def loads(cls, array):
|
|
46
|
+
def loads(cls, array: bytes) -> "BloomFilter":
|
|
46
47
|
"""
|
|
47
48
|
Initialize Bloomfilter instance given dump bytes.
|
|
48
49
|
|
|
49
|
-
:param array:
|
|
50
|
+
:param array: BloomFilter dumped bytes.
|
|
50
51
|
:type array: bytes
|
|
51
52
|
"""
|
|
52
53
|
strategy_ordinal = array[0]
|
|
@@ -65,9 +66,29 @@ class BloomFilter(object):
|
|
|
65
66
|
instance.setup(num_hash_functions, data, strategy)
|
|
66
67
|
return instance
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
@classmethod
|
|
70
|
+
def loads_from_hex(cls, hex_str: str) -> "BloomFilter":
|
|
71
|
+
"""
|
|
72
|
+
Initialize Bloomfilter instance from hex string.
|
|
73
|
+
|
|
74
|
+
:param hex_str: BloomFilter dumped hex string.
|
|
75
|
+
:type hex_str: str
|
|
76
|
+
"""
|
|
77
|
+
return cls.loads(bytes.fromhex(hex_str))
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def loads_from_base64(cls, base64_encoded_bytes: bytes) -> "BloomFilter":
|
|
81
|
+
"""
|
|
82
|
+
Initialize Bloomfilter instance from base64 encoded bytes.
|
|
83
|
+
|
|
84
|
+
:param base64_encoded_bytes: BloomFilter dumped bytes encoded in base64.
|
|
85
|
+
:type base64_encoded_bytes: bytes
|
|
69
86
|
"""
|
|
70
|
-
|
|
87
|
+
return cls.loads(base64.b64decode(base64_encoded_bytes))
|
|
88
|
+
|
|
89
|
+
def dumps(self) -> bytes:
|
|
90
|
+
"""
|
|
91
|
+
Serialize BloomFilter instance to bytes.
|
|
71
92
|
"""
|
|
72
93
|
result = bytes()
|
|
73
94
|
result += self.strategy.ordinal().to_bytes(1, byteorder="little")
|
|
@@ -77,6 +98,18 @@ class BloomFilter(object):
|
|
|
77
98
|
result += self.data[i : i + 64][::-1]
|
|
78
99
|
return result
|
|
79
100
|
|
|
101
|
+
def dumps_to_hex(self) -> str:
|
|
102
|
+
"""
|
|
103
|
+
Serialize BloomFilter instance to hex string.
|
|
104
|
+
"""
|
|
105
|
+
return self.dumps().hex()
|
|
106
|
+
|
|
107
|
+
def dumps_to_base64(self) -> bytes:
|
|
108
|
+
"""
|
|
109
|
+
Serialize BloomFilter instance to base64 encoded bytes.
|
|
110
|
+
"""
|
|
111
|
+
return base64.b64encode(self.dumps())
|
|
112
|
+
|
|
80
113
|
@classmethod
|
|
81
114
|
def num_of_bits(cls, expected_insertions, err_rate):
|
|
82
115
|
"""
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: bloomfilter-py
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Yet another bloomfilter implementation in Python
|
|
5
|
+
Home-page: https://github.com/OldPanda/bloomfilter-py
|
|
6
|
+
Author: OldPanda
|
|
7
|
+
Author-email: me@old-panda.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.7
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
|
|
25
|
+
# bloomfilter-py
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
[](https://codecov.io/gh/OldPanda/bloomfilter-py)
|
|
29
|
+
[](https://pepy.tech/project/bloomfilter-py)
|
|
30
|
+
|
|
31
|
+
## Overview
|
|
32
|
+
Yet another Bloomfilter implementation in Python, compatible with Java's Guava library.
|
|
33
|
+
|
|
34
|
+
I was looking for a Python library which is capable of reading what Bloomfilter of Java's Guava library serializes and is also able to output byte array which is recognizable by Java. But unfortunately failed. Hence I developed this library by borrowing how Guava implements Bloomfilter serialization/deserialization a lot to deal with Bloomfilters on both Python and Java sides.
|
|
35
|
+
|
|
36
|
+
As for Bloomfilter usage in Java world, please refer to [this post](https://www.baeldung.com/guava-bloom-filter).
|
|
37
|
+
|
|
38
|
+
Here's a brief [introduction](https://en.wikipedia.org/wiki/Bloom_filter) to Bloomfilter.
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
* Python 3.7+
|
|
42
|
+
|
|
43
|
+
This library is not tested under Python 3.6 and lower versions.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
```
|
|
47
|
+
pip install bloomfilter-py
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage Examples
|
|
51
|
+
|
|
52
|
+
### Basic Usage
|
|
53
|
+
```Python
|
|
54
|
+
>>> from bloomfilter import BloomFilter
|
|
55
|
+
>>> bloom_filter = BloomFilter(expected_insertions=500, err_rate=0.01)
|
|
56
|
+
>>> for i in range(100):
|
|
57
|
+
... bloom_filter.put(i)
|
|
58
|
+
...
|
|
59
|
+
>>> 1 in bloom_filter
|
|
60
|
+
True
|
|
61
|
+
>>> 100 in bloom_filter
|
|
62
|
+
False
|
|
63
|
+
>>>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Serialize Bloomfilter
|
|
67
|
+
You can easily serialize `BloomFilter` instance to a byte array
|
|
68
|
+
```Python
|
|
69
|
+
>>> dumps = bloom_filter.dumps()
|
|
70
|
+
>>> with open("dumps.out", "wb") as f:
|
|
71
|
+
... f.write(dumps)
|
|
72
|
+
...
|
|
73
|
+
>>>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
or to a hex string
|
|
77
|
+
```Python
|
|
78
|
+
>>> hex_str = bloom_filter.dumps_to_hex()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
or to a base64 encoded bytes
|
|
82
|
+
```Python
|
|
83
|
+
base64_bytes = bloom_filter.dumps_to_base64()
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Deserialize Bloomfilter
|
|
87
|
+
And you can easily initialize a `BloomFilter` instance from a byte array
|
|
88
|
+
```Python
|
|
89
|
+
>>> with open("dumps.out", "rb") as f:
|
|
90
|
+
... bf = BloomFilter.loads(f.read())
|
|
91
|
+
...
|
|
92
|
+
>>> 1 in bf
|
|
93
|
+
True
|
|
94
|
+
>>> 100 in bf
|
|
95
|
+
False
|
|
96
|
+
>>>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
or from a hex string
|
|
100
|
+
```Python
|
|
101
|
+
>>> bf = BloomFilter.loads_from_hex(hex_str)
|
|
102
|
+
>>> 1 in bf
|
|
103
|
+
True
|
|
104
|
+
>>> 100 in bf
|
|
105
|
+
False
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
or from a base64 encoded bytes
|
|
109
|
+
```Python
|
|
110
|
+
>>> bf = BloomFilter.loads_from_base64(base64_bytes)
|
|
111
|
+
>>> 100 in bf
|
|
112
|
+
False
|
|
113
|
+
>>> 200 in bf
|
|
114
|
+
False
|
|
115
|
+
>>> 1 in bf
|
|
116
|
+
True
|
|
117
|
+
>>> 99 in bf
|
|
118
|
+
True
|
|
119
|
+
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from setuptools import
|
|
1
|
+
from setuptools import find_packages, setup
|
|
2
2
|
|
|
3
|
-
version = "0.0
|
|
4
|
-
install_requires = ["bitarray==
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
install_requires = ["bitarray==2.6.0", "mmh3==3.0.0"]
|
|
5
5
|
extras_require = {}
|
|
6
6
|
|
|
7
7
|
setup(
|
|
@@ -18,7 +18,7 @@ setup(
|
|
|
18
18
|
include_package_data=True,
|
|
19
19
|
zip_safe=False,
|
|
20
20
|
classifiers=[
|
|
21
|
-
"Development Status ::
|
|
21
|
+
"Development Status :: 5 - Production/Stable",
|
|
22
22
|
"Intended Audience :: Developers",
|
|
23
23
|
"License :: OSI Approved :: MIT License",
|
|
24
24
|
"Programming Language :: Python",
|
|
@@ -26,6 +26,8 @@ setup(
|
|
|
26
26
|
"Programming Language :: Python :: 3.7",
|
|
27
27
|
"Programming Language :: Python :: 3.8",
|
|
28
28
|
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
29
31
|
"Operating System :: OS Independent",
|
|
30
32
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
31
33
|
],
|
bloomfilter-py-0.0.6/PKG-INFO
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: bloomfilter-py
|
|
3
|
-
Version: 0.0.6
|
|
4
|
-
Summary: Yet another bloomfilter implementation in Python
|
|
5
|
-
Home-page: https://github.com/OldPanda/bloomfilter-py
|
|
6
|
-
Author: OldPanda
|
|
7
|
-
Author-email: me@old-panda.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # bloomfilter-py
|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
[](https://codecov.io/gh/OldPanda/bloomfilter-py)
|
|
13
|
-
|
|
14
|
-
## Overview
|
|
15
|
-
Yet another Bloomfilter implementation in Python, compatible with Java's Guava library.
|
|
16
|
-
|
|
17
|
-
I was looking for a Python library which is capable of reading what Bloomfilter of Java's Guava library serializes and is also able to output byte array which is recognizable by Java. But unfortunately failed. Hence I developed this library by borrowing how Guava implements Bloomfilter serialization/deserialization a lot to deal with Bloomfilters on both Python and Java sides.
|
|
18
|
-
|
|
19
|
-
As for Bloomfilter usage in Java world, please refer to [this post](https://www.baeldung.com/guava-bloom-filter).
|
|
20
|
-
|
|
21
|
-
Here's a brief [introduction](https://en.wikipedia.org/wiki/Bloom_filter) to Bloomfilter.
|
|
22
|
-
|
|
23
|
-
## Requirements
|
|
24
|
-
* Python 3.7+
|
|
25
|
-
|
|
26
|
-
This library is not tested under Python 3.6 and lower versions.
|
|
27
|
-
|
|
28
|
-
## Install
|
|
29
|
-
```
|
|
30
|
-
pip install bloomfilter-py
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Usage Examples
|
|
34
|
-
|
|
35
|
-
### Basic Usage
|
|
36
|
-
```Python
|
|
37
|
-
>>> from bloomfilter import BloomFilter
|
|
38
|
-
>>> bloom_filter = BloomFilter(expected_insertions=500, err_rate=0.01)
|
|
39
|
-
>>> for i in range(100):
|
|
40
|
-
... bloom_filter.put(i)
|
|
41
|
-
...
|
|
42
|
-
>>> 1 in bloom_filter
|
|
43
|
-
True
|
|
44
|
-
>>> 100 in bloom_filter
|
|
45
|
-
False
|
|
46
|
-
>>>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Serialize Bloomfilter
|
|
50
|
-
```Python
|
|
51
|
-
>>> dumps = bloom_filter.dumps()
|
|
52
|
-
>>> with open("dumps.out", "wb") as f:
|
|
53
|
-
... f.write(dumps)
|
|
54
|
-
...
|
|
55
|
-
>>>
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Deserialize Bloomfilter
|
|
59
|
-
```Python
|
|
60
|
-
>>> with open("dumps.out", "rb") as f:
|
|
61
|
-
... bf = BloomFilter.loads(f.read())
|
|
62
|
-
...
|
|
63
|
-
>>> 1 in bf
|
|
64
|
-
True
|
|
65
|
-
>>> 100 in bf
|
|
66
|
-
False
|
|
67
|
-
>>>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Platform: UNKNOWN
|
|
71
|
-
Classifier: Development Status :: 4 - Beta
|
|
72
|
-
Classifier: Intended Audience :: Developers
|
|
73
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
74
|
-
Classifier: Programming Language :: Python
|
|
75
|
-
Classifier: Programming Language :: Python :: 3
|
|
76
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
77
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
78
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
79
|
-
Classifier: Operating System :: OS Independent
|
|
80
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
81
|
-
Requires-Python: >=3.7
|
|
82
|
-
Description-Content-Type: text/markdown
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: bloomfilter-py
|
|
3
|
-
Version: 0.0.6
|
|
4
|
-
Summary: Yet another bloomfilter implementation in Python
|
|
5
|
-
Home-page: https://github.com/OldPanda/bloomfilter-py
|
|
6
|
-
Author: OldPanda
|
|
7
|
-
Author-email: me@old-panda.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Description: # bloomfilter-py
|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
[](https://codecov.io/gh/OldPanda/bloomfilter-py)
|
|
13
|
-
|
|
14
|
-
## Overview
|
|
15
|
-
Yet another Bloomfilter implementation in Python, compatible with Java's Guava library.
|
|
16
|
-
|
|
17
|
-
I was looking for a Python library which is capable of reading what Bloomfilter of Java's Guava library serializes and is also able to output byte array which is recognizable by Java. But unfortunately failed. Hence I developed this library by borrowing how Guava implements Bloomfilter serialization/deserialization a lot to deal with Bloomfilters on both Python and Java sides.
|
|
18
|
-
|
|
19
|
-
As for Bloomfilter usage in Java world, please refer to [this post](https://www.baeldung.com/guava-bloom-filter).
|
|
20
|
-
|
|
21
|
-
Here's a brief [introduction](https://en.wikipedia.org/wiki/Bloom_filter) to Bloomfilter.
|
|
22
|
-
|
|
23
|
-
## Requirements
|
|
24
|
-
* Python 3.7+
|
|
25
|
-
|
|
26
|
-
This library is not tested under Python 3.6 and lower versions.
|
|
27
|
-
|
|
28
|
-
## Install
|
|
29
|
-
```
|
|
30
|
-
pip install bloomfilter-py
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Usage Examples
|
|
34
|
-
|
|
35
|
-
### Basic Usage
|
|
36
|
-
```Python
|
|
37
|
-
>>> from bloomfilter import BloomFilter
|
|
38
|
-
>>> bloom_filter = BloomFilter(expected_insertions=500, err_rate=0.01)
|
|
39
|
-
>>> for i in range(100):
|
|
40
|
-
... bloom_filter.put(i)
|
|
41
|
-
...
|
|
42
|
-
>>> 1 in bloom_filter
|
|
43
|
-
True
|
|
44
|
-
>>> 100 in bloom_filter
|
|
45
|
-
False
|
|
46
|
-
>>>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Serialize Bloomfilter
|
|
50
|
-
```Python
|
|
51
|
-
>>> dumps = bloom_filter.dumps()
|
|
52
|
-
>>> with open("dumps.out", "wb") as f:
|
|
53
|
-
... f.write(dumps)
|
|
54
|
-
...
|
|
55
|
-
>>>
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Deserialize Bloomfilter
|
|
59
|
-
```Python
|
|
60
|
-
>>> with open("dumps.out", "rb") as f:
|
|
61
|
-
... bf = BloomFilter.loads(f.read())
|
|
62
|
-
...
|
|
63
|
-
>>> 1 in bf
|
|
64
|
-
True
|
|
65
|
-
>>> 100 in bf
|
|
66
|
-
False
|
|
67
|
-
>>>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Platform: UNKNOWN
|
|
71
|
-
Classifier: Development Status :: 4 - Beta
|
|
72
|
-
Classifier: Intended Audience :: Developers
|
|
73
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
74
|
-
Classifier: Programming Language :: Python
|
|
75
|
-
Classifier: Programming Language :: Python :: 3
|
|
76
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
77
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
78
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
79
|
-
Classifier: Operating System :: OS Independent
|
|
80
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
81
|
-
Requires-Python: >=3.7
|
|
82
|
-
Description-Content-Type: text/markdown
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|