Repository navigation
[Redis 8.10] Add FT.AGGREGATE REDUCE COLLECT support with complex-value FieldValue - #3878
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03a3031e49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b6d2ec3 to
a605ccf
Compare
b33a00b to
2149635
Compare
03a3031 to
96806b8
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96806b869a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Make SearchResult#addField(String, FieldValue) package-private so the public addField(String, byte[]) stays unambiguous for null arguments; the reply parsers in the same package are the only producers of nested FieldValue columns. - Add @SInCE 7.8 to the new COLLECT API (Reducer#collect() and the CollectReducer fluent methods) and document the contract exceptions they throw. - Add @SInCE 7.8 to the FieldValue members that were still untagged. - Gate shouldPerformCollectAggregation on Redis 8.10 instead of catching every RedisCommandExecutionException from FT.AGGREGATE, so a builder regression fails the test rather than silently skipping it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6dbe3c3c67
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1ec9000f0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @Override | ||
| public CollectReducer as(String alias) { |
There was a problem hiding this comment.
Add a release tag to the covariant as override
The earlier @since fix covered the other fluent methods, but CollectReducer.as(String) is also a newly declared public API with a covariant return type and still has no @since 7.8 tag; Javadoc does not inherit this tag from Reducer.as(String), so the generated API omits its introduction version. Add an override doc comment with the release tag.
AGENTS.md reference: AGENTS.md:L149-L150
Useful? React with 👍 / 👎.
Adds the experimental
REDUCE COLLECTreducer forFT.AGGREGATE, which gathers per-row field projections within eachGROUPBYgroup. To carry its nested column values,FieldValueis extended from a scalar-only wrapper into a tagged union (Kind:SCALAR,ARRAY,MAP,NULL), andSearchReplyParserdecodes nested reply structures recursively instead of failing on theByteBuffercast.Key Decisions & Assumptions
FieldValueextension assumes that reply model and should be rebased if it changes.ARRAY, RESP3MAP); normalization happens at read time via a lenientasMap()that interprets a flat even-length array as key/value pairs. Callers read collected columns uniformly asasList()→ per-entryasMap()on both protocols. Any even-length scalar array (for example aTOLISTcolumn) is accepted by this view; documented as caller responsibility.COLLECTstays inAggregateArgs(theaggregateutilspackage serves FT.HYBRID only).Behavioral / Conceptual Changes
FieldValuearrays/maps; previously the parser failed on them. Scalar columns decode byte-identically to before.FieldValuethrough the wrong kind (for exampleasString()on an array) throwsIllegalStateException; an odd-length pair array is rejected rather than silently truncated.FIELDS *and explicit fields are mutually exclusive, and a reducer without fields fails at encode time.Testing
New
FieldValueUnitTestscover kind discrimination, the pair-normalizingasMap(), immutability, and structural equality.SearchReplyCollectParserUnitTestsverify RESP2/RESP3 collected-column parsing produces equal normalized entries, null preservation inside entries, and TOLIST-style arrays. Command-builder tests assert the exactREDUCE COLLECTwire format; an integration test runs a full COLLECT aggregation, self-skipping on servers withoutsearch-enable-unstable-features.Notes
COLLECTis gated behindsearch-enable-unstable-features; both the server feature and this API are marked@Experimental.HybridReplyParserstill decodes field values as scalars only; FT.HYBRID cannot emit COLLECT today, so this is a known limitation, not a regression.Note
Medium Risk
Extends a core search reply type and parser; scalar behavior is preserved but new kind checks can surface
IllegalStateExceptionif callers use scalar accessors on nested aggregation columns.Overview
Adds experimental
FT.AGGREGATE REDUCE COLLECTsupport viaAggregateArgs.Reducer.collect()and aCollectReducerbuilder (fields/fieldsAll, in-groupsortBy,limit,as), marked@Experimentaland documented as requiringsearch-enable-unstable-features.FieldValueis no longer scalar-only: it introducesKind(SCALAR,ARRAY,MAP,NULL), factories (array,map,nullValue), andasList()/asMap()with kind checks (IllegalStateExceptionon mismatch).asMap()normalizes RESP2 flat key/value arrays and RESP3 maps so collected entries read the same on both protocols.SearchReplyParserrecursively decodes nested reply shapes (COLLECT, TOLIST) into nestedFieldValues instead of assuming every value is aByteBuffer. Scalar columns still decode as before; wrong accessors on complex columns now fail explicitly.User guide adds a COLLECT section with usage examples. Tests cover wire encoding, parser behavior on RESP2/RESP3,
FieldValuesemantics, and an integration path that skips when the server cannot enable unstable features.Reviewed by Cursor Bugbot for commit a1ec900. Bugbot is set up for automated code reviews on this repo. Configure here.