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

feat(base): Add EventCacheStore::filter_duplicated_events #4659

Merged

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Feb 12, 2025

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 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, see
chunk_large_query_over).


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.
@Hywan Hywan marked this pull request as ready for review February 12, 2025 14:39
@Hywan Hywan requested a review from a team as a code owner February 12, 2025 14:39
@Hywan Hywan requested review from andybalaam and bnjbvr and removed request for a team and andybalaam February 12, 2025 14:39
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.74%. Comparing base (fce7999) to head (371d1e4).
Report is 16 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bnjbvr bnjbvr left a 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 👌

Comment on lines +514 to +520
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");
Copy link
Member

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() },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I WANT MORE 🧀

Comment on lines +162 to +165
// If `events` is empty, we can short-circuit.
if events.is_empty() {
break;
}
Copy link
Member

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?

Copy link
Member Author

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.

@bnjbvr bnjbvr enabled auto-merge (rebase) February 12, 2025 15:38
@bnjbvr bnjbvr merged commit 1918bd5 into matrix-org:main Feb 12, 2025
41 checks passed
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

Successfully merging this pull request may close these issues.

2 participants