Skip to content
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

Commands with RANGE not fully supported #352

Closed
5 tasks
hcwilhelm opened this issue Apr 14, 2021 · 2 comments
Closed
5 tasks

Commands with RANGE not fully supported #352

hcwilhelm opened this issue Apr 14, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@hcwilhelm
Copy link
Contributor

Background

I was looking into the implementation of the test executor for sorted sets and found that we use scala Range for some commands. But I think this is not reflecting accurately the Redis API. The Redis API supports min and max parameters as floating-point numbers as well as -inf and +inf and open intervals on both min and max buy prepending (. Scalas Range class only works with ints and has only support for open intervals on the right side, if I am not mistaken. The question is if Scalas Range semantics is enough for our purpose or if we want to precisely map the capabilities of the Redis API into zio-redis ? If so I think we need to come up with a more precise Range implementation.
An example of such a command would be

Tasks

  • Implement a Datatype wich models/supports of Redis RANGE semantic
  • Use this Type in the sorted set API
  • Implement input encoder
  • Adapt TestExecutor
  • Fix tests
@maizy
Copy link
Contributor

maizy commented Aug 18, 2024

I've done research on all commands for sorted sets with range arguments.

There are three types of ranges available: by rank (by index), by score, and by lex.

by rank

  • zCount
  • zRange
  • zRevRange
  • zRemRangeByRank

Range start / stop in these commands specify an inclusive range with positive or negative numbers for bounds. A negative bound indicates an offset from the end of the sorted set. Neither ±inf nor (int nor [int are allowed as arguments.

Now range arguments is modelled after scala.collection.immutable.Range, and it's almost suitable for it. With some notes:

  • Range can be inclusive (0 to 5) and exclusive (0 until 5), but when range is converted to redis command's arguments, this information is lost.
  • Ranges like -2 to -3 have no meaning in scala, but are allowed. There are no checks in range constructors.
  • Range can have a step (0 to 10 by 3) which can't be translated into a redis argument.

I'd like to add:

  • support for exclusive ranges by recalculating them to inclusive ranges when converting to command arguments
  • more integration tests for negative bounds

by score

  • zRangeByScore
  • zRevRangeByScore
  • zRangeByScoreWithScores
  • zRevRangeByScoreWithScores
  • zRemRangeByScore

These are fully supported, but are implemented with deprecated commands ZRANGEBYSCORE, ZREVRANGEBYSCORE and can be replaced with ZRANGE key start stop BYSCORE [REV] [WITHSCORES]. If we replace them, we will lose support for redis <6.2.

I can do it, but should I?

by lex

  • zLexCount
  • zRangeByLex
  • zRevRangeByLex
  • zRemRangeByLex

These are also fully supported, but with deprecated ZRANGEBYLEX, ZREVRANGEBYLEX and can be replaced by ZRANGE key start stop BYLEX [REV].

Note that the withScores option isn't available here, even for the new ZRANGE .. BYLEX variant.

@mijicd
Copy link
Member

mijicd commented Sep 26, 2024

#989 provided some of the missing implementations. @drmarjanovic will list the missing ones in issue(s) related to Redis 7 migration.

@mijicd mijicd closed this as completed Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants