Kind regards
Regards,
- Josiah
On Sun, Apr 1, 2012 at 1:43 AM, Thomas Fritz <frit...@gmail.com> wrote:
> Hello, i was wondering why there is a SDIFF and SDIFFSTORE but no ZDIFF and ZDIFFSTORE?
>
> Kind regards
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
Regards,
- Josiah
Allowing only one command among a group of related commands to take a
different type of argument would violate a variety of expectations. So
what you are actually proposing is the ability for SINTER, SUNION, and
SDIFF to operate on ZSETs but discard the scores.
While I can't think of a particular situation where I'd have found it
necessary, I do like the symmetry (SETs can already become ZSETs via
the ZSET union and intersect commands), and I suspect that the code
changes would be very minimal.
just finishing ZSET
operations out with ZDIFFSTORE may actually be the right answer. Then
again, assuming that you have non-zero scores in your ZSETs,
ZDIFFSTORE between two ZSETs can be implemented via...
ZINTERSTORE temp 2 zset1 zset2 weights 1 0
ZUNIONSTORE result 2 zset1 temp weights 1 -1
ZREMRANGEBYSCORE result 0 0
DEL temp
> On a similar topic, why no ZINTER or ZUNION without STORE? A good default
> option would be to return all of the results like with SINTER and SUNION.
> This is just my personal perspective, but it seems that Sorted Sets should
> behave as an extension of Sets, inheriting/supporting the same methods if
> possible.
The majority of use-cases involving intersection and union on ZSETs
will fetch a sub-range of a potentially large result. Omitting the
non-store version ensures that you know what you want when you fetch
it. Also, if you wanted the non-store variant, you can get the exact
same behavior with a multi/exec transaction. Perform your operations,
followed by a ZRANGE key 0 -1, followed by a DEL. The STORE variants
are strictly more powerful than their non-store counterparts, and by
not having the non-store versions, that is 2 fewer commands to
implement, document, and maintain.
If you feel like ZDIFFSTORE is something that you really want;
implement it, create a feature request on the tracker, and link to
your fork. Including tests will help. Ultimately it's up to Salvatore,
but having code can go a long way towards convincing someone that the
idea is good.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/J764r7GgaEgJ.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
