Commit Graph

144 Commits

Author SHA1 Message Date
be899b824e Merge pull request #4519 from soloestoy/zset-int-problem
Zset int problem
2018-06-08 12:45:11 +02:00
0a698e499a ZPOP: invert score-ele to match ZRANGE WITHSCORES order. 2018-06-05 17:06:25 +02:00
b9d19371e4 ZPOP: unblock multiple clients in right way 2018-05-31 23:35:47 +08:00
4e7a160b9b ZPOP: fix the wrong keyc, should be 1 2018-05-22 21:31:22 +08:00
56bbab238a ZPOP: change sync ZPOP to have a count argument instead of N keys.
Usually blocking operations make a lot of sense with multiple keys so
that we can listen to multiple queues (or whatever the app models) with
a single connection. However in the synchronous case it is more useful
to be able to ask for N elements. This is a change that I also wanted to
perform soon or later in the blocking list variant, but here it is more
natural since there is no reply type difference.
2018-05-11 18:00:32 +02:00
6efb6c1e06 ZPOP: renaming to have explicit MIN/MAX score idea.
This commit also adds a top comment about a subtle behavior of mixing
blocking operations of different types in the same key.
2018-05-11 17:31:53 +02:00
438125b47c Implements [B]Z[REV]POP and the respective unit tests
An implementation of the
[Ze POP Redis Module](https://github.com/itamarhaber/zpop) as core
Redis commands.

Fixes #1861.
2018-04-30 02:10:42 +03:00
e8901b2fe4 zset: fix the int problem 2017-12-08 15:37:08 +08:00
adeed29a99 Use SipHash hash function to mitigate HashDos attempts.
This change attempts to switch to an hash function which mitigates
the effects of the HashDoS attack (denial of service attack trying
to force data structures to worst case behavior) while at the same time
providing Redis with an hash function that does not expect the input
data to be word aligned, a condition no longer true now that sds.c
strings have a varialbe length header.

Note that it is possible sometimes that even using an hash function
for which collisions cannot be generated without knowing the seed,
special implementation details or the exposure of the seed in an
indirect way (for example the ability to add elements to a Set and
check the return in which Redis returns them with SMEMBERS) may
make the attacker's life simpler in the process of trying to guess
the correct seed, however the next step would be to switch to a
log(N) data structure when too many items in a single bucket are
detected: this seems like an overkill in the case of Redis.

SPEED REGRESION TESTS:

In order to verify that switching from MurmurHash to SipHash had
no impact on speed, a set of benchmarks involving fast insertion
of 5 million of keys were performed.

The result shows Redis with SipHash in high pipelining conditions
to be about 4% slower compared to using the previous hash function.
However this could partially be related to the fact that the current
implementation does not attempt to hash whole words at a time but
reads single bytes, in order to have an output which is endian-netural
and at the same time working on systems where unaligned memory accesses
are a problem.

Further X86 specific optimizations should be tested, the function
may easily get at the same level of MurMurHash2 if a few optimizations
are performed.
2017-02-20 17:29:17 +01:00
5dc4fe1529 Verify pairs are provided after subcommands
Fixes https://github.com/antirez/redis/issues/3639
2016-12-02 18:19:36 +02:00
a636aeac07 Apply the new dictUnlink() where possible.
Optimizations suggested and originally implemented by @oranagra.
Re-applied by @antirez using the modified API.
2016-09-14 16:37:53 +02:00
68bf45fa1e Optimize repeated keyname hashing.
(Change cherry-picked and modified by @antirez from a larger commit
provided by @oranagra in PR #3223).
2016-09-12 13:19:05 +02:00
8f3a4df775 Use const in Redis Module API where possible. 2016-06-20 23:08:06 +03:00
bafed3ddd6 Merge pull request #3222 from oranagra/more_minir_fixes
minor fixes - mainly signalModifiedKey, and GEORADIUS
2016-05-18 07:50:53 -07:00
db3ade22eb Modules: zset lex iterator #2. 2016-05-10 06:40:09 +02:00
2b04f86ae5 Modules: zset lex iterator #1. 2016-05-10 06:40:08 +02:00
6eeeda39e9 Modules: sorted set iterators WIP #2. 2016-05-10 06:40:08 +02:00
9682b616a2 minor fixes - mainly signalModifiedKey, and GEORADIUS 2016-05-09 12:05:33 +03:00
0b4bb502a2 Fix ZINCRBY return value. 2016-04-18 00:35:54 -03:00
dda0f37f11 ZREM refactored into proper API. 2016-04-15 15:20:57 +02:00
6f926c3e83 ZRANK refactored into proper API. 2016-04-15 12:47:03 +02:00
b73c7af0f4 zsetAdd() API exposed into server.h. 2016-04-14 16:00:08 +02:00
b1f181a736 ZADD refactored into a proper API. 2016-04-14 12:49:40 +02:00
bb75ecddfd New options for GEORADIUS: STORE and STOREDIST.
Related to issue #3019.
2016-02-18 10:24:16 +01:00
a7c5be18a8 Lazyfree: Sorted sets convereted to plain SDS. (several commits squashed) 2015-10-01 13:02:24 +02:00
32f80e2f1b RDMF: More consistent define names. 2015-07-27 14:37:58 +02:00
40eb548a80 RDMF: REDIS_OK REDIS_ERR -> C_OK C_ERR. 2015-07-26 23:17:55 +02:00
2d9e3eb107 RDMF: redisAssert -> serverAssert. 2015-07-26 15:29:53 +02:00
14ff572482 RDMF: OBJ_ macros for object related stuff. 2015-07-26 15:28:00 +02:00
554bd0e7bd RDMF: use client instead of redisClient, like Disque. 2015-07-26 15:20:52 +02:00
cef054e868 RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
5254c2d3c3 Removed useless tryObjectEncoding() call from ZRANK. 2015-07-03 09:47:08 +02:00
9fc47ddf0b Geo: zsetScore refactoring
Now used both in geo.c and t_zset to provide ZSCORE.
2015-06-22 17:26:36 +02:00
7f4ac3d19c [In-Progress] Add Geo Commands
Current todo:
  - replace functions in zset.{c,h} with a new unified Redis
    zset access API.

Once we get the zset interface fixed, we can squash
relevant commits in this branch and have one nice commit
to merge into unstable.

This commit adds:
  - Geo commands
  - Tests; runnable with: ./runtest --single unit/geo
  - Geo helpers in deps/geohash-int/
  - src/geo.{c,h} and src/geojson.{c,h} implementing geo commands
  - Updated build configurations to get everything working
  - TEMPORARY: src/zset.{c,h} implementing zset score and zset
    range reading without writing to client output buffers.
  - Modified linkage of one t_zset.c function for use in zset.c

Conflicts:
	src/Makefile
	src/redis.c
2015-06-22 09:07:13 +02:00
0dc6a5d497 Update t_zset.c 2015-06-02 18:12:57 +08:00
d8a8dca7fd ZADD RETCH option renamed CH
From Twitter:

    "@antirez that’s an awfully-named command :(
     http://en.wikipedia.org/wiki/Retching"
2015-05-29 11:32:22 +02:00
c043a4e6f4 ZADD RETCH option: Return number of elements added or updated
Normally ZADD only returns the number of elements added to a sorted
set, using the RETCH option it returns the sum of elements added or
for which the score was updated.
2015-05-29 11:22:03 +02:00
5d32abbb9e ZADD NX and XX options 2015-05-29 09:59:42 +02:00
382a943414 ZADD implemenation able to take options. 2015-05-28 18:10:51 +02:00
d956d809ac Fix three simple clang analyzer warnings 2014-12-23 09:31:04 -05:00
5b3930655f Remove redundant else/return block
Fixes #1741
2014-08-07 12:20:57 +02:00
d74e422b5e Remove useless var and check in zunionInterGenericCommand(). 2014-07-22 17:38:22 +02:00
119813e968 ZUNIONSTORE reimplemented for speed.
The user @kjmph provided excellent ideas to improve speed of ZUNIONSTORE
(in certain cases by many order of magnitude), together with an
implementation of the ideas.

While the ideas were sounding, the implementation could be improved both
in terms of speed and clearness, so that's my attempt at reimplementing
the speedup proposed, trying to improve by directly using just a
dictionary with an embedded score inside, and reusing the single-pass
aggregate + order-later approach.

Note that you can't apply this commit without applying the previous
commit in this branch that adds a double in the dictEntry value union.

Issue #1786.
2014-07-22 17:38:22 +02:00
95b1979c32 No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
dc8584696a fix issue 1787 2014-06-01 02:23:24 +08:00
ab3afe2f4d ZREMRANGEBYLEX memory leak removed calling zslFreeLexRange(). 2014-04-18 13:01:04 +02:00
78954ca3a2 ZREMRANGEBYLEX implemented. 2014-04-17 14:49:25 +02:00
8827dc4eec Always pass sorted set range objects by reference. 2014-04-17 14:30:12 +02:00
95098b7230 ZREMRANGE* commands refactored into a single generic function. 2014-04-17 14:19:14 +02:00
bcab07f7fc Pass by pointer and release of lex ranges.
Given that the code was written with a 2 years pause... something
strange happened in the middle. So there was no function to free a
lex range min/max objects, and in some places the range was passed by
value.
2014-04-16 23:55:58 +02:00