Ejemplo n.º 1
0
def pyblume_test_locking(N):
    print '   a. Creating filter'
    bloom = pyblume.Filter(1024 * 512, 0.000001, "/tmp/pyblume_locking_test.bf")

    bloom2 = pyblume.open("/tmp/pyblume_locking_test.bf", for_write=1)


    print '   b. Loading filter'
    start = time.time()
    for k in xrange(0, N, 10):
        bloom.add(str(k))
    end = time.time()
    print '         bloom.add: %d/s' % ((N / 10) / (end - start))
Ejemplo n.º 2
0
    def test_filter():
        bloom = pyblume.open(filepath)

        print '   c. Computing false positive rate'
        fn_count = 0
        fp_count = 0
        start = time.time()
        for k in xrange(0, N):
            hit = str(k) in bloom
            if hit and k % 10 != 0:
                fp_count += 1
            elif not hit and k % 10 == 0:
                fn_count += 1
        end = time.time()
        print '         bloom.check: %d/s' % (N / (end - start))
        print '   d. %d false positives out of %d trials (p = %0.4f)' % (fp_count, N, float(fp_count) / N)
Ejemplo n.º 3
0
BLOOM_ERROR_RATE = 0.000001
fileloc = "/tmp/test.blume"

bf = pyblume.Filter(BLOOM_FILTER_MAX_FILESIZE, BLOOM_ERROR_RATE, fileloc)

for i in range(313):

    bf.add(str(i))

bf.close()

check = [str(j) for j in range(300, 400)]

print check

bf = pyblume.open(fileloc, for_write=False)
for x in check:
    if x in bf:
        print "Found"
bf.close()

'''
NOTES:

Bloom Filters Description - https://www.pinterest.com/pin/429953095654194981/

https://www.pinterest.com/pin/429953095654194979/

'''