Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting and cleaning up some of the source #10

Merged
merged 8 commits into from
Mar 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
build/*
dist/
*.o

*.so
*.pyc
pyreBloom/pyre
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python
services:
- redis-server
python:
- '2.7'
install:
- 'sudo apt-get install libhiredis-dev'
- 'pip install -r requirements.txt'
- 'make install'
script: make test
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
build: pyreBloom/*.c
python setup.py build_ext --inplace

install:
python setup.py install

clean:
# Remove the build
sudo rm -rf build dist
find . -name '*.pyc' | xargs -n 100 rm
find . -name .coverage | xargs rm
find . -name '*.o' | xargs rm
find . -name '*.so' | xargs rm

.PHONY: test
test: install
rm -f .coverage
nosetests --exe -v
46 changes: 28 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__Py__thon + __Re__dis + __Bloom__ Filter = pyreBloom
Python + Redis + Bloom Filter = pyreBloom
=====================================================
[![Build Status](https://travis-ci.org/seomoz/pyreBloom.svg?branch=linting)](https://travis-ci.org/seomoz/pyreBloom)

One of Salvatore's suggestions for Redis' GETBIT and SETBIT commands is to
implement bloom filters. There was an existing python project that we used
Expand All @@ -18,11 +19,14 @@ versions.
Installation
============

You will need `hiredis` installed, as well as Cython (for the time being --
we'd like to remove this dependency soon), and a C compiler (probably GCC).
You will need `hiredis` installed, and a C compiler (probably GCC). You can
optionally have `Cython` installed, which will generate the C extension code.
With those things installed, it's pretty simple:

sudo python setup.py install
```bash
pip install -r requirements
python setup.py install
```

Hiredis
-------
Expand Down Expand Up @@ -51,27 +55,33 @@ modes are about 4-5 times faster than their serial equivalents, so use them
when you can. When you instantiate a pyreBloom, you should give it a redis
key name, a capacity, and an error rate:

import pyreBloom
p = pyreBloom.pyreBloom('myBloomFilter', 100000, 0.01)
# You can find out how many bits this will theoretically consume
p.bytes
# And how many hashes are needed to satisfy the false positive rate
p.hashes
```python
import pyreBloom
p = pyreBloom.pyreBloom('myBloomFilter', 100000, 0.01)
# You can find out how many bits this will theoretically consume
p.bytes
# And how many hashes are needed to satisfy the false positive rate
p.hashes
```

From that point, you can add elements quite easily:

tests = ['hello', 'how', 'are', 'you', 'today']
p.extend(tests)
```python
tests = ['hello', 'how', 'are', 'you', 'today']
p.extend(tests)
```

The batch mode of `contains` differs from the serial version in that it actually
returns which elements are in the bloom filter:

p.contains('hello')
# True
p.contains(['hello', 'whats', 'new', 'with', 'you'])
# ['hello', 'you']
'hello' in p
# True
```python
p.contains('hello')
# True
p.contains(['hello', 'whats', 'new', 'with', 'you'])
# ['hello', 'you']
'hello' in p
# True
```

The Story
=========
Expand Down
Loading