MOD-10047: Prepare Hybrid Parsing For Hybrid Cursors#6736
MOD-10047: Prepare Hybrid Parsing For Hybrid Cursors#6736kei-nan wants to merge 9 commits intofeature-RRFfrom
Conversation
Codecov Report❌ Patch coverage is Please upload reports for the commit b09b749 to get more accurate results.
Additional details and impacted files@@ Coverage Diff @@
## feature-RRF #6736 +/- ##
==============================================
Coverage ? 88.69%
==============================================
Files ? 261
Lines ? 42760
Branches ? 3630
==============================================
Hits ? 37925
Misses ? 4786
Partials ? 49
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:
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors hybrid request parsing to move pipeline-related code from the merger construction phase to the parsing level, enabling hybrid requests to exist without requiring a merger. The primary motivation is to prepare for future cursor support in hybrid search by decoupling request construction from pipeline building.
Key changes include:
- Reorganized parsing function to return structured command context rather than complete HybridRequest
- Moved LOAD step processing and implicit sorting logic from merger to parser
- Updated test suite to use new parsing interface instead of merger-based construction
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/cpptests/test_cpp_parsed_hybrid_pipeline.cpp |
New test file using parse-then-build pattern instead of merger construction |
tests/cpptests/test_cpp_parse_hybrid.cpp |
Updated to use new ParseHybridCommandCtx structure and parsing interface |
tests/cpptests/test_cpp_hybrid_defaults.cpp |
Modified to work with restructured parsing context and parameter handling |
tests/cpptests/test_cpp_hybrid.cpp |
Simplified to basic HybridRequest creation test, removing pipeline tests |
src/pipeline/pipeline_construction.h |
Removed processLoadStep function declaration |
src/pipeline/pipeline_construction.c |
Updated comment about scorer creation conditions |
src/module.c |
Split hybrid command handler into internal/external variants |
src/hybrid/parse_hybrid.h |
Added ParseHybridCommandCtx structure and updated function signature |
src/hybrid/parse_hybrid.c |
Major refactor moving pipeline logic to parsing phase |
src/hybrid/hybrid_request.h |
Updated HybridRequest structure and added new pipeline building functions |
src/hybrid/hybrid_request.c |
Split pipeline building into depletion and merge phases |
src/hybrid/hybrid_exec.h |
Updated function signatures and added cursor support |
src/hybrid/hybrid_exec.c |
Refactored execution flow to work with new parsing structure |
src/aggregate/aggregate_request.c |
Enhanced SORTBY 0 handling for hybrid tail queries |
src/aggregate/aggregate.h |
Added QEXEC_F_NO_SORT flag for explicit no-sorting behavior |
Comments suppressed due to low confidence (1)
tests/cpptests/test_cpp_parse_hybrid.cpp:1
- Same issue as previous test - 'COMBINE' should not appear before 'SORTBY'. The command structure is incorrect. It should be: 'SEARCH', 'hello', 'VSIM', '@vector', TEST_BLOB_DATA, 'SORTBY', '1', '@score'
/*
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if (hybridParams->scoringCtx) { | ||
| HybridScoringContext_Free(hybridParams->scoringCtx); | ||
| rm_free(hybridParams); | ||
| } | ||
|
|
||
| if (tailPipeline) { | ||
| Pipeline_Clean(tailPipeline); | ||
| rm_free(tailPipeline); | ||
| hybridParams->scoringCtx = NULL; |
There was a problem hiding this comment.
The error handling only frees the scoringCtx but doesn't clean up other resources that may have been allocated during parsing, such as vector query parameters or other contexts that could have been created before the error occurred. This could lead to memory leaks.
| StrongRef_Release(sync_ref); | ||
| array_free(depleters); | ||
| return rc; | ||
| return NULL; |
There was a problem hiding this comment.
Are you sure this won't cause some side-effects? Callee level
There was a problem hiding this comment.
pretty sure,
currently it is only called in HybridRequest_BuildPipeline and it handles it correctly.
| RedisModuleCtx *ctx, RedisSearchCtx *sctx, QueryError *status, | ||
| bool internal) { | ||
| // Build the pipeline and execute | ||
| hreq->reqflags = hybridParams->aggregationParams.common.reqflags; |
There was a problem hiding this comment.
Consider moving this to HybridRequest_BuildPipeline
| int RSShardedHybridCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { | ||
| return hybridCommandHandler(ctx, argv, argc, true); | ||
| } | ||
|
|
||
| int RSClientHybridCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { | ||
| return hybridCommandHandler(ctx, argv, argc, false); |
There was a problem hiding this comment.
Consider different names - like internal-external
Itzikvaknin
left a comment
There was a problem hiding this comment.
LGTM, see few comments
src/aggregate/aggregate_request.c
Outdated
| AC_Advance(ac); // Advance without adding SortBy step to the plan | ||
| *papCtx->reqflags |= QEXEC_F_NO_SORT; | ||
| } else { | ||
| QueryError_SetError(status, QUERY_EPARSEARGS, "SORTBY 0 is not supported in this type of query"); |
There was a problem hiding this comment.
Yes, lets have a also a flow test for this
Reorganize the parsing of a hybrid request so a hybrid request can live without a pipeline.
A clear and concise description of what the PR is solving, including:
Main objects this PR modified
Mark if applicable