-
Notifications
You must be signed in to change notification settings - Fork 269
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
feat(base): Add EventCacheStore::filter_duplicated_events
#4659
feat(base): Add EventCacheStore::filter_duplicated_events
#4659
Conversation
This patch adds and implements the `EventCacheStore::filter_duplicated_events` method. It is implemented on the `MemoryStore` and the `SqliteEventCacheStore`. This method remove the unique events and reutrn the duplicated events.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4659 +/- ##
==========================================
+ Coverage 85.69% 85.74% +0.04%
==========================================
Files 292 292
Lines 33620 33713 +93
==========================================
+ Hits 28812 28906 +94
+ Misses 4808 4807 -1 ☔ View full report in Codecov by Sentry. |
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.
Thanks! Super nice that the approach we devised for the sqlite store with a single SELECT
query works flawlessly 👌
let event_comte = event("comté"); | ||
let event_brigand = event("brigand du jorat"); | ||
let event_raclette = event("raclette"); | ||
let event_morbier = event("morbier"); | ||
let event_gruyere = event("gruyère"); | ||
let event_tome = event("tome"); | ||
let event_mont_dor = event("mont d'or"); |
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.
❤️ 🧀
previous: Some(CId::new(0)), | ||
new: CId::new(1), | ||
next: None, | ||
gap: Gap { prev_token: "brillat-savarin".to_owned() }, |
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.
I WANT MORE 🧀
// If `events` is empty, we can short-circuit. | ||
if events.is_empty() { | ||
break; | ||
} |
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.
Can you if events.is_empty() { return; }
at the top of the events, instead?
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.
No because we remove events one by one from events
. When it's empty, we can stop iterating all other events.
This patch adds and implements the
EventCacheStore::filter_duplicated_events
method. It is implemented on theMemoryStore
and theSqliteEventCacheStore
.This method remove the unique events and return the duplicated events.
On the
MemoryStore
, it iterates over events only once.On the
SqliteEventCacheStore
, it runs a single query (modulo the size of events to check, seechunk_large_query_over
).EventCache
storage #3280EventCache
lazy-loading #4632