Commit Graph

48 Commits

Author SHA1 Message Date
Matt Stancliff
53b1ee34dd Fix ziplistDeleteRange index parameter
It's valid to delete from negative offsets, so we *don't*
want unsigned arguments here.
2014-12-23 09:31:03 -05:00
Matt Stancliff
fae53dea33 Fix how zipEntry returns values
zipEntry was returning a struct, but that caused some
problems with tests under 32 bit builds.

The tests run better if we operate on structs allocated in the
caller without worrying about copying on return.
2014-12-23 09:31:03 -05:00
Matt Stancliff
8febcffdc5 Allow all code tests to run using Redis args
Previously, many files had individual main() functions for testing,
but each required being compiled with their own testing flags.
That gets difficult when you have 8 different flags you need
to set just to run all tests (plus, some test files required
other files to be compiled aaginst them, and it seems some didn't
build at all without including the rest of Redis).

Now all individual test main() funcions are renamed to a test
function for the file itself and one global REDIS_TEST define enables
testing across the entire codebase.

Tests can now be run with:
  - `./redis-server test <test>`

  e.g. ./redis-server test ziplist

If REDIS_TEST is not defined, then no tests get included and no
tests are included in the final redis-server binary.
2014-12-23 09:31:03 -05:00
Matt Stancliff
8380655e85 Remove ziplist compiler warnings
Only happen when compiled with the test define.
2014-12-23 09:31:03 -05:00
Xiaojie Zhang
9aba616866 Fix comment inconsistencies in ziplist.c
Closes #1523
2014-09-29 06:49:08 -04:00
Matt Stancliff
12d0195b30 Clean up text throughout project
- Remove trailing newlines from redis.conf
  - Fix comment misspelling
  - Clarifies zipEncodeLength usage and a C API mention (#1243, #1242)
  - Fix cluster typos (inspired by @papanikge #1507)
  - Fix rewite -> rewrite in a few places (inspired by #682)

Closes #1243, #1242, #1507
2014-09-29 06:49:07 -04:00
Xiaojie Zhang
4bb6844e43 Avoid unnecessary decoding in ziplist.c
Closes #1519
2014-08-08 11:04:54 +02:00
antirez
1c75408457 assert.h replaced with redisassert.h when appropriate.
Also a warning was suppressed by including unistd.h in redisassert.h
(needed for _exit()).
2013-08-19 15:01:21 +02:00
Salvatore Sanfilippo
7d626d4975 Merge pull request #776 from charsyam/ziplist-bug
fix randstring bug in ziplist.c
2013-07-02 03:18:18 -07:00
Pierre Chapuis
50d43a9823 fix comments forgotten in #285 (zipmap -> ziplist) 2013-01-28 11:07:17 +01:00
charsyam
52b52a3508 fix randstring bug 2012-11-20 02:50:31 +08:00
antirez
4365e5b2d3 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
Pieter Noordhuis
3cc2904e3e Set p to its new offset before modifying it 2012-08-13 14:13:09 -07:00
Pieter Noordhuis
5117c20ab5 Add ziplist test for deleting next to last entries 2012-08-13 14:09:40 -07:00
antirez
b62bdf1c64 Don't assume that "char" is signed.
For the C standard char can be either signed or unsigned, it's up to the
compiler, but Redis assumed that it was signed in a few places.

The practical effect of this patch is that now Redis 2.6 will run
correctly in every system where char is unsigned, notably the RaspBerry
PI and other ARM systems with GCC.

Thanks to Georgi Marinov (@eesn on twitter) that reported the problem
and allowed me to use his RaspBerry via SSH to trace and fix the issue!
2012-07-18 12:04:58 +02:00
antirez
ba779119b8 ziplistFind(): don't assume that entries are comparable by encoding.
Because Redis 2.6 introduced new integer encodings it is no longer true
that if two entries have a different encoding they are not equal.

An old ziplist can be loaded from an RDB file generated with Redis 2.4,
in this case for instance a small unsigned integers is encoded with a
16 bit encoding, while in Redis 2.6 a more specific 8 bit encoding
format is used.

Because of this bug hashes ended with duplicated values or fields lookup
failed, causing many bad behaviors.
This in turn caused a crash while converting the ziplist encoded hash into
a real hash table because an assertion was raised on duplicated elements.

This commit fixes issue #547.

Many thanks to Pinterest's Marty Weiner and colleagues for discovering
the problem and helping us in the debugging process.
2012-06-14 16:01:27 +02:00
Pieter Noordhuis
bf21941686 Compare integers in ziplist regardless of encoding
Because of the introduction of new integer encoding types for ziplists
in the 2.6 tree, the same integer value may have a different encoding in
different versions of the ziplist implementation. This means that the
encoding can NOT be used as a fast path in comparing integers.
2012-05-06 10:06:21 +02:00
antirez
7dbc514de7 Spurious debugging printf removed. 2012-04-24 17:15:21 +02:00
antirez
a76b9063d0 Added two new encodings to ziplist.c
1) One integer "immediate" encoding that can encode from 0 to 12 in the
encoding byte itself.
2) One 8 bit signed integer encoding that can encode 8 bit signed small
integers in a single byte.

The idea is to exploit all the not used bits we have around in a
backward compatible way.
2012-04-24 17:04:00 +02:00
antirez
f22cff43a6 ziplist.c: added comments about the new 24 bit encoding. 2012-04-24 12:52:36 +02:00
Grisha Trubetskoy
5a86ab4799 Add a 24bit integer to ziplists to save one byte for ints that can
fit in 24 bits (thanks to antirez for catching and solving the two's compliment
bug).

Increment REDIS_RDB_VERSION to 6
2012-04-24 12:02:19 +02:00
antirez
bd376d13f8 Big endian fix. The bug was introduced because of a typo. 2012-03-23 12:42:20 +01:00
antirez
8562798308 Merge conflicts resolved. 2012-03-09 22:07:45 +01:00
antirez
7a3e372025 endian.c/h -> endianconv.c/h to avoid issues with broken libraries search paths. 2012-02-14 16:11:46 +01:00
antirez
66d1b021ec ziplist.c endianess fixes, chapter 5. 2012-02-09 17:09:01 +01:00
antirez
cab1105c6e ziplist.c endianess fixes, chapter 4. 2012-02-09 16:36:25 +01:00
antirez
3fa19b7dfc ziplist.c endianess fixes, chapter 3. 2012-02-09 16:28:35 +01:00
antirez
8e0ef249a2 more ziplist.c endianess fixes 2012-02-08 23:20:39 +01:00
antirez
5653847714 ziplist.c fixes for bigendian 2012-02-08 22:59:35 +01:00
Pieter Noordhuis
fe45840201 Implements ziplistFind
To improve the performance of the ziplist implementation, some
functions have been converted to macros to avoid unnecessary stack
movement and duplicate variable assignments.
2012-01-03 16:13:42 -08:00
antirez
f013f40003 Fixed a few warnings compiling on Linux. 2011-10-23 10:57:01 +02:00
Pieter Noordhuis
edf23aff0e Use string2ll in ziplist code (faster) 2011-05-05 16:26:51 +02:00
Pieter Noordhuis
b7d3bf5157 Fix ziplist regression and update stresser 2011-05-05 15:16:51 +02:00
Pieter Noordhuis
7d8c555e92 Merge branch 'unstable' into unstable-zset
Conflicts:
	src/object.c
2011-04-06 16:15:01 +02:00
Pieter Noordhuis
69298a05eb Offset should be size_t 2011-03-14 10:53:53 +01:00
antirez
f220437450 ziplist are now endianess agnostic 2011-03-09 18:49:59 +01:00
antirez
d4fb9f4144 encoded types API to get blob length 2011-02-28 14:48:49 +01:00
Pieter Noordhuis
8ce39260a4 Fix compiler warnings on Solaris 2010-12-23 11:26:11 +00:00
antirez
d51ebef509 LRANGE converted into a COW friendly command. Some refactoring, comment, and new addReply*() family function added in the process. 2010-12-07 16:33:13 +01:00
antirez
10c12171cc removed a number of stupid compilation warnings on Linux 2010-11-02 11:15:09 +01:00
Pieter Noordhuis
306c6a02e3 Replace ziplist stresser and fix regression 2010-10-14 21:11:42 +02:00
Pieter Noordhuis
b0d605c1d6 Add regression test and fix for >255 byte string entries 2010-09-23 22:04:19 +02:00
Pieter Noordhuis
84403fe7c1 Allow a random seed argument for the ziplist test binary 2010-09-07 00:08:42 +02:00
Pieter Noordhuis
169d2ef1e0 Fix updating the prevlen field of consecutive entries
In the condition where the prevlen field of the next entry on insert
and delete operations needs more bytes to be properly encoded, the next
entry also needs to be updated with a new prevlen. This patch makes sure
that this effect cascades throughout the ziplist.
2010-09-07 00:04:57 +02:00
Pieter Noordhuis
c470538142 Make ziplist schema more efficient for strings with length > 15 2010-08-13 19:29:22 +02:00
antirez
6171250871 fixed a ziplist bug about encoding of integer values overflowing 64 bit 2010-07-27 15:26:08 +02:00
antirez
3688d7f308 Compilation fixed on Linux after the source code split 2010-07-01 21:13:38 +02:00
antirez
e2641e09cc redis.c split into many different C files.
networking related stuff moved into networking.c

moved more code

more work on layout of source code

SDS instantaneuos memory saving. By Pieter and Salvatore at VMware ;)

cleanly compiling again after the first split, now splitting it in more C files

moving more things around... work in progress

split replication code

splitting more

Sets split

Hash split

replication split

even more splitting

more splitting

minor change
2010-07-01 14:38:51 +02:00