Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Implement ARAGG and RANGE predicate for ARGREP#15534

Open
ShubhamTaple wants to merge 4 commits into
redis:unstableredis/redis:unstablefrom
ShubhamTaple:arShubhamTaple/redis:arCopy head branch name to clipboard
Open

Implement ARAGG and RANGE predicate for ARGREP#15534
ShubhamTaple wants to merge 4 commits into
redis:unstableredis/redis:unstablefrom
ShubhamTaple:arShubhamTaple/redis:arCopy head branch name to clipboard

Conversation

@ShubhamTaple

@ShubhamTaple ShubhamTaple commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This PR addresses #15211 - but ARQUERY is not added because its functionality would remain same as ARGREP, so I don't see a point adding it (happy to change my decision if maintainers push me)

  • Implements ARAGG - Array Aggregate command in similar fashion as AROP.

  • Enhances ARGREP to include RANGE predicate.

Changes

  1. Changes to ARGREP to add RANGE is minimal. (t_array.c)
  2. ARAGG is implemented in similar way to AROP. (t_array.c)
  3. Predicate logic is now shared between ARGREP and ARAGG. (t_array.c)
  4. Tests covering ARGREP with RANGE predicate and ARAGG command.

ARGREP – now with RANGE predicate

ARGREP key start end
  [EXACT string | MATCH string | GLOB pattern | RE pattern | RANGE min max [EXCLUSIVE]] ...
  [AND | OR] [LIMIT count] [WITHVALUES] [NOCASE]

ARAGG – compute aggregates with optional predicates

ARAGG key start end
  [EXACT string | MATCH string | GLOB pattern | RE pattern | RANGE min max [EXCLUSIVE]] ...
  [AND | OR] [LIMIT count] [NOCASE]
  AGGREGATE op [op ...]

Examples

127.0.0.1:6379> DEL temps
(integer) 1
127.0.0.1:6379> ARMSET temps 0 20.1 1 45.0 2 29.9 3 35.2
(integer) 4
127.0.0.1:6379> ARGREP temps - + RANGE 30 40
1) (integer) 3

127.0.0.1:6379> DEL temps
(integer) 1
127.0.0.1:6379> ARMSET temps 0 5 1 10 2 15 3 20 4 25
(integer) 5
127.0.0.1:6379> ARGREP temps - + RANGE 10 20 EXCLUSIVE
1) (integer) 2

127.0.0.1:6379> DEL readings
(integer) 1
127.0.0.1:6379> ARMSET readings 5 "failover-55"
(integer) 1
127.0.0.1:6379> ARGREP readings - + MATCH "fail" WITHVALUES
1) 1) (integer) 5
   2) "failover-55"
   
127.0.0.1:6379> DEL temps
(integer) 1
127.0.0.1:6379> ARMSET temps 0 20.1 1 5.0 2 35.2
(integer) 3
127.0.0.1:6379> ARAGG temps - + AGGREGATE MIN MAX AVG
1) "5"
2) "35.2"
3) "20.1"

127.0.0.1:6379> DEL errors
(integer) 1
127.0.0.1:6379> ARMSET errors 0 "timeout-120" 1 "timeout-150" 2 "timeout-180"
(integer) 3
127.0.0.1:6379> ARAGG errors - + MATCH "timeout" AGGREGATE COUNT
1) (integer) 3

Note

Medium Risk
New public commands and shared parser changes affect ARGREP and ARAGG behavior; readonly-only but regex/RANGE parsing and aggregate edge cases need careful review.

Overview
Introduces ARAGG (8.10.0): a readonly array command that scans an index range, optionally filters elements with the same predicates as ARGREP (EXACT, MATCH, GLOB, RE, RANGE), then returns SUM, MIN, MAX, COUNT, AVG, AND, OR, XOR in one pass via a required AGGREGATE clause. Predicates are optional for ARAGG; WITHVALUES is rejected there.

ARGREP gains a RANGE min max [EXCLUSIVE] predicate (numeric element values, inclusive or exclusive bounds). Command metadata is updated in commands/aragg.json, commands/argrep.json, and generated commands.def.

t_array.c refactors ARGREP-specific predicate code into a shared array predicate engine (arPredicate*, arParsePredicatePlanOrReply with optional stop-at-AGGREGATE and optional zero predicates). araggCommand implements multi-accumulator logic similar in spirit to AROP, honoring LIMIT on matched elements. Unit tests in tests/unit/type/array.tcl cover RANGE on ARGREP and broad ARAGG behavior.

Reviewed by Cursor Bugbot for commit f68b8e6. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-project-automation github-project-automation Bot moved this to Needs triage in Redis Triage Jul 25, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit c672d52. Configure here.

Comment thread src/t_array.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.