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

improve validation of quotient filter metadata bits #128

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions probables/quotientfilter/quotientfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,24 @@ def print(self, file: TextIO = sys.stdout):
file=file,
)

def validate_metadata(self):
"""check for invalid bit settings"""
def validate_metadata(self, verbose=False) -> bool:
"""Check for invalid bit settings, per the wikipedia documentation

Args:
verbose (str): Print which index in the quotient filter failed
Returns:
bool: True if the metadata bits are all passing; False otherwise"""
is_valid = True
for i in range(self._size):
if self._is_occupied[i] == 0 and self._is_continuation == 1 and self._is_shifted == 0:
print(f"Row failed: {i}")
if verbose:
print(f"Row failed: {i}")
is_valid = False
if self._is_occupied[i] == 1 and self._is_continuation == 1 and self._is_shifted == 0:
print(f"Row failed: {i}")
if verbose:
print(f"Row failed: {i}")
is_valid = False
return is_valid

def _element_is(self, idx):
is_a = "Continuation"
Expand Down
Loading