summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-ibloom.spec472
-rw-r--r--sources1
3 files changed, 474 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..5e8102f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/ibloom-0.0.2.1.tar.gz
diff --git a/python-ibloom.spec b/python-ibloom.spec
new file mode 100644
index 0000000..71b4e77
--- /dev/null
+++ b/python-ibloom.spec
@@ -0,0 +1,472 @@
+%global _empty_manifest_terminate_build 0
+Name: python-ibloom
+Version: 0.0.2.1
+Release: 1
+Summary: Python library which implements a Redis-backed Bloom filter.
+License: MIT
+URL: https://github.com/coghost/ibloom
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e0/a6/ddfe35b03a142e89f434018b2994d9f8a6d77d685131071b531acc4d0531/ibloom-0.0.2.1.tar.gz
+BuildArch: noarch
+
+Requires: python3-Cython
+
+%description
+## ibloom
+
+
+this is a fork of [pyreBloom-ng](https://github.com/leovp/pyreBloom-ng), pyreBloom-ng is a python library which implements a Redis-backed Bloom filter.
+
+pyreBloom-ng is really powerful. but it's setup.py and tests and bench/benchmark.py are all outdated, the repo's last commit is 4 years ago.
+
+based on pyreBloom-ng and added supported for python3's str, avoid of annoying *`b'some_key'`*
+
+## Installation
+
+### pre-requirement
+`ibloom` requires `hiredis` library, `Cython` and `a C compiler`
+
+
+> hiredis
+
+```sh
+# Mac
+brew install hiredis
+
+# ubuntu
+apt-get install libhiredis-dev
+
+# From source:
+git clone https://github.com/redis/hiredis
+cd hiredis && make && sudo make install
+```
+
+> Cython
+
+```sh
+pip install Cython
+```
+
+## Startup
+
+### init an instance
+
+```python
+from ibloom import IBloom
+ib = IBloom('ibloomI', 1000, 0.01, '127.0.0.1', 6383)
+```
+or
+```python
+from ibloom import IBloom
+ib_n = IBloom(key='ibloomN', capacity=1000, error=0.01, host='127.0.0.1', port=6383)
+```
+
+### check basic info
+
+```python
+# You can find out how many bits this will theoretically consume
+>>> ib.bits
+9585
+# And how many hashes are needed to satisfy the false positive rate
+>>> ib.hashes
+7
+# find all available bloom filter keys
+>>> ib.keys()
+['ibloomI.0']
+```
+
+### add data
+
+#### add all supplied
+
+```python
+# Add one value at a time (slow)
+>>> ib.add('first')
+True
+# Or use batch operations (faster).
+>>> ib.update([f'{x}' for x in range(5)])
+5
+# Alternative: ib += data, but this will return nothing
+>>> ib += [f'{x + 5}' for x in range(5)]
+```
+
+#### only add if not exist
+
+```python
+# will first get the difference, and then update them to redis, and return them
+>>> ib.update_difference(['5', '6', '7', '8', '9', '10'])
+['10']
+```
+
+### check if key exists
+
+#### find one
+
+```python
+# Test one value at a time (slow).
+# . in ...
+>>> 'first' in ib
+True
+# ...contains(.)
+>>> ib.contains('first')
+True
+```
+
+#### find multiple
+
+```python
+# Use batch operations (faster).
+# Note: ibloom.intersection() returns a list of values
+# which are found in a Bloom filter. It makes sense when
+# you consider it a set-like operation.
+>>> ib.intersection(['3', '4', '5', '6'])
+['3', '4', '5', '6']
+# Alternative: ib & [b'3', b'4', b'5', b'6']
+>>> ib & ['3', '4', '5', '6', '9', '10']
+['3', '4', '5', '6', '9']
+```
+
+#### find non exist
+
+```python
+>>> ib.difference(['5', '6', '7', '8', '9', '10'])
+['10']
+# not recommended, maybe update in the future
+# Alternative: ib ^ ['5', '6', '7', '8', '9', '10']
+>>> ib ^ ['5', '6', '7', '8', '9', '10']
+['10']
+```
+
+### delete the bloom key
+
+```python
+# delete self
+ib.delete()
+```
+
+
+
+
+%package -n python3-ibloom
+Summary: Python library which implements a Redis-backed Bloom filter.
+Provides: python-ibloom
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-ibloom
+## ibloom
+
+
+this is a fork of [pyreBloom-ng](https://github.com/leovp/pyreBloom-ng), pyreBloom-ng is a python library which implements a Redis-backed Bloom filter.
+
+pyreBloom-ng is really powerful. but it's setup.py and tests and bench/benchmark.py are all outdated, the repo's last commit is 4 years ago.
+
+based on pyreBloom-ng and added supported for python3's str, avoid of annoying *`b'some_key'`*
+
+## Installation
+
+### pre-requirement
+`ibloom` requires `hiredis` library, `Cython` and `a C compiler`
+
+
+> hiredis
+
+```sh
+# Mac
+brew install hiredis
+
+# ubuntu
+apt-get install libhiredis-dev
+
+# From source:
+git clone https://github.com/redis/hiredis
+cd hiredis && make && sudo make install
+```
+
+> Cython
+
+```sh
+pip install Cython
+```
+
+## Startup
+
+### init an instance
+
+```python
+from ibloom import IBloom
+ib = IBloom('ibloomI', 1000, 0.01, '127.0.0.1', 6383)
+```
+or
+```python
+from ibloom import IBloom
+ib_n = IBloom(key='ibloomN', capacity=1000, error=0.01, host='127.0.0.1', port=6383)
+```
+
+### check basic info
+
+```python
+# You can find out how many bits this will theoretically consume
+>>> ib.bits
+9585
+# And how many hashes are needed to satisfy the false positive rate
+>>> ib.hashes
+7
+# find all available bloom filter keys
+>>> ib.keys()
+['ibloomI.0']
+```
+
+### add data
+
+#### add all supplied
+
+```python
+# Add one value at a time (slow)
+>>> ib.add('first')
+True
+# Or use batch operations (faster).
+>>> ib.update([f'{x}' for x in range(5)])
+5
+# Alternative: ib += data, but this will return nothing
+>>> ib += [f'{x + 5}' for x in range(5)]
+```
+
+#### only add if not exist
+
+```python
+# will first get the difference, and then update them to redis, and return them
+>>> ib.update_difference(['5', '6', '7', '8', '9', '10'])
+['10']
+```
+
+### check if key exists
+
+#### find one
+
+```python
+# Test one value at a time (slow).
+# . in ...
+>>> 'first' in ib
+True
+# ...contains(.)
+>>> ib.contains('first')
+True
+```
+
+#### find multiple
+
+```python
+# Use batch operations (faster).
+# Note: ibloom.intersection() returns a list of values
+# which are found in a Bloom filter. It makes sense when
+# you consider it a set-like operation.
+>>> ib.intersection(['3', '4', '5', '6'])
+['3', '4', '5', '6']
+# Alternative: ib & [b'3', b'4', b'5', b'6']
+>>> ib & ['3', '4', '5', '6', '9', '10']
+['3', '4', '5', '6', '9']
+```
+
+#### find non exist
+
+```python
+>>> ib.difference(['5', '6', '7', '8', '9', '10'])
+['10']
+# not recommended, maybe update in the future
+# Alternative: ib ^ ['5', '6', '7', '8', '9', '10']
+>>> ib ^ ['5', '6', '7', '8', '9', '10']
+['10']
+```
+
+### delete the bloom key
+
+```python
+# delete self
+ib.delete()
+```
+
+
+
+
+%package help
+Summary: Development documents and examples for ibloom
+Provides: python3-ibloom-doc
+%description help
+## ibloom
+
+
+this is a fork of [pyreBloom-ng](https://github.com/leovp/pyreBloom-ng), pyreBloom-ng is a python library which implements a Redis-backed Bloom filter.
+
+pyreBloom-ng is really powerful. but it's setup.py and tests and bench/benchmark.py are all outdated, the repo's last commit is 4 years ago.
+
+based on pyreBloom-ng and added supported for python3's str, avoid of annoying *`b'some_key'`*
+
+## Installation
+
+### pre-requirement
+`ibloom` requires `hiredis` library, `Cython` and `a C compiler`
+
+
+> hiredis
+
+```sh
+# Mac
+brew install hiredis
+
+# ubuntu
+apt-get install libhiredis-dev
+
+# From source:
+git clone https://github.com/redis/hiredis
+cd hiredis && make && sudo make install
+```
+
+> Cython
+
+```sh
+pip install Cython
+```
+
+## Startup
+
+### init an instance
+
+```python
+from ibloom import IBloom
+ib = IBloom('ibloomI', 1000, 0.01, '127.0.0.1', 6383)
+```
+or
+```python
+from ibloom import IBloom
+ib_n = IBloom(key='ibloomN', capacity=1000, error=0.01, host='127.0.0.1', port=6383)
+```
+
+### check basic info
+
+```python
+# You can find out how many bits this will theoretically consume
+>>> ib.bits
+9585
+# And how many hashes are needed to satisfy the false positive rate
+>>> ib.hashes
+7
+# find all available bloom filter keys
+>>> ib.keys()
+['ibloomI.0']
+```
+
+### add data
+
+#### add all supplied
+
+```python
+# Add one value at a time (slow)
+>>> ib.add('first')
+True
+# Or use batch operations (faster).
+>>> ib.update([f'{x}' for x in range(5)])
+5
+# Alternative: ib += data, but this will return nothing
+>>> ib += [f'{x + 5}' for x in range(5)]
+```
+
+#### only add if not exist
+
+```python
+# will first get the difference, and then update them to redis, and return them
+>>> ib.update_difference(['5', '6', '7', '8', '9', '10'])
+['10']
+```
+
+### check if key exists
+
+#### find one
+
+```python
+# Test one value at a time (slow).
+# . in ...
+>>> 'first' in ib
+True
+# ...contains(.)
+>>> ib.contains('first')
+True
+```
+
+#### find multiple
+
+```python
+# Use batch operations (faster).
+# Note: ibloom.intersection() returns a list of values
+# which are found in a Bloom filter. It makes sense when
+# you consider it a set-like operation.
+>>> ib.intersection(['3', '4', '5', '6'])
+['3', '4', '5', '6']
+# Alternative: ib & [b'3', b'4', b'5', b'6']
+>>> ib & ['3', '4', '5', '6', '9', '10']
+['3', '4', '5', '6', '9']
+```
+
+#### find non exist
+
+```python
+>>> ib.difference(['5', '6', '7', '8', '9', '10'])
+['10']
+# not recommended, maybe update in the future
+# Alternative: ib ^ ['5', '6', '7', '8', '9', '10']
+>>> ib ^ ['5', '6', '7', '8', '9', '10']
+['10']
+```
+
+### delete the bloom key
+
+```python
+# delete self
+ib.delete()
+```
+
+
+
+
+%prep
+%autosetup -n ibloom-0.0.2.1
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-ibloom -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.2.1-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..49e1f72
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+36e5ec7aa857e680ad4ff7a3696c8414 ibloom-0.0.2.1.tar.gz