zdiff

181 views
Skip to first unread message

Xiangrong Fang

unread,
Oct 21, 2010, 2:39:10 AM10/21/10
to redi...@googlegroups.com
I wonder if zdiffstore mentioned here:

http://groups.google.com/group/redis-db/browse_thread/thread/f17f696761088655?fwc=2

will be added in redis 2.2 or not?

Also,

1) why there are no zunion as sunion, but only zunionstore command?

2) is it possible, if for some reason zdiff is not feasible, add a command like

Z2S zset set

to get a set from a zset, and do it fast :D


BR
Shannon

Josiah Carlson

unread,
Oct 21, 2010, 3:24:02 AM10/21/10
to redi...@googlegroups.com
On Wed, Oct 20, 2010 at 11:39 PM, Xiangrong Fang <xrf...@gmail.com> wrote:
> I wonder if zdiffstore mentioned here:
>
> http://groups.google.com/group/redis-db/browse_thread/thread/f17f696761088655?fwc=2
>
> will be added in redis 2.2 or not?

I've not heard anything, but now is a good time to get the discussion going :)

> Also,
>
> 1) why there are no zunion as sunion, but only zunionstore command?

With a set, there is no real way to pull down partial blocks of data
without a SORT. Zsets allow you to pull individual items, ranges,
etc. Also, because of transactional pipelines with MULTI/EXEC, the
non-store versions are effectively redundant with regards to commands
(a store can be followed by a delete, making it equivalent to the
non-store version).

> 2) is it possible, if for some reason zdiff is not feasible, add a command like
>
> Z2S zset set
>
> to get a set from a zset, and do it fast :D

Zdiff is possible, I imagine it was lost in the shuffle of all of the
other things to do for the 2.0 release that were more important at the
time. It would be interesting to be able to quickly be able to
convert a zset into a set, as the reverse is already possible with
ZUNIONSTORE/ZINTERSTORE.

Regards,
- Josiah

Xiangrong Fang

unread,
Oct 21, 2010, 3:28:29 AM10/21/10
to redi...@googlegroups.com
How to convert a SET to a ZSET via ZUNIONSTORE/ZINTERSTORE? Z*STORE
only accept ZSET as their parameters.

R.
Shannon

2010/10/21 Josiah Carlson <josiah....@gmail.com>:

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

Josiah Carlson

unread,
Oct 21, 2010, 4:47:19 AM10/21/10
to redi...@googlegroups.com
It was delayed until 2.2. In 2.2, ZUNIONSTORE/ZINTERSTORE can take
sets as input, whose values default to 1.0, but which can be scaled
with the WEIGHTS argument.

- Josiah

George Bashi

unread,
Oct 21, 2010, 5:52:06 AM10/21/10
to redi...@googlegroups.com
Hi,

I'm not sure the patch will be merged - after submitting it, I spoke with Pieter on IRC and he pointed out that it's difficult to find a valid use-case for ZDIFFSTORE - Pieter and I solved my problem much better by rearranging my data structures!
If there is interest in ZDIFFSTORE then I'd be more than happy to rebase my patch on the latest head.

Cheers,

George

Xiangrong Fang

unread,
Oct 21, 2010, 8:37:02 AM10/21/10
to redi...@googlegroups.com
Hi George,

Why there is no use case? For example, what I am trying to do now:

A bbs has posts, which I plan to put in a zset, because they have time
lines. No there is a set (or zset) recording the post id a user has
already read. I would like to use DIFF to extract all new posts for a
user.

In fact if possible I would suggest to allow diff/union/intersect to
accept hybrid data types, e.g. a set diff a zset etc. But then again,
I don't know how redis works, so this may be impossible.

But I do think there are many valid use cases...

Regards,
Shannon

2010/10/21 George Bashi <ja...@georgebashi.com>:

Reply all
Reply to author
Forward
0 new messages