Repository navigation
[Redis 8.10] Add support for the TS.READ time series command - #4642
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b53751443b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| /** | ||
| * {@code TS.READ key timestamp [BLOCK milliseconds min_count] [MAX_COUNT max_count]} | ||
| * <p> | ||
| * Returns up to {@code max_count} samples with timestamp greater than or equal to the cursor, in | ||
| * ascending timestamp order. With {@code BLOCK} the call waits until at least {@code min_count} | ||
| * qualifying samples exist or until the timeout elapses; without it the call returns immediately. | ||
| * An empty list is a successful reply, including when a blocking call times out. | ||
| * | ||
| * @param key the time series key | ||
| * @param readParams the cursor and optional {@code BLOCK} / {@code MAX_COUNT} arguments | ||
| * @return samples with timestamp {@code >=} the resolved cursor | ||
| * @since 8.0 | ||
| */ | ||
| List<TSElement> tsRead(String key, TSReadParams readParams); |
There was a problem hiding this comment.
Update docs for TS.READ public API
Because this adds the user-facing tsRead API and new TS.READ behavior, the maintained MkDocs pages under docs/ need a corresponding update; otherwise users relying on the project docs will not learn about the new command or its BLOCK/MAX_COUNT semantics even after upgrading.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Adds support for the RedisTimeSeries TS.READ command to Jedis’ TimeSeries module, exposing a cursor-based forward read API (with optional blocking and reply capping) and wiring it through the core execution surfaces (command objects, unified client, and pipelines), along with unit and integration coverage.
Changes:
- Introduces
TSReadParamsto modelTS.READcursor + optionalBLOCK/MAX_COUNTarguments (including blocking classification and validation). - Wires
tsRead(...)throughRedisTimeSeriesCommands/ pipeline commands,CommandObjects,UnifiedJedis, andPipeliningBase, and extendsTimeSeriesProtocolwithTS.READ+ new keywords/sentinel. - Adds unit tests for params serialization/validation and mocked + integration tests (with a targeted cluster override/disable for a known flush interaction).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/redis/clients/jedis/timeseries/TSReadParams.java | New params object for TS.READ cursor + optional BLOCK/MAX_COUNT, including validation and blocking classification. |
| src/main/java/redis/clients/jedis/timeseries/TimeSeriesProtocol.java | Adds TS.READ, $ sentinel bytes, and BLOCK/MAX_COUNT keywords to protocol enums/constants. |
| src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesCommands.java | Adds new public tsRead overloads with @since and command javadocs. |
| src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesPipelineCommands.java | Adds pipeline responses for tsRead overloads. |
| src/main/java/redis/clients/jedis/CommandObjects.java | Implements tsRead command objects; applies args.blocking() when BLOCK is requested. |
| src/main/java/redis/clients/jedis/UnifiedJedis.java | Exposes tsRead APIs on the unified client via CommandObjects. |
| src/main/java/redis/clients/jedis/PipeliningBase.java | Exposes tsRead APIs on pipeline base via CommandObjects. |
| src/test/java/redis/clients/jedis/timeseries/TSReadParamsTest.java | New unit test suite for TSReadParams validation, blocking classification, and wire serialization order. |
| src/test/java/redis/clients/jedis/mocked/unified/UnifiedJedisTimeSeriesCommandsTest.java | Adds mocked unified-jedis tests for tsRead overloads. |
| src/test/java/redis/clients/jedis/mocked/pipeline/PipeliningBaseTimeSeriesCommandsTest.java | Adds mocked pipeline tests for tsRead overloads. |
| src/test/java/redis/clients/jedis/commands/unified/timeseries/TimeSeriesCommandsTestBase.java | Adds integration coverage for non-blocking reads, paging via MAX_COUNT, sentinels, blocking behavior, and error propagation. |
| src/test/java/redis/clients/jedis/commands/unified/cluster/timeseries/TimeSeriesClusterCommandsIT.java | Disables the cross-client blocking wake test in cluster due to clean-cluster flush behavior. |
| pom.xml | Ensures the new main-source file is included in formatter plugin inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 893eb977c6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Summary
Adds the RedisTimeSeries
TS.READcommand to the Jedis client across all execution surfaces.TS.READperforms a non-blocking (or optionally blocking) forward read of samples whose timestamp is greater than or equal to a cursor, in ascending order, enabling cursor-based paging and tailing of a time series. Two overloads are exposed: a simpletsRead(key, timestamp)and a fulltsRead(key, TSReadParams)supportingBLOCKandMAX_COUNT.Key Decisions & Assumptions
TSReadParamsmodels the cursor plus optionalBLOCK milliseconds min_countandMAX_COUNT max_countarguments. The cursor is either a non-negative literal (Unix ms) or one of the server-resolved sentinels-(earliest),+(latest existing sample), or$(only samples added after the call).BLOCKgroup is all-or-nothing: requesting blocking always emits bothmillisecondsandmin_count.BLOCKis present, the command is issued through blocking-command connection handling (args.blocking()); the simple overload never blocks.BLOCKmilliseconds, non-positivemin_count/max_count, andmin_count > max_count, mirroring server constraints to fail fast.-(earliest).Behavioral / Conceptual Changes
tsReadis added toRedisTimeSeriesCommands/RedisTimeSeriesPipelineCommandsand wired throughCommandObjects,UnifiedJedis, andPipeliningBase.TS.READprotocol command and theBLOCK/MAX_COUNTkeywords plus the$cursor byte toTimeSeriesProtocol.Testing
Adds
TSReadParamsTestcovering argument validation, blocking classification, wire-serialization order (BLOCKbeforeMAX_COUNT), and equals/hashCode. Integration coverage is added to the time series command test base and cluster IT, plus pipeline and unified-jedis command tests exercising both overloads.Notes
@since 8.0.TSReadParams.javais added to the formatter's included-sources list inpom.xml.Note
Low Risk
Additive public API and protocol wiring following existing time-series and blocking-command patterns; no changes to auth or core connection logic beyond marking TS.READ as blocking when requested.
Overview
Adds RedisTimeSeries
TS.READto Jedis so clients can read samples with timestamp ≥ a cursor in ascending order, with optional paging and tailing.New
tsRead(key, timestamp)andtsRead(key, TSReadParams)are wired through command interfaces,CommandObjects,UnifiedJedis, and pipelines.TSReadParamsbuilds the wire form (BLOCK,MAX_COUNT, cursor literals-/+/$) and validates argument constraints client-side. WhenBLOCKis set,CommandObjectsmarks the command blocking so connections use infinite-timeout read handling (same pattern as other blocking Redis commands). Protocol gainsTS.READ,BLOCK,MAX_COUNT, and the$cursor byte.Integration tests cover non-blocking reads,
MAX_COUNTpaging, sentinels, blocking timeout/immediate return, and cross-connection wake; cluster IT disables the flaky blocking-wake case. Unit tests cover params serialization and mocked command routing.Reviewed by Cursor Bugbot for commit 893eb97. Bugbot is set up for automated code reviews on this repo. Configure here.