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

Test executor sortedsets #363

Merged
merged 35 commits into from
Jun 7, 2021
Merged

Conversation

hcwilhelm
Copy link
Contributor

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.

hcwilhelm added 7 commits May 10, 2021 23:12
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
Copy link
Member

@mijicd mijicd left a 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.

redis/src/test/scala/zio/redis/ApiSpec.scala Outdated Show resolved Hide resolved
case api.SortedSets.ZAdd =>
val key = input(0).asString

val updateOption = input.map(_.asString).find {
Copy link
Member

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

Comment on lines +1036 to +1038
val optionsCount = updateOption.map(_ => 1).getOrElse(0) + changedOption.map(_ => 1).getOrElse(0) + incrOption
.map(_ => 1)
.getOrElse(0)
Copy link
Member

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 :).

@hcwilhelm
Copy link
Contributor Author

hcwilhelm commented May 15, 2021

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.

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.

mijicd
mijicd previously approved these changes Jun 7, 2021
@hcwilhelm hcwilhelm marked this pull request as ready for review June 7, 2021 12:11
@hcwilhelm hcwilhelm requested a review from a team as a code owner June 7, 2021 12:11
@mijicd mijicd merged commit b0f0cba into zio:master Jun 7, 2021
@hcwilhelm hcwilhelm deleted the test-executor-sortedsets branch September 6, 2023 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants