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

Add sortmode for Trie + bugfix score sorting #2952

Merged
merged 8 commits into from
Aug 5, 2022
Merged

Conversation

ashtul
Copy link
Contributor

@ashtul ashtul commented Jul 31, 2022

Add two sorting modes: by lexigraphic order and by score order.
Sorting mode is set when Trie is initialized.
Sorting node children now takes place on writes only (add/delete). Before this change, nodes were sorted during queries, making the data structure unsafe for multi-readers.

typedef enum {
  Trie_Sort_Lex = 0,
  Trie_Sort_Score = 1,
} TrieSortMode;

Bug Fix - The default sort by score had a bug exposed in the test_cpp_trie.

replaces #2951

Copy link
Collaborator

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

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

👍 Look good, one comment.

@codecov
Copy link

codecov bot commented Jul 31, 2022

Codecov Report

Merging #2952 (d004545) into master (63d1dff) will increase coverage by 0.00%.
The diff coverage is 93.02%.

❗ Current head d004545 differs from pull request most recent head 2d73f27. Consider uploading reports for the commit 2d73f27 to get more accurate results

@@           Coverage Diff           @@
##           master    #2952   +/-   ##
=======================================
  Coverage   81.94%   81.94%           
=======================================
  Files         180      180           
  Lines       29429    29430    +1     
=======================================
+ Hits        24115    24116    +1     
  Misses       5314     5314           
Impacted Files Coverage Δ
src/spec.c 86.01% <60.00%> (ø)
src/trie/trie.c 94.79% <96.66%> (ø)
src/dictionary.c 90.40% <100.00%> (ø)
src/redisearch_api.c 89.49% <100.00%> (ø)
src/spell_check.c 98.28% <100.00%> (ø)
src/suggest.c 90.98% <100.00%> (ø)
src/trie/trie_type.c 83.09% <100.00%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63d1dff...2d73f27. Read the comment docs.

@ashtul ashtul changed the title Add sortmode for Trie Add sortmode for Trie + bugfix score sorting Jul 31, 2022
MeirShpilraien
MeirShpilraien previously approved these changes Aug 3, 2022
@ashtul ashtul merged commit 26429d4 into master Aug 5, 2022
@ashtul ashtul deleted the ariel_trie-sort-on-write branch August 5, 2022 09:37
oshadmi pushed a commit that referenced this pull request Aug 8, 2022
* Set sorting of Trie. Sort on write

* add cpp tests

* Fix for spellcheck

* change -1 to INT_MIN

* revert -1

* remove tests - add in later PR
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