Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Correctness of the code #2

Open
TheHolyJoker opened this issue Jul 2, 2020 · 0 comments
Open

Correctness of the code #2

TheHolyJoker opened this issue Jul 2, 2020 · 0 comments

Comments

@TheHolyJoker
Copy link

TheHolyJoker commented Jul 2, 2020

I think there is an error in the implementation, which makes elements sometimes disappear.

The following code:

from cuckoopy import CuckooFilter
from random import *
from typing import *

letters = 'abcdefghijklmnopqrstuvwxyz'


def test_correctness(max_capacity: int, load_factor: float, bucket_size: int):
    set_size = int(max_capacity * load_factor)
    elements_set: Set[str] = { "".join(choices(letters, k=8)) for _ in range(set_size)}

    cf = CuckooFilter(max_capacity, bucket_size, 2)
    for x in elements_set:
        cf.insert(x)

    for x in elements_set:
        assert cf.contains(x)  # Fails here.

    print("Pass!")


test_correctness(1 << 18, .96, 4)
test_correctness(1 << 19, .96, 4)
test_correctness(1 << 20, .96, 4)
test_correctness(1 << 21, .96, 4)
test_correctness(1 << 22, .96, 4)

Will usually fail.

Reproducing

Save the code into a file named simple_test.py inside tests directory, and run it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant