-
Notifications
You must be signed in to change notification settings - Fork 64
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
Test executor sortedsets #363
Conversation
Conflicts: redis/src/main/scala/zio/redis/TestExecutor.scala redis/src/main/scala/zio/redis/api/SortedSets.scala redis/src/main/scala/zio/redis/options/Shared.scala redis/src/test/scala/zio/redis/ApiSpec.scala redis/src/test/scala/zio/redis/SortedSetsSpec.scala
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.
I'll make another, more detailed pass as I need to review this using editor to understand everything, but in general, mapping doesn't seem to be troublesome.
case api.SortedSets.ZAdd => | ||
val key = input(0).asString | ||
|
||
val updateOption = input.map(_.asString).find { |
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.
Does it need conversion to string? Also, |
might make it cleaner:
case "XX" | "NX" | "LT" | "GT" => true
case _ => false
val optionsCount = updateOption.map(_ => 1).getOrElse(0) + changedOption.map(_ => 1).getOrElse(0) + incrOption | ||
.map(_ => 1) | ||
.getOrElse(0) |
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.
Please use fold
instead of map
+ getOrElse
. This remark applies generally :).
Ok, that's good. I find it way easier to work with the map where I have access to both the value and the score. And so far I could satisfy all the tests I allowed to run ;) And yes I fully understand this is a giant PR and the sorted set Implementation has by far the most lines of code, although I am sure there is a lot of duplication. |
eb123f1
to
46dc590
Compare
SortedSets API support for the TestExecutor backed by a Map[Element, Score]
I found it easier to have a Map of Element -> Score as the underlying data structure than for example a scala TreeSet.
The implementation is not complete at this point but I wanted to create a PR anyways to get some feedback.
I am struggling with implementing full SortedSet API support because some commands support an enormous amount of
Options and also for some commands It is not directly obvious how they should work.