Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronized on contains/add necessary for BloomFilterMemory? #68

Open
artpar opened this issue Jun 1, 2023 · 0 comments
Open

Synchronized on contains/add necessary for BloomFilterMemory? #68

artpar opened this issue Jun 1, 2023 · 0 comments

Comments

@artpar
Copy link

artpar commented Jun 1, 2023

Hi

I am wondering if the method blocks for contain/add need to be synchronized ?

public synchronized boolean contains(byte[] element) {

contains method is a read-only check on the existing bits.

public synchronized boolean addRaw(byte[] element) {

add method is slightly more trivial than contains since its checking and then setting bits, and also tracking whether any bit was added, eventually returning the added variable. So the caller can figure out if a new bit was set when adding an item. synchronized does makes sense in this case, but what if as a caller I am not concerned about whether a new bit was set on adding an element.

I have extended the BloomFilterMemory class in my project and made the two methods non synchronized, just wanted to be sure that I am not overlooking anything.

Thanks a lot for making and open-sourcing this.

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

No branches or pull requests

1 participant