kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

TimeSeries: Support `LATEST` option in queries

Open yezhizi opened this issue 1 month ago • 0 comments

Search before asking

  • [x] I had searched in the issues and found no similar issues.

Motivation

When using TS.GET/TS.RANGE to query a compacted time series, the LATEST option can be specified. This causes TS.GET/TS.RANGE to return the compacted value of the latest bucket, which may be a partial bucket.

Redis reference: https://redis.io/docs/latest/commands/ts.get/

Solution

Modify rangeCommon and getCommon to retrieve the latest bucket of source series when the latest sample is requested.

Note: Since partial aggregations are stored in DOWNSTREAM sub keys, we only need to fetch the last chunk of the source series to retrieve the latest bucket's aggregated value.

Refer to DOWNSTREAM sub keys Refer to https://github.com/apache/kvrocks/pull/3151

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

yezhizi avatar Nov 19 '25 08:11 yezhizi