-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Align Search APIs and behaviour with Redis 8.0+ #4173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Introduce executeKeylessCommand - Implement round-robin execution in ClusterCommandExecutor - Update search commands according to the latest request/response policies - Remove JedisBroadcastAndRoundRobinConfig - Introduce AggregateIterator for proper Cluster support - Deprecate APIs that rely on legacy RediSeach behaviour
85ff14f
to
f85344a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR aligns various Redis search APIs with Redis 8.0+ policies by introducing a new keyless command execution method, implementing round‑robin distribution for keyless commands in cluster mode, and replacing legacy search iteration APIs with a more robust AggregateIterator. Key changes include the introduction of executeKeylessCommand, removal of JedisBroadcastAndRoundRobinConfig, and the implementation of round‑robin scheduling in ClusterCommandExecutor.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/test/java/redis/clients/jedis/modules/search/AggregateIteratorTest.java | New tests for AggregateIterator covering basic use, cursor removal and error cases |
src/main/java/redis/clients/jedis/search/aggr/AggregationBuilder.java | Adds cursorCount tracking when using cursor-based aggregation |
src/main/java/redis/clients/jedis/search/aggr/AggregateIterator.java | Implements a new iterator for aggregation results with proper cursor management |
src/main/java/redis/clients/jedis/executors/ClusterCommandExecutor.java | Introduces round‑robin distribution for keyless command execution |
src/main/java/redis/clients/jedis/UnifiedJedis.java | Updates search commands to use the new executeKeylessCommand method and deprecates legacy APIs |
src/main/java/redis/clients/jedis/CommandObjects.java | Adjusts round‑robin command routing logic and removes unused configuration |
Comments suppressed due to low confidence (1)
src/main/java/redis/clients/jedis/CommandObjects.java:3443
- [nitpick] Add a comment explaining why certain SearchCommands (SUGGET, SUGADD, SUGLEN, SUGDEL, CURSOR) are excluded from round-robin routing to aid future maintainers.
private boolean isRoundRobinSearchCommand(SearchCommand sc) {
// Convert connection map to list for round-robin access | ||
List<Map.Entry<String, ConnectionPool>> nodeList = new ArrayList<>(connectionMap.entrySet()); | ||
|
||
// Select node using round-robin distribution for true unified distribution | ||
// Use modulo directly on the node list size to create a circular counter | ||
int roundRobinIndex = roundRobinCounter.getAndUpdate(current -> (current + 1) % nodeList.size()); | ||
Map.Entry<String, ConnectionPool> selectedEntry = nodeList.get(roundRobinIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider caching the node list or optimizing the round-robin selection process if the connection map does not change frequently, to reduce repetitive list creation and improve efficiency.
// Convert connection map to list for round-robin access | |
List<Map.Entry<String, ConnectionPool>> nodeList = new ArrayList<>(connectionMap.entrySet()); | |
// Select node using round-robin distribution for true unified distribution | |
// Use modulo directly on the node list size to create a circular counter | |
int roundRobinIndex = roundRobinCounter.getAndUpdate(current -> (current + 1) % nodeList.size()); | |
Map.Entry<String, ConnectionPool> selectedEntry = nodeList.get(roundRobinIndex); | |
// Check if the connection map size has changed | |
if (cachedNodeList == null || cachedConnectionMapSize != connectionMap.size()) { | |
synchronized (this) { | |
if (cachedNodeList == null || cachedConnectionMapSize != connectionMap.size()) { | |
cachedNodeList = new ArrayList<>(connectionMap.entrySet()); | |
cachedConnectionMapSize = connectionMap.size(); | |
} | |
} | |
} | |
// Select node using round-robin distribution for true unified distribution | |
// Use modulo directly on the node list size to create a circular counter | |
int roundRobinIndex = roundRobinCounter.getAndUpdate(current -> (current + 1) % cachedNodeList.size()); | |
Map.Entry<String, ConnectionPool> selectedEntry = cachedNodeList.get(roundRobinIndex); |
Copilot uses AI. Check for mistakes.
Uh oh!
There was an error while loading. Please reload this page.