-
Notifications
You must be signed in to change notification settings - Fork 536
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
Use internal data object for MLBF to accommodate soft/hard block versions #22775
Conversation
029eea3
to
f4bb5a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
be0a284
to
9fbdaaa
Compare
9fbdaaa
to
b571b2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good for now - I'm assuming they'll be a fair bit of reworking needed once we're building an additional soft-blocked bloom filter, and including details of both hard and soft in the stashes.
Relates to: mozilla/addons#15014
Description
Adds the concept of a
data
property toMLBF
. This allows storing of both soft/hard blocks without actually modifying how stashes/filters are generatedContext
This PR doesn't change the underlying behaviour of the bloomfilter but modifies the data structure used for storing data in the
MLBF
class. Adding data for soft blocked versions and then handling the creating of filters or stashes based on that data will be much easier after this PR.Specifically this PR ensures that data is loaded consistently via storage or database and that all data is loaded on instantiation. This ensures filters produced contain valid data.
Testing
You can create a blockfilter locally and ensure it has correct data.
Expect a directory to be created in
./storage/mlbf
matching either the parameter you specified forid
or a timestamp.Expect two files
cache.json
containing the blocked/not_blocked versions for that data type (in this case always hard blocked) andfilter
where the suffix matches the data type (in the future it could be blocked or soft_blocked)Expect the strings in the
blocked
property of cache.json to match the versions in the query above if you search for hard blocks.Scenario 2: create a stash
Now you need to add a new block, using the django shell.
Next create another filter using the same command above.
Now, open a django shell and we can create a stash (make sure mlbf is the latest filter and previous is the first filter you created)
Verify you can diff the filters and see what has changed
The value should return 1 if you only added one additional block.
You can also pass None for previous and get back the number of blocks there are currently (2)
Now you can generate a stash
This should create a new directory matching the id of the
mlbf
and should contain 2 filescache.json
and nowstash.json
.The cache.json should contain the new block you created.
Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.