Skip to content

Refactor CTrieRef into TermsTrie and SuffixTrie - #10886

Merged
daxhuiberts merged 1 commit into
masterfrom
dax-ctrie-refactor
Aug 13, 2026
Merged

daxhuiberts merged 1 commit into
masterfrom
dax-ctrie-refactor

Conversation

@daxhuiberts

@daxhuiberts daxhuiberts commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

  1. Current: CTrieRef wraps a bare *mut ffi::Trie with no lifetime and no notion of
    which kind of trie it holds. Handing a suffix walk the primary terms trie is type
    confusion the compiler cannot catch, and the rule that a trie must not be mutated
    while a walk is in progress can only be stated in prose — so all four iteration
    methods are unsafe fn.
  2. Change: CTrieRef becomes two #[repr(transparent)] types, TermsTrie and
    SuffixTrie, borrowed as &/&mut rather than owned. The trie kind is now part of
    the type, mutators take &mut self while walks take &self, and timeout is passed
    by value instead of as a caller-owned pointer.
  3. Outcome: internal only, no behavior change. Four unsafe fn leave the public surface
    because the borrow checker now enforces what their safety sections asked for, and the
    terms/suffix mix-up becomes a compile error.

Which additional issues this PR fixes

N/A

Main objects this PR modified

  1. c_trie::TermsTrie / c_trie::SuffixTrie — replace CTrieRef; construction moves to
    from_raw / from_raw_mut, which carry the validity obligations.
  2. The four walks (iterate_contains, iterate_wildcard on each type) — now safe.
  3. as_ptr / as_mut_ptr — split, so a shared borrow can no longer hand C a pointer to
    mutate through.
  4. query_eval::nodes::{prefix, token, wildcard_query} — the only call sites.

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

@daxhuiberts daxhuiberts changed the title Refactor CTrieRef into TermsTrie and SuffixTrie Refactor CTrieRef into TermsTrie and SuffixTrie Aug 12, 2026
@daxhuiberts
daxhuiberts requested a review from memark August 12, 2026 14:05
@codecov

codecov Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.21%. Comparing base (4f2b28a) to head (6ab4fcf).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/redisearch_rs/c_wrappers/c_trie/src/lib.rs 67.92% 17 Missing ⚠️
src/redisearch_rs/query_eval/src/nodes/token.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10886      +/-   ##
==========================================
- Coverage   83.21%   82.21%   -1.00%     
==========================================
  Files         606      630      +24     
  Lines       80993    82123    +1130     
  Branches    36254    37381    +1127     
==========================================
+ Hits        67399    67521     +122     
- Misses      13247    14255    +1008     
  Partials      347      347              
Flag Coverage Δ
flow 84.36% <ø> (-0.05%) ⬇️
unit 55.73% <76.92%> (-0.60%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@daxhuiberts daxhuiberts mentioned this pull request Aug 12, 2026
1 of 4 tasks
@sonarqubecloud

Copy link
Copy Markdown

@daxhuiberts
daxhuiberts added this pull request to the merge queue Aug 13, 2026
Merged via the queue into master with commit a5156b7 Aug 13, 2026
101 of 104 checks passed
@daxhuiberts
daxhuiberts deleted the dax-ctrie-refactor branch August 13, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants