joseph-fox / python-bloomfilter

Scalable Bloom Filter implemented in Python
MIT License
164 stars 25 forks source link

Two for the price #40

Open Maxim-MDProjects opened 1 year ago

Maxim-MDProjects commented 1 year ago

Hello. I need to load several files from disk into one, how should I do it? None of the options below worked

def load_bloom_filter(directory):
    bloom_filter = None
    for filename in sorted(os.listdir(directory)):
        file_path = os.path.join(directory, filename)
        if bloom_filter is None:
            bloom_filter = BloomFilter.fromfile(open(file_path, 'rb'))
            print("len1:", len(bloom_filter))
        else:
            bloom_filter_new = BloomFilter.fromfile(open(file_path, 'rb'))
            print("len2:", len(bloom_filter_new))
            bloom_filter = bloom_filter_new.copy() #v1
            bloom_filter |= bloom_filter_new       #v2
    return bloom_filter

.add does not fit because there are many elements