Skip to content

Commit

Permalink
Fix build with newer dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
sistawendy committed Jan 24, 2015
2 parents c470da4 + 4468c3b commit 4e063af
Show file tree
Hide file tree
Showing 20 changed files with 3,110 additions and 2,092 deletions.
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 -f
find . -name .coverage | xargs rm -f
find . -name '*.o' | xargs rm -f
find . -name '*.so' | xargs rm -f

.PHONY: test
test:
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.txt
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.bits
# 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
23 changes: 23 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Encoding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :

# http://docs.vagrantup.com/v2/
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.hostname = 'pyreBloom'
config.ssh.forward_agent = true

# Part of provisioning is cloning a couple of private repos, so this is to
# enable key forwarding during provisioning
config.vm.provision :shell, inline:
'echo \'Defaults env_keep += "SSH_AUTH_SOCK"\' > /etc/sudoers.d/ssh-auth-sock; ' +
'chmod 0440 /etc/sudoers.d/ssh-auth-sock'

config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end

config.vm.provision :shell, path: 'provision/script.sh', privileged: false
end
13 changes: 13 additions & 0 deletions provision/etc/init/redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# redis - Single-Node Qless Admin UI
#

description "Redis"

start on (local-filesystems
and net-device-up IFACE!=lo)
stop on runlevel[!2345]

respawn
console log

exec redis-server /etc/redis.conf
Loading

0 comments on commit 4e063af

Please sign in to comment.