91 Commits

Author SHA1 Message Date
antirez
1a1eb8bc8d SCAN code refactored to parse cursor first.
The previous implementation of SCAN parsed the cursor in the generic
function implementing SCAN, SSCAN, HSCAN and ZSCAN.

The actual higher-level command implementation only checked for empty
keys and return ASAP in that case. The result was that inverting the
arguments of, for instance, SSCAN for example and write:

    SSCAN 0 key

Instead of

    SSCAN key 0

Resulted into no error, since 0 is a non-existing key name very likely.
Just the iterator returned no elements at all.

In order to fix this issue the code was refactored to extract the
function to parse the cursor and return the error. Every higher level
command implementation now parses the cursor and later checks if the key
exist or not.
2013-11-05 15:47:50 +01:00
antirez
e23fa0ec99 Aesthetic fix (missing space) into HSCAN and ZSCAN implementations.
Thanks to @badboy for reporting.
2013-10-28 13:20:11 +01:00
antirez
b2618c6cdb ZSCAN implemented. 2013-10-28 11:36:42 +01:00
antirez
4bb257b480 Fix comments for correctness in zunionInterGenericCommand().
Related to issue #1240.
2013-08-19 15:01:05 +02:00
antirez
5173de0525 Properly init/release iterators in zunionInterGenericCommand().
This commit does mainly two things:

1) It fixes zunionInterGenericCommand() by removing mass-initialization
of all the iterators used, so that we don't violate the unsafe iterator
API of dictionaries. This fixes issue #1240.

2) Since the zui* APIs required the allocator to be initialized in the
zsetopsrc structure in order to use non-iterator related APIs, this
commit fixes this strict requirement by accessing objects directly via
the op->subject->ptr pointer we have to the object.
2013-08-19 15:01:01 +02:00
antirez
aa32f92338 Introduction of a new string encoding: EMBSTR
Previously two string encodings were used for string objects:

1) REDIS_ENCODING_RAW: a string object with obj->ptr pointing to an sds
stirng.

2) REDIS_ENCODING_INT: a string object where the obj->ptr void pointer
is casted to a long.

This commit introduces a experimental new encoding called
REDIS_ENCODING_EMBSTR that implements an object represented by an sds
string that is not modifiable but allocated in the same memory chunk as
the robj structure itself.

The chunk looks like the following:

+--------------+-----------+------------+--------+----+
| robj data... | robj->ptr | sds header | string | \0 |
+--------------+-----+-----+------------+--------+----+
                     |                       ^
                     +-----------------------+

The robj->ptr points to the contiguous sds string data, so the object
can be manipulated with the same functions used to manipulate plan
string objects, however we need just on malloc and one free in order to
allocate or release this kind of objects. Moreover it has better cache
locality.

This new allocation strategy should benefit both the memory usage and
the performances. A performance gain between 60 and 70% was observed
during micro-benchmarks, however there is more work to do to evaluate
the performance impact and the memory usage behavior.
2013-07-22 10:31:38 +02:00
antirez
6c56424f24 Z*STORE event fixed: generate del only if resulting sorted set is empty. 2013-01-29 13:50:01 +01:00
antirez
f28d386cc5 Keyspace events: it is now possible to select subclasses of events.
When keyspace events are enabled, the overhead is not sever but
noticeable, so this commit introduces the ability to select subclasses
of events in order to avoid to generate events the user is not
interested in.

The events can be selected using redis.conf or CONFIG SET / GET.
2013-01-28 13:15:12 +01:00
antirez
f2d1105618 Keyspace events added for more commands. 2013-01-28 13:14:56 +01:00
guiquanz
df7a5b7157 Fixed many typos. 2013-01-19 10:59:44 +01:00
antirez
35c7312f59 Fix integer overflow in zunionInterGenericCommand().
This fixes issue #761.
2012-11-22 15:28:28 +01:00
antirez
a32d1ddff6 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
antirez
e093a09c2f Fixed issue #516 (ZINTERSTORE mixing sets and zsets).
Weeks ago trying to fix an harmless GCC warning I introduced a bug in
the ziplist-encoded implementations of sorted sets.

The bug completely broke zuiNext() iterator, that is used in the
ZINTERSTORE and ZUNIONSTORE implementation, so those two commands are no
longer reliable starting from Redis version 2.4.12 and latest 2.6.0-RC
releases.

This commit fixes the problem and adds a regression test.
2012-05-23 11:12:43 +02:00
antirez
6c6d6d8194 A few compiler warnings suppressed. 2012-04-24 11:11:55 +02:00
antirez
3393afc51a zzlIsInRange() now is capable of handling empty sorted sets that may end inside the data set when loading very old RDB files produced by early-stage versions of Redis. 2012-02-22 09:52:10 +01:00
antirez
71b0cfb773 bzero -> memset 2012-02-21 10:06:04 +01:00
antirez
90905c6b20 added a comment on top of the zslRandomLevel() function 2012-01-16 09:39:04 +01:00
antirez
bb241b1996 error in comment fixed 2012-01-11 20:25:51 +01:00
antirez
68bc54c09b Prevent NaN scores in sorted sets resulting from calls to ZUNIONSTORE and ZINTERSTORE. 2011-12-23 09:27:31 +01:00
BigCat
c1cc254d62 Fix issue #247 : Accepting non-integer parameters when shouldn't
Using `getLongFromObjectOrReply` instead of `atoi` if possible.
The following functions are modified.

* lrangeCommand
* ltrimCommand
* lremCommand
* lindexCommand
* lsetCommand
* zunionInterGenericCommand
* genericZrangebyscoreCommand
* sortCommand
2011-12-19 19:48:35 +08:00
antirez
caa84eb445 added assertion in zslInsert() that ensures the inserted element score is not NaN 2011-12-18 11:12:58 +01:00
antirez
33dcbd6df7 string to number API is now more strict not accepting spaces before or after the number. A few tests converted to match the new error messages using the word float instead of double. 2011-11-14 15:34:44 +01:00
antirez
d6c3b3004e dict.c API names modified to be more coincise and consistent. 2011-11-08 17:07:55 +01:00
antirez
f846ddf3ed Fixed a few warnings compiling on Linux. 2011-10-23 10:57:01 +02:00
antirez
357f49db2f replaced redisAssert() with redisAssertWithInfo() in a shitload of places. 2011-10-04 18:43:03 +02:00
Pieter Noordhuis
bfad95e4cb Remove ZCOUNT branches from generic RANGEBYSCORE code 2011-10-03 14:23:31 +02:00
Pieter Noordhuis
68360a1d39 Use element rank instead of iterating in ZCOUNT 2011-10-03 14:14:43 +02:00
antirez
4b31796841 Variadic ZREM 2011-05-31 20:15:18 +02:00
antirez
33bc204b04 Variadic ZADD 2011-05-31 17:47:34 +02:00
antirez
fab8566cb1 Fixed typo in comment 2011-05-24 10:35:58 +02:00
antirez
4ea2be056b Fix for ZUNIONSTORE bug when there is an empty set among input sets. Regression test added. 2011-05-19 17:58:52 +02:00
antirez
883af78cb2 Fixed misuse of the new iterator semantics in ZUNIONSTORE 2011-05-15 17:28:06 +02:00
antirez
2b8ff79f19 Fix for a possible bug related to ZINTER/UNIONSTORE called with the same source set more than one time. 2011-05-15 15:33:01 +02:00
antirez
1bc8ae14e2 if /dev/urandom is not available use rand() to get a random node name 2011-05-04 10:30:22 +02:00
antirez
086fac186f take a hashslot -> keys index, will be used for cluster rehasing 2011-04-28 19:00:33 +02:00
Pieter Noordhuis
a6604494f3 Explicitly zero zval since it is stored on the stack 2011-04-06 16:39:22 +02:00
Pieter Noordhuis
a6ca3077d4 Test for ENCODING_SKIPLIST instead of ENCODING_RAW 2011-04-06 16:17:07 +02:00
Pieter Noordhuis
87f0ac65db Remove sorted set when empty after ZREMRANGEBY* 2011-03-21 23:54:46 +01:00
Pieter Noordhuis
b423656da7 Offset should be size_t 2011-03-14 10:53:53 +01:00
Pieter Noordhuis
63080b6f2f Remove unused function 2011-03-14 10:53:14 +01:00
Pieter Noordhuis
dc940c96f0 Test for empty inner range when looking for elements in range 2011-03-11 18:18:02 +01:00
Pieter Noordhuis
8781386c7a Make zzl API unaware of the robj where the ziplist is stored 2011-03-11 17:06:07 +01:00
Pieter Noordhuis
940daef2c4 Encode sorted set after loading from dump 2011-03-10 17:50:13 +01:00
Pieter Noordhuis
8ce571585b Convert encoding of result when in limits 2011-03-10 17:02:05 +01:00
Pieter Noordhuis
301db9955c Remove comment 2011-03-10 16:53:20 +01:00
Pieter Noordhuis
2c8e68ed64 Generic iterator code for usage in ZUNIONSTORE/ZINTERSTORE 2011-03-10 16:34:52 +01:00
Pieter Noordhuis
8a2dda5e3d Make zzlLength take a ziplist argument 2011-03-10 16:17:14 +01:00
Pieter Noordhuis
808e023370 Fix used function in ZCARD 2011-03-09 16:13:39 +01:00
Pieter Noordhuis
921adfba1d Convert encoding when thresholds overflow 2011-03-09 16:13:06 +01:00
Pieter Noordhuis
a8de648365 Support dual encoding for more commands 2011-03-09 12:37:59 +01:00