'A wrapper for :class:`~cola.core.bloomfilter.BloomFilter` with file persistence.
When started, it will load the bits from file, at the same time,
when shutdown, the bits will be saved into a file.'

def __init__(self, filename, capacity, false_positive_rate=0.01):

    if (os.path.exists(filename) and (os.path.getsize(filename) > 0)):
        with open(filename) as f:
            (old_capcity, old_false_rate, hash_) = pickle.load(f)
            if ((capacity > old_capcity) or (false_positive_rate < old_false_rate)):
                del hash_
                (self.capacity, self.false_positive_rate) = (capacity, false_positive_rate)
            else:
                self.capacity = old_capcity
                self.false_positive_rate = old_false_rate
            super(FileBloomFilter, self).__init__(capacity=self.capacity, false_positive_rate=self.false_positive_rate)
            if ('hash_' in locals()):
                self.hash = hash_
    else:
        self.capacity = capacity
        self.false_positive_rate = false_positive_rate
        super(FileBloomFilter, self).__init__(capacity=capacity, false_positive_rate=false_positive_rate)
    dirname = os.path.dirname(filename)
    if (not os.path.exists(dirname)):
        os.makedirs(dirname)
    self.f = open(filename, 'w+')
