card323 / redis

Automatically exported from code.google.com/p/redis
0 stars 0 forks source link

Need iterator for hash data structure #641

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What version of Redis you are using, in what kind of Operating System?
2.2.12

What is the problem you are experiencing?
Hash data structure does not have an iterator. For a large number of records 
HVALS takes too long time. So was wondering if there can be support to get 
records in a batch like zrange command for sorted set or an iterator to iterate 
as many records as you want.

What steps will reproduce the problem?
--

Do you have an INFO output? Please past it here.
--

If it is a crash, can you please paste the stack trace that you can find in
the log file or on standard output? This is really useful for us!
--

Please provide any additional information below.

Original issue reported on code.google.com by sonal...@gmail.com on 22 Aug 2011 at 11:02

GoogleCodeExporter commented 8 years ago
Hashes are inherently unordered, nor does Redis keep multiple versions of a 
single value (e.g. to keep around an old version you are iterating over when it 
is modified or deleted) so it is unfortunately not possible to iterate over the 
fields/value pairs in a hash. This also means that even if we are able to 
iterate over a hash that it can not be consistent without introducing a 
versioning scheme.

If you do not require a consistent view, you can try to use an extra set per 
hash storing its fields in combination with SRANDMEMBER to eventually sample 
all fields in the hash. Otherwise you could try and find a way to split the 
hash into multiple smaller hashes such that HVALS doesn't take too long.

For the sake of argument: HVALS against a 100k field hash where every field 
equals "value" takes about ~35ms on my 2010 i7 MBP, from a Ruby script, where 
the time taken to parse the protocol is included.

Original comment by pcnoordh...@gmail.com on 22 Aug 2011 at 2:38