python-bloomfilter icon indicating copy to clipboard operation
python-bloomfilter copied to clipboard

Two for the price

Open Maxim-MDProjects opened this issue 2 years ago • 0 comments

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

Maxim-MDProjects avatar Jul 11 '23 13:07 Maxim-MDProjects