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

RFC: Use a more general but still object-safe signature for Query::query_terms. #1468

Merged
merged 2 commits into from
Aug 23, 2022
Merged

RFC: Use a more general but still object-safe signature for Query::query_terms. #1468

merged 2 commits into from
Aug 23, 2022

Conversation

adamreichold
Copy link
Collaborator

@adamreichold adamreichold commented Aug 23, 2022

BTreeMap is a relatively specific data structure and the current signature enforces allocating a new collection and cloning the terms even if the consumer only needs to inspect a subset of the terms.

This PR is a breaking change which aims to avoid this by using a closure to visit each of the terms contained in the query. The closure is passed as a trait object to keep the Query trait it self object-safe.

The approach has the downside of pushing deduplication of identical terms into the visitor. But it also gives consumers the option of e.g. counting multiplicities.

@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2022

Codecov Report

Merging #1468 (c39f03b) into main (8b3a6f6) will decrease coverage by 0.00%.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##             main    #1468      +/-   ##
==========================================
- Coverage   94.09%   94.09%   -0.01%     
==========================================
  Files         238      238              
  Lines       44552    44538      -14     
==========================================
- Hits        41923    41908      -15     
- Misses       2629     2630       +1     
Impacted Files Coverage Δ
src/query/boost_query.rs 69.76% <0.00%> (ø)
src/query/disjunction_max_query.rs 0.00% <0.00%> (ø)
src/query/query.rs 85.71% <66.66%> (ø)
src/query/boolean_query/boolean_query.rs 92.76% <100.00%> (ø)
src/query/mod.rs 100.00% <100.00%> (ø)
src/query/phrase_query/phrase_query.rs 91.54% <100.00%> (ø)
src/query/term_query/term_query.rs 93.02% <100.00%> (ø)
src/snippet/mod.rs 90.02% <100.00%> (+0.30%) ⬆️
src/fastfield/reader.rs 87.73% <0.00%> (-0.62%) ⬇️
src/store/index/mod.rs 97.83% <0.00%> (-0.55%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@fulmicoton fulmicoton merged commit 71ab482 into quickwit-oss:main Aug 23, 2022
This was referenced Jan 13, 2023
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.

3 participants