[MOD-13913] Add debug implementation for NumericRangeTree#8292
[MOD-13913] Add debug implementation for NumericRangeTree#8292LukeMathWalker merged 1 commit intomasterfrom
Conversation
bdf8961 to
9a7b195
Compare
e60035a to
1c84fcd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8292 +/- ##
==========================================
+ Coverage 82.82% 82.86% +0.04%
==========================================
Files 403 405 +2
Lines 58449 58621 +172
Branches 16578 16750 +172
==========================================
+ Hits 48410 48576 +166
+ Misses 9874 9862 -12
- Partials 165 183 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9a7b195 to
4d02a30
Compare
1c84fcd to
9db43f7
Compare
9db43f7 to
1b9cd2f
Compare
4d02a30 to
853f01f
Compare
1b9cd2f to
0aef10b
Compare
src/redisearch_rs/numeric_range_tree/tests/integration/debug.rs
Outdated
Show resolved
Hide resolved
0aef10b to
ad6b3fe
Compare
853f01f to
7e72e18
Compare
8bef85f to
a099cbf
Compare
7e72e18 to
d8ccfc6
Compare
a099cbf to
67a358b
Compare
118d838 to
dbac863
Compare
67a358b to
937e999
Compare
dbac863 to
c4fe674
Compare
010f7d0 to
e7bee69
Compare
c4fe674 to
63087b3
Compare
f685066 to
b473dcb
Compare
9f591ad to
8fa02c0
Compare
e09782e to
06f9330
Compare
8fa02c0 to
8042deb
Compare
06f9330 to
601f53a
Compare
|
4995446 to
2e87d70
Compare
| let mut reader = range.reader(); | ||
| let mut result = RSIndexResult::numeric(0.0); | ||
| while reader.next_record(&mut result).unwrap_or(false) { | ||
| if result.doc_id != last_doc_id { |
There was a problem hiding this comment.
why do we skip printing all multi index results?
Is there a test for multi value?
There was a problem hiding this comment.
If my understanding of the existing C code is correct, it does currently avoid to emit the same doc id multiple time.
It goes:
QueryIterator *iter = NewInvIndIterator_NumericQuery(range->entries, sctx, &fieldCtx, NULL, NULL, range->minVal, range->maxVal);
ReplyIteratorResultsIDs(iter, sctx->redisCtx);which in turn invokes:
InitInvIndIterator(&numIt->base, INV_IDX_NUMERIC_ITERATOR, idx, NewNumericResult(), fieldCtx, sctx, &decoderCtx, NumericCheckAbort);which in turn uses this helper to decide if it should skip multi-values:
// Returns true if the iterator should skip multi-values from the same document
static inline bool ShouldSkipMulti(const InvIndIterator *it) {
return IndexReader_HasMulti(it->reader); // The index holds multi-values (if not, no need to check)
}which basically always evaluates to "skip multivalues in read, just don't bother checking if there are no multivalues".
I guess the reasoning goes as follows: we are only returning the doc ids, without their values, so what's the point of printing the same doc id N times?
I'm happy to change it, but I assume this will be a user-visible change if the debug commands are exposed?
There was a problem hiding this comment.
Changed it to include all ids.
| } | ||
|
|
||
| /// Reply with inverted index header information (adds 1 element to parent). | ||
| fn reply_inverted_index_header(parent: &mut ArrayBuilder<'_>, entries: &NumericIndex) { |
There was a problem hiding this comment.
consider moving to a general inverted index debug file. it essentially implements
debug_commands.c
There was a problem hiding this comment.
Converted this into a method on the Summary itself.
| } | ||
|
|
||
| /// Reply with debug info for an inverted index. | ||
| fn reply_inverted_index_debug( |
There was a problem hiding this comment.
This function as well can be move to inverted index debug file
There was a problem hiding this comment.
That was my first instinct too, but this is actually specific to a numeric index since it makes two specific assumptions:
- All entries are numeric
- And the index is tracking the number of entries explicitly (i.e. it uses our
EntriesTrackingIndexwrapper around the "bare" index)
It is not used for anything else, and in fact, its C counterpart gets deleted in #8306.
There was a problem hiding this comment.
Changed to reply_numeric_index_debug 👍🏻
2e87d70 to
285e614
Compare
285e614 to
81b786b
Compare
81b786b to
ea3d05c
Compare
| let mut reader = range.reader(); | ||
| let mut result = RSIndexResult::numeric(0.0); | ||
| while reader.next_record(&mut result).unwrap_or(false) { | ||
| entries_arr.long_long(result.doc_id as i64); |
There was a problem hiding this comment.
Multi-value doc IDs returned repeatedly
Medium Severity
debug_dump_index emits IDs via range.reader() in reply_range_entries, which returns every numeric entry. Unlike the C DUMP_NUMIDX path, this bypasses iterator logic that skips duplicate IDs for multi-value docs. Multi-valued documents are therefore repeated, producing a different command output shape and inconsistent counts against numDocs.
Additional Locations (1)
| } | ||
|
|
||
| /// Reply with debug info for an inverted index. | ||
| fn reply_inverted_index_debug( |
ea3d05c to
7a90827
Compare
|





Describe the changes in the pull request
Rust equivalent of the debug representation for
NumericRangeTreeprovided bydebug_commands.c.Stacked on top #8276.
Main objects this PR modified
Mark if applicable
Release Notes
If a release note is required (bug fix / new feature / enhancement), describe the user impact of this PR in the title.
Note
Medium Risk
Adds new
FT.DEBUGreply generation paths forNumericRangeTreeand changes the tree DFS iteration order, which could affect any caller relying on node traversal order; functionality is debug-only but touches core data structure iteration.Overview
Adds Rust implementations for
FT.DEBUGintrospection ofNumericRangeTree(NUMIDX_SUMMARY,DUMP_NUMIDX,DUMP_NUMIDXTREE), including optional per-range inverted-index headers and computed average memory-efficiency stats.Updates
inverted_index::debug::Summaryto format its metrics into Redis replies, exposesnumeric_range_tree::debug, and changes the tree iterator toReversePreOrderDfsIterator(right-first traversal), with newinsta-based snapshot integration tests and fixtures to lock the debug output format.Written by Cursor Bugbot for commit 7a90827. This will update automatically on new commits. Configure here.