summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-07-26 15:28:00 +0200
committerantirez <antirez@gmail.com>2015-07-26 15:28:00 +0200
commit14ff572482cfe02c5ac61a1816cb8099d458e499 (patch)
treeb6836f54761f5f6b0b343ad078b6df43772952a5
parent554bd0e7bd81715e319cafda437ed2aebd44b6e9 (diff)
downloadredis-14ff572482cfe02c5ac61a1816cb8099d458e499.tar.gz
RDMF: OBJ_ macros for object related stuff.
-rw-r--r--src/aof.c34
-rw-r--r--src/bitops.c18
-rw-r--r--src/cluster.c4
-rw-r--r--src/config.c16
-rw-r--r--src/db.c42
-rw-r--r--src/debug.c36
-rw-r--r--src/geo.c16
-rw-r--r--src/hyperloglog.c4
-rw-r--r--src/networking.c26
-rw-r--r--src/notify.c4
-rw-r--r--src/object.c144
-rw-r--r--src/rdb.c102
-rw-r--r--src/replication.c8
-rw-r--r--src/scripting.c4
-rw-r--r--src/server.c94
-rw-r--r--src/server.h54
-rw-r--r--src/slowlog.c6
-rw-r--r--src/sort.c38
-rw-r--r--src/t_hash.c118
-rw-r--r--src/t_list.c64
-rw-r--r--src/t_set.c104
-rw-r--r--src/t_string.c60
-rw-r--r--src/t_zset.c160
23 files changed, 578 insertions, 578 deletions
diff --git a/src/aof.c b/src/aof.c
index 17cae875c..aeee446be 100644
--- a/src/aof.c
+++ b/src/aof.c
@@ -666,7 +666,7 @@ int loadAppendOnlyFile(char *filename) {
freeFakeClientArgv(fakeClient);
goto readerr;
}
- argv[j] = createObject(REDIS_STRING,argsds);
+ argv[j] = createObject(OBJ_STRING,argsds);
if (fread(buf,2,1,fp) == 0) {
fakeClient->argc = j+1; /* Free up to j. */
freeFakeClientArgv(fakeClient);
@@ -756,7 +756,7 @@ fmterr: /* Format error. */
int rioWriteBulkObject(rio *r, robj *obj) {
/* Avoid using getDecodedObject to help copy-on-write (we are often
* in a child process when this function is called). */
- if (obj->encoding == REDIS_ENCODING_INT) {
+ if (obj->encoding == OBJ_ENCODING_INT) {
return rioWriteBulkLongLong(r,(long)obj->ptr);
} else if (sdsEncodedObject(obj)) {
return rioWriteBulkString(r,obj->ptr,sdslen(obj->ptr));
@@ -770,7 +770,7 @@ int rioWriteBulkObject(rio *r, robj *obj) {
int rewriteListObject(rio *r, robj *key, robj *o) {
long long count = 0, items = listTypeLength(o);
- if (o->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (o->encoding == OBJ_ENCODING_QUICKLIST) {
quicklist *list = o->ptr;
quicklistIter *li = quicklistGetIterator(list, AL_START_HEAD);
quicklistEntry entry;
@@ -804,7 +804,7 @@ int rewriteListObject(rio *r, robj *key, robj *o) {
int rewriteSetObject(rio *r, robj *key, robj *o) {
long long count = 0, items = setTypeSize(o);
- if (o->encoding == REDIS_ENCODING_INTSET) {
+ if (o->encoding == OBJ_ENCODING_INTSET) {
int ii = 0;
int64_t llval;
@@ -821,7 +821,7 @@ int rewriteSetObject(rio *r, robj *key, robj *o) {
if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0;
items--;
}
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
dictIterator *di = dictGetIterator(o->ptr);
dictEntry *de;
@@ -851,7 +851,7 @@ int rewriteSetObject(rio *r, robj *key, robj *o) {
int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
long long count = 0, items = zsetLength(o);
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = o->ptr;
unsigned char *eptr, *sptr;
unsigned char *vstr;
@@ -886,7 +886,7 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0;
items--;
}
- } else if (o->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (o->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = o->ptr;
dictIterator *di = dictGetIterator(zs->dict);
dictEntry *de;
@@ -918,11 +918,11 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
/* Write either the key or the value of the currently selected item of a hash.
* The 'hi' argument passes a valid Redis hash iterator.
* The 'what' filed specifies if to write a key or a value and can be
- * either REDIS_HASH_KEY or REDIS_HASH_VALUE.
+ * either OBJ_HASH_KEY or OBJ_HASH_VALUE.
*
* The function returns 0 on error, non-zero on success. */
static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) {
- if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;
unsigned int vlen = UINT_MAX;
long long vll = LLONG_MAX;
@@ -934,7 +934,7 @@ static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) {
return rioWriteBulkLongLong(r, vll);
}
- } else if (hi->encoding == REDIS_ENCODING_HT) {
+ } else if (hi->encoding == OBJ_ENCODING_HT) {
robj *value;
hashTypeCurrentFromHashTable(hi, what, &value);
@@ -962,8 +962,8 @@ int rewriteHashObject(rio *r, robj *key, robj *o) {
if (rioWriteBulkObject(r,key) == 0) return 0;
}
- if (rioWriteHashIteratorCursor(r, hi, REDIS_HASH_KEY) == 0) return 0;
- if (rioWriteHashIteratorCursor(r, hi, REDIS_HASH_VALUE) == 0) return 0;
+ if (rioWriteHashIteratorCursor(r, hi, OBJ_HASH_KEY) == 0) return 0;
+ if (rioWriteHashIteratorCursor(r, hi, OBJ_HASH_VALUE) == 0) return 0;
if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0;
items--;
}
@@ -1050,20 +1050,20 @@ int rewriteAppendOnlyFile(char *filename) {
if (expiretime != -1 && expiretime < now) continue;
/* Save the key and associated value */
- if (o->type == REDIS_STRING) {
+ if (o->type == OBJ_STRING) {
/* Emit a SET command */
char cmd[]="*3\r\n$3\r\nSET\r\n";
if (rioWrite(&aof,cmd,sizeof(cmd)-1) == 0) goto werr;
/* Key and value */
if (rioWriteBulkObject(&aof,&key) == 0) goto werr;
if (rioWriteBulkObject(&aof,o) == 0) goto werr;
- } else if (o->type == REDIS_LIST) {
+ } else if (o->type == OBJ_LIST) {
if (rewriteListObject(&aof,&key,o) == 0) goto werr;
- } else if (o->type == REDIS_SET) {
+ } else if (o->type == OBJ_SET) {
if (rewriteSetObject(&aof,&key,o) == 0) goto werr;
- } else if (o->type == REDIS_ZSET) {
+ } else if (o->type == OBJ_ZSET) {
if (rewriteSortedSetObject(&aof,&key,o) == 0) goto werr;
- } else if (o->type == REDIS_HASH) {
+ } else if (o->type == OBJ_HASH) {
if (rewriteHashObject(&aof,&key,o) == 0) goto werr;
} else {
redisPanic("Unknown object type");
diff --git a/src/bitops.c b/src/bitops.c
index 66fa97ef5..0b3e55ef2 100644
--- a/src/bitops.c
+++ b/src/bitops.c
@@ -232,10 +232,10 @@ void setbitCommand(client *c) {
byte = bitoffset >> 3;
o = lookupKeyWrite(c->db,c->argv[1]);
if (o == NULL) {
- o = createObject(REDIS_STRING,sdsnewlen(NULL, byte+1));
+ o = createObject(OBJ_STRING,sdsnewlen(NULL, byte+1));
dbAdd(c->db,c->argv[1],o);
} else {
- if (checkType(c,o,REDIS_STRING)) return;
+ if (checkType(c,o,OBJ_STRING)) return;
o = dbUnshareStringValue(c->db,c->argv[1],o);
o->ptr = sdsgrowzero(o->ptr,byte+1);
}
@@ -267,7 +267,7 @@ void getbitCommand(client *c) {
return;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_STRING)) return;
+ checkType(c,o,OBJ_STRING)) return;
byte = bitoffset >> 3;
bit = 7 - (bitoffset & 0x7);
@@ -330,7 +330,7 @@ void bitopCommand(client *c) {
continue;
}
/* Return an error if one of the keys is not a string. */
- if (checkType(c,o,REDIS_STRING)) {
+ if (checkType(c,o,OBJ_STRING)) {
unsigned long i;
for (i = 0; i < j; i++) {
if (objects[i])
@@ -444,7 +444,7 @@ void bitopCommand(client *c) {
/* Store the computed value into the target key */
if (maxlen) {
- o = createObject(REDIS_STRING,res);
+ o = createObject(OBJ_STRING,res);
setKey(c->db,targetkey,o);
notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"set",targetkey,c->db->id);
decrRefCount(o);
@@ -465,11 +465,11 @@ void bitcountCommand(client *c) {
/* Lookup, check for type, and return 0 for non existing keys. */
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_STRING)) return;
+ checkType(c,o,OBJ_STRING)) return;
/* Set the 'p' pointer to the string, that can be just a stack allocated
* array if our string was integer encoded. */
- if (o->encoding == REDIS_ENCODING_INT) {
+ if (o->encoding == OBJ_ENCODING_INT) {
p = (unsigned char*) llbuf;
strlen = ll2string(llbuf,sizeof(llbuf),(long)o->ptr);
} else {
@@ -534,11 +534,11 @@ void bitposCommand(client *c) {
addReplyLongLong(c, bit ? -1 : 0);
return;
}
- if (checkType(c,o,REDIS_STRING)) return;
+ if (checkType(c,o,OBJ_STRING)) return;
/* Set the 'p' pointer to the string, that can be just a stack allocated
* array if our string was integer encoded. */
- if (o->encoding == REDIS_ENCODING_INT) {
+ if (o->encoding == OBJ_ENCODING_INT) {
p = (unsigned char*) llbuf;
strlen = ll2string(llbuf,sizeof(llbuf),(long)o->ptr);
} else {
diff --git a/src/cluster.c b/src/cluster.c
index a294937c3..ff7c80c2a 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -3832,7 +3832,7 @@ void clusterCommand(client *c) {
robj *o;
sds ci = clusterGenNodesDescription(0);
- o = createObject(REDIS_STRING,ci);
+ o = createObject(OBJ_STRING,ci);
addReplyBulk(c,o);
decrRefCount(o);
} else if (!strcasecmp(c->argv[1]->ptr,"myid") && c->argc == 2) {
@@ -4377,7 +4377,7 @@ void dumpCommand(client *c) {
createDumpPayload(&payload,o);
/* Transfer to the client */
- dumpobj = createObject(REDIS_STRING,payload.io.buffer.ptr);
+ dumpobj = createObject(OBJ_STRING,payload.io.buffer.ptr);
addReplyBulk(c,dumpobj);
decrRefCount(dumpobj);
return;
diff --git a/src/config.c b/src/config.c
index 167ea6fd7..465f8ccb1 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1197,7 +1197,7 @@ void configGetCommand(client *c) {
matches++;
}
if (stringmatch(pattern,"notify-keyspace-events",0)) {
- robj *flagsobj = createObject(REDIS_STRING,
+ robj *flagsobj = createObject(OBJ_STRING,
keyspaceEventsFlagsToString(server.notify_keyspace_events));
addReplyBulkCString(c,"notify-keyspace-events");
@@ -1806,13 +1806,13 @@ int rewriteConfig(char *path) {
rewriteConfigNumericalOption(state,"latency-monitor-threshold",server.latency_monitor_threshold,CONFIG_DEFAULT_LATENCY_MONITOR_THRESHOLD);
rewriteConfigNumericalOption(state,"slowlog-max-len",server.slowlog_max_len,REDIS_SLOWLOG_MAX_LEN);
rewriteConfigNotifykeyspaceeventsOption(state);
- rewriteConfigNumericalOption(state,"hash-max-ziplist-entries",server.hash_max_ziplist_entries,REDIS_HASH_MAX_ZIPLIST_ENTRIES);
- rewriteConfigNumericalOption(state,"hash-max-ziplist-value",server.hash_max_ziplist_value,REDIS_HASH_MAX_ZIPLIST_VALUE);
- rewriteConfigNumericalOption(state,"list-max-ziplist-size",server.list_max_ziplist_size,REDIS_LIST_MAX_ZIPLIST_SIZE);
- rewriteConfigNumericalOption(state,"list-compress-depth",server.list_compress_depth,REDIS_LIST_COMPRESS_DEPTH);
- rewriteConfigNumericalOption(state,"set-max-intset-entries",server.set_max_intset_entries,REDIS_SET_MAX_INTSET_ENTRIES);
- rewriteConfigNumericalOption(state,"zset-max-ziplist-entries",server.zset_max_ziplist_entries,REDIS_ZSET_MAX_ZIPLIST_ENTRIES);
- rewriteConfigNumericalOption(state,"zset-max-ziplist-value",server.zset_max_ziplist_value,REDIS_ZSET_MAX_ZIPLIST_VALUE);
+ rewriteConfigNumericalOption(state,"hash-max-ziplist-entries",server.hash_max_ziplist_entries,OBJ_HASH_MAX_ZIPLIST_ENTRIES);
+ rewriteConfigNumericalOption(state,"hash-max-ziplist-value",server.hash_max_ziplist_value,OBJ_HASH_MAX_ZIPLIST_VALUE);
+ rewriteConfigNumericalOption(state,"list-max-ziplist-size",server.list_max_ziplist_size,OBJ_LIST_MAX_ZIPLIST_SIZE);
+ rewriteConfigNumericalOption(state,"list-compress-depth",server.list_compress_depth,OBJ_LIST_COMPRESS_DEPTH);
+ rewriteConfigNumericalOption(state,"set-max-intset-entries",server.set_max_intset_entries,OBJ_SET_MAX_INTSET_ENTRIES);
+ rewriteConfigNumericalOption(state,"zset-max-ziplist-entries",server.zset_max_ziplist_entries,OBJ_ZSET_MAX_ZIPLIST_ENTRIES);
+ rewriteConfigNumericalOption(state,"zset-max-ziplist-value",server.zset_max_ziplist_value,OBJ_ZSET_MAX_ZIPLIST_VALUE);
rewriteConfigNumericalOption(state,"hll-sparse-max-bytes",server.hll_sparse_max_bytes,CONFIG_DEFAULT_HLL_SPARSE_MAX_BYTES);
rewriteConfigYesNoOption(state,"activerehashing",server.activerehashing,CONFIG_DEFAULT_ACTIVE_REHASHING);
rewriteConfigClientoutputbufferlimitOption(state);
diff --git a/src/db.c b/src/db.c
index 406d7b4ce..55b725f78 100644
--- a/src/db.c
+++ b/src/db.c
@@ -120,7 +120,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
int retval = dictAdd(db->dict, copy, val);
redisAssertWithInfo(NULL,key,retval == REDIS_OK);
- if (val->type == REDIS_LIST) signalListAsReady(db, key);
+ if (val->type == OBJ_LIST) signalListAsReady(db, key);
if (server.cluster_enabled) slotToKeyAdd(key);
}
@@ -217,15 +217,15 @@ int dbDelete(redisDb *db, robj *key) {
* in 'db', the usage pattern looks like this:
*
* o = lookupKeyWrite(db,key);
- * if (checkType(c,o,REDIS_STRING)) return;
+ * if (checkType(c,o,OBJ_STRING)) return;
* o = dbUnshareStringValue(db,key,o);
*
* At this point the caller is ready to modify the object, for example
* using an sdscat() call to append some data, or anything else.
*/
robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) {
- redisAssert(o->type == REDIS_STRING);
- if (o->refcount != 1 || o->encoding != REDIS_ENCODING_RAW) {
+ redisAssert(o->type == OBJ_STRING);
+ if (o->refcount != 1 || o->encoding != OBJ_ENCODING_RAW) {
robj *decoded = getDecodedObject(o);
o = createRawStringObject(decoded->ptr, sdslen(decoded->ptr));
decrRefCount(decoded);
@@ -399,15 +399,15 @@ void scanCallback(void *privdata, const dictEntry *de) {
if (o == NULL) {
sds sdskey = dictGetKey(de);
key = createStringObject(sdskey, sdslen(sdskey));
- } else if (o->type == REDIS_SET) {
+ } else if (o->type == OBJ_SET) {
key = dictGetKey(de);
incrRefCount(key);
- } else if (o->type == REDIS_HASH) {
+ } else if (o->type == OBJ_HASH) {
key = dictGetKey(de);
incrRefCount(key);
val = dictGetVal(de);
incrRefCount(val);
- } else if (o->type == REDIS_ZSET) {
+ } else if (o->type == OBJ_ZSET) {
key = dictGetKey(de);
incrRefCount(key);
val = createStringObjectFromLongDouble(*(double*)dictGetVal(de),0);
@@ -460,8 +460,8 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
/* Object must be NULL (to iterate keys names), or the type of the object
* must be Set, Sorted Set, or Hash. */
- redisAssert(o == NULL || o->type == REDIS_SET || o->type == REDIS_HASH ||
- o->type == REDIS_ZSET);
+ redisAssert(o == NULL || o->type == OBJ_SET || o->type == OBJ_HASH ||
+ o->type == OBJ_ZSET);
/* Set i to the first option argument. The previous one is the cursor. */
i = (o == NULL) ? 2 : 3; /* Skip the key argument if needed. */
@@ -509,12 +509,12 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
ht = NULL;
if (o == NULL) {
ht = c->db->dict;
- } else if (o->type == REDIS_SET && o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->type == OBJ_SET && o->encoding == OBJ_ENCODING_HT) {
ht = o->ptr;
- } else if (o->type == REDIS_HASH && o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->type == OBJ_HASH && o->encoding == OBJ_ENCODING_HT) {
ht = o->ptr;
count *= 2; /* We return key / value for this type. */
- } else if (o->type == REDIS_ZSET && o->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (o->type == OBJ_ZSET && o->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = o->ptr;
ht = zs->dict;
count *= 2; /* We return key / value for this type. */
@@ -538,14 +538,14 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
} while (cursor &&
maxiterations-- &&
listLength(keys) < (unsigned long)count);
- } else if (o->type == REDIS_SET) {
+ } else if (o->type == OBJ_SET) {
int pos = 0;
int64_t ll;
while(intsetGet(o->ptr,pos++,&ll))
listAddNodeTail(keys,createStringObjectFromLongLong(ll));
cursor = 0;
- } else if (o->type == REDIS_HASH || o->type == REDIS_ZSET) {
+ } else if (o->type == OBJ_HASH || o->type == OBJ_ZSET) {
unsigned char *p = ziplistIndex(o->ptr,0);
unsigned char *vstr;
unsigned int vlen;
@@ -579,7 +579,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
char buf[REDIS_LONGSTR_SIZE];
int len;
- redisAssert(kobj->encoding == REDIS_ENCODING_INT);
+ redisAssert(kobj->encoding == OBJ_ENCODING_INT);
len = ll2string(buf,sizeof(buf),(long)kobj->ptr);
if (!stringmatchlen(pat, patlen, buf, len, 0)) filter = 1;
}
@@ -597,7 +597,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
/* If this is a hash or a sorted set, we have a flat list of
* key-value elements, so if this element was filtered, remove the
* value, or skip it if it was not filtered: we only match keys. */
- if (o && (o->type == REDIS_ZSET || o->type == REDIS_HASH)) {
+ if (o && (o->type == OBJ_ZSET || o->type == OBJ_HASH)) {
node = nextnode;
nextnode = listNextNode(node);
if (filter) {
@@ -650,11 +650,11 @@ void typeCommand(client *c) {
type = "none";
} else {
switch(o->type) {
- case REDIS_STRING: type = "string"; break;
- case REDIS_LIST: type = "list"; break;
- case REDIS_SET: type = "set"; break;
- case REDIS_ZSET: type = "zset"; break;
- case REDIS_HASH: type = "hash"; break;
+ case OBJ_STRING: type = "string"; break;
+ case OBJ_LIST: type = "list"; break;
+ case OBJ_SET: type = "set"; break;
+ case OBJ_ZSET: type = "zset"; break;
+ case OBJ_HASH: type = "hash"; break;
default: type = "unknown"; break;
}
}
diff --git a/src/debug.c b/src/debug.c
index 1e87300eb..dc77d2c78 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -150,9 +150,9 @@ void computeDatasetDigest(unsigned char *final) {
expiretime = getExpire(db,keyobj);
/* Save the key and associated value */
- if (o->type == REDIS_STRING) {
+ if (o->type == OBJ_STRING) {
mixObjectDigest(digest,o);
- } else if (o->type == REDIS_LIST) {
+ } else if (o->type == OBJ_LIST) {
listTypeIterator *li = listTypeInitIterator(o,0,REDIS_TAIL);
listTypeEntry entry;
while(listTypeNext(li,&entry)) {
@@ -161,7 +161,7 @@ void computeDatasetDigest(unsigned char *final) {
decrRefCount(eleobj);
}
listTypeReleaseIterator(li);
- } else if (o->type == REDIS_SET) {
+ } else if (o->type == OBJ_SET) {
setTypeIterator *si = setTypeInitIterator(o);
robj *ele;
while((ele = setTypeNextObject(si)) != NULL) {
@@ -169,10 +169,10 @@ void computeDatasetDigest(unsigned char *final) {
decrRefCount(ele);
}
setTypeReleaseIterator(si);
- } else if (o->type == REDIS_ZSET) {
+ } else if (o->type == OBJ_ZSET) {
unsigned char eledigest[20];
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = o->ptr;
unsigned char *eptr, *sptr;
unsigned char *vstr;
@@ -202,7 +202,7 @@ void computeDatasetDigest(unsigned char *final) {
xorDigest(digest,eledigest,20);
zzlNext(zl,&eptr,&sptr);
}
- } else if (o->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (o->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = o->ptr;
dictIterator *di = dictGetIterator(zs->dict);
dictEntry *de;
@@ -221,7 +221,7 @@ void computeDatasetDigest(unsigned char *final) {
} else {
redisPanic("Unknown sorted set encoding");
}
- } else if (o->type == REDIS_HASH) {
+ } else if (o->type == OBJ_HASH) {
hashTypeIterator *hi;
robj *obj;
@@ -230,10 +230,10 @@ void computeDatasetDigest(unsigned char *final) {
unsigned char eledigest[20];
memset(eledigest,0,20);
- obj = hashTypeCurrentObject(hi,REDIS_HASH_KEY);
+ obj = hashTypeCurrentObject(hi,OBJ_HASH_KEY);
mixObjectDigest(eledigest,obj);
decrRefCount(obj);
- obj = hashTypeCurrentObject(hi,REDIS_HASH_VALUE);
+ obj = hashTypeCurrentObject(hi,OBJ_HASH_VALUE);
mixObjectDigest(eledigest,obj);
decrRefCount(obj);
xorDigest(digest,eledigest,20);
@@ -302,7 +302,7 @@ void debugCommand(client *c) {
strenc = strEncoding(val->encoding);
char extra[128] = {0};
- if (val->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (val->encoding == OBJ_ENCODING_QUICKLIST) {
char *nextra = extra;
int remaining = sizeof(extra);
quicklist *ql = val->ptr;
@@ -353,7 +353,7 @@ void debugCommand(client *c) {
val = dictGetVal(de);
key = dictGetKey(de);
- if (val->type != REDIS_STRING || !sdsEncodedObject(val)) {
+ if (val->type != OBJ_STRING || !sdsEncodedObject(val)) {
addReplyError(c,"Not an sds encoded string.");
} else {
addReplyStatusFormat(c,
@@ -495,7 +495,7 @@ void _redisAssertPrintClientInfo(client *c) {
char buf[128];
char *arg;
- if (c->argv[j]->type == REDIS_STRING && sdsEncodedObject(c->argv[j])) {
+ if (c->argv[j]->type == OBJ_STRING && sdsEncodedObject(c->argv[j])) {
arg = (char*) c->argv[j]->ptr;
} else {
snprintf(buf,sizeof(buf),"Object type: %d, encoding: %d",
@@ -511,22 +511,22 @@ void serverLogObjectDebugInfo(robj *o) {
serverLog(REDIS_WARNING,"Object type: %d", o->type);
serverLog(REDIS_WARNING,"Object encoding: %d", o->encoding);
serverLog(REDIS_WARNING,"Object refcount: %d", o->refcount);
- if (o->type == REDIS_STRING && sdsEncodedObject(o)) {
+ if (o->type == OBJ_STRING && sdsEncodedObject(o)) {
serverLog(REDIS_WARNING,"Object raw string len: %zu", sdslen(o->ptr));
if (sdslen(o->ptr) < 4096) {
sds repr = sdscatrepr(sdsempty(),o->ptr,sdslen(o->ptr));
serverLog(REDIS_WARNING,"Object raw string content: %s", repr);
sdsfree(repr);
}
- } else if (o->type == REDIS_LIST) {
+ } else if (o->type == OBJ_LIST) {
serverLog(REDIS_WARNING,"List length: %d", (int) listTypeLength(o));
- } else if (o->type == REDIS_SET) {
+ } else if (o->type == OBJ_SET) {
serverLog(REDIS_WARNING,"Set size: %d", (int) setTypeSize(o));
- } else if (o->type == REDIS_HASH) {
+ } else if (o->type == OBJ_HASH) {
serverLog(REDIS_WARNING,"Hash size: %d", (int) hashTypeLength(o));
- } else if (o->type == REDIS_ZSET) {
+ } else if (o->type == OBJ_ZSET) {
serverLog(REDIS_WARNING,"Sorted set size: %d", (int) zsetLength(o));
- if (o->encoding == REDIS_ENCODING_SKIPLIST)
+ if (o->encoding == OBJ_ENCODING_SKIPLIST)
serverLog(REDIS_WARNING,"Skiplist level: %d", (int) ((zset*)o->ptr)->zsl->level);
}
}
diff --git a/src/geo.c b/src/geo.c
index a0b2ea370..6671806bd 100644
--- a/src/geo.c
+++ b/src/geo.c
@@ -221,7 +221,7 @@ int geoGetPointsInRange(robj *zobj, double min, double max, double lon, double l
size_t origincount = ga->used;
sds member;
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
unsigned char *vstr = NULL;
@@ -250,7 +250,7 @@ int geoGetPointsInRange(robj *zobj, double min, double max, double lon, double l
== REDIS_ERR) sdsfree(member);
zzlNext(zl, &eptr, &sptr);
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *ln;
@@ -266,7 +266,7 @@ int geoGetPointsInRange(robj *zobj, double min, double max, double lon, double l
if (!zslValueLteMax(ln->score, &range))
break;
- member = (o->encoding == REDIS_ENCODING_INT) ?
+ member = (o->encoding == OBJ_ENCODING_INT) ?
sdsfromlonglong((long)o->ptr) :
sdsdup(o->ptr);
if (geoAppendIfWithinRadius(ga,lon,lat,radius,ln->score,member)
@@ -397,7 +397,7 @@ void geoaddCommand(client *c) {
GeoHashBits hash;
geohashEncodeWGS84(xy[0], xy[1], GEO_STEP_MAX, &hash);
GeoHashFix52Bits bits = geohashAlign52Bits(hash);
- robj *score = createObject(REDIS_STRING, sdsfromlonglong(bits));
+ robj *score = createObject(OBJ_STRING, sdsfromlonglong(bits));
robj *val = c->argv[2 + i * 3 + 2];
argv[2+i*2] = score;
argv[3+i*2] = val;
@@ -425,7 +425,7 @@ void georadiusGeneric(client *c, int type) {
/* Look up the requested zset */
robj *zobj = NULL;
if ((zobj = lookupKeyReadOrReply(c, key, shared.emptymultibulk)) == NULL ||
- checkType(c, zobj, REDIS_ZSET)) {
+ checkType(c, zobj, OBJ_ZSET)) {
return;
}
@@ -589,7 +589,7 @@ void geohashCommand(client *c) {
/* Look up the requested zset */
robj *zobj = NULL;
if ((zobj = lookupKeyReadOrReply(c, c->argv[1], shared.emptymultibulk))
- == NULL || checkType(c, zobj, REDIS_ZSET)) return;
+ == NULL || checkType(c, zobj, OBJ_ZSET)) return;
/* Geohash elements one after the other, using a null bulk reply for
* missing elements. */
@@ -643,7 +643,7 @@ void geoposCommand(client *c) {
/* Look up the requested zset */
robj *zobj = NULL;
if ((zobj = lookupKeyReadOrReply(c, c->argv[1], shared.emptymultibulk))
- == NULL || checkType(c, zobj, REDIS_ZSET)) return;
+ == NULL || checkType(c, zobj, OBJ_ZSET)) return;
/* Report elements one after the other, using a null bulk reply for
* missing elements. */
@@ -686,7 +686,7 @@ void geodistCommand(client *c) {
/* Look up the requested zset */
robj *zobj = NULL;
if ((zobj = lookupKeyReadOrReply(c, c->argv[1], shared.emptybulk))
- == NULL || checkType(c, zobj, REDIS_ZSET)) return;
+ == NULL || checkType(c, zobj, OBJ_ZSET)) return;
/* Get the scores. We need both otherwise NULL is returned. */
double score1, score2, xyxy[4];
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 6405f5ba9..fb56e5538 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -1111,7 +1111,7 @@ robj *createHLLObject(void) {
redisAssert((p-(uint8_t*)s) == sparselen);
/* Create the actual object. */
- o = createObject(REDIS_STRING,s);
+ o = createObject(OBJ_STRING,s);
hdr = o->ptr;
memcpy(hdr->magic,"HYLL",4);
hdr->encoding = HLL_SPARSE;
@@ -1125,7 +1125,7 @@ int isHLLObjectOrReply(client *c, robj *o) {
struct hllhdr *hdr;
/* Key exists, check type */
- if (checkType(c,o,REDIS_STRING))
+ if (checkType(c,o,OBJ_STRING))
return REDIS_ERR; /* Error already sent. */
if (stringObjectLen(o) < sizeof(*hdr)) goto invalid;
diff --git a/src/networking.c b/src/networking.c
index 277c400fc..545441be2 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -44,10 +44,10 @@ size_t sdsZmallocSize(sds s) {
/* Return the amount of memory used by the sds string at object->ptr
* for a string object. */
size_t getStringObjectSdsUsedMemory(robj *o) {
- redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
+ redisAssertWithInfo(NULL,o,o->type == OBJ_STRING);
switch(o->encoding) {
- case REDIS_ENCODING_RAW: return sdsZmallocSize(o->ptr);
- case REDIS_ENCODING_EMBSTR: return zmalloc_size(o)-sizeof(robj);
+ case OBJ_ENCODING_RAW: return sdsZmallocSize(o->ptr);
+ case OBJ_ENCODING_EMBSTR: return zmalloc_size(o)-sizeof(robj);
default: return 0; /* Just integer encoding for now. */
}
}
@@ -232,7 +232,7 @@ void _addReplyObjectToList(client *c, robj *o) {
/* Append to this object when possible. */
if (tail->ptr != NULL &&
- tail->encoding == REDIS_ENCODING_RAW &&
+ tail->encoding == OBJ_ENCODING_RAW &&
sdslen(tail->ptr)+sdslen(o->ptr) <= REDIS_REPLY_CHUNK_BYTES)
{
c->reply_bytes -= sdsZmallocSize(tail->ptr);
@@ -259,13 +259,13 @@ void _addReplySdsToList(client *c, sds s) {
}
if (listLength(c->reply) == 0) {
- listAddNodeTail(c->reply,createObject(REDIS_STRING,s));
+ listAddNodeTail(c->reply,createObject(OBJ_STRING,s));
c->reply_bytes += sdsZmallocSize(s);
} else {
tail = listNodeValue(listLast(c->reply));
/* Append to this object when possible. */
- if (tail->ptr != NULL && tail->encoding == REDIS_ENCODING_RAW &&
+ if (tail->ptr != NULL && tail->encoding == OBJ_ENCODING_RAW &&
sdslen(tail->ptr)+sdslen(s) <= REDIS_REPLY_CHUNK_BYTES)
{
c->reply_bytes -= sdsZmallocSize(tail->ptr);
@@ -274,7 +274,7 @@ void _addReplySdsToList(client *c, sds s) {
c->reply_bytes += sdsZmallocSize(tail->ptr);
sdsfree(s);
} else {
- listAddNodeTail(c->reply,createObject(REDIS_STRING,s));
+ listAddNodeTail(c->reply,createObject(OBJ_STRING,s));
c->reply_bytes += sdsZmallocSize(s);
}
}
@@ -295,7 +295,7 @@ void _addReplyStringToList(client *c, const char *s, size_t len) {
tail = listNodeValue(listLast(c->reply));
/* Append to this object when possible. */
- if (tail->ptr != NULL && tail->encoding == REDIS_ENCODING_RAW &&
+ if (tail->ptr != NULL && tail->encoding == OBJ_ENCODING_RAW &&
sdslen(tail->ptr)+len <= REDIS_REPLY_CHUNK_BYTES)
{
c->reply_bytes -= sdsZmallocSize(tail->ptr);
@@ -330,7 +330,7 @@ void addReply(client *c, robj *obj) {
if (sdsEncodedObject(obj)) {
if (_addReplyToBuffer(c,obj->ptr,sdslen(obj->ptr)) != REDIS_OK)
_addReplyObjectToList(c,obj);
- } else if (obj->encoding == REDIS_ENCODING_INT) {
+ } else if (obj->encoding == OBJ_ENCODING_INT) {
/* Optimization: if there is room in the static buffer for 32 bytes
* (more than the max chars a 64 bit integer can take as string) we
* avoid decoding the object and go for the lower level approach. */
@@ -425,7 +425,7 @@ void *addDeferredMultiBulkLength(client *c) {
* ready to be sent, since we are sure that before returning to the
* event loop setDeferredMultiBulkLength() will be called. */
if (prepareClientToWrite(c) != REDIS_OK) return NULL;
- listAddNodeTail(c->reply,createObject(REDIS_STRING,NULL));
+ listAddNodeTail(c->reply,createObject(OBJ_STRING,NULL));
return listLast(c->reply);
}
@@ -439,7 +439,7 @@ void setDeferredMultiBulkLength(client *c, void *node, long length) {
len = listNodeValue(ln);
len->ptr = sdscatprintf(sdsempty(),"*%ld\r\n",length);
- len->encoding = REDIS_ENCODING_RAW; /* in case it was an EMBSTR. */
+ len->encoding = OBJ_ENCODING_RAW; /* in case it was an EMBSTR. */
c->reply_bytes += sdsZmallocSize(len->ptr);
if (ln->next != NULL) {
next = listNodeValue(ln->next);
@@ -970,7 +970,7 @@ int processInlineBuffer(client *c) {
/* Create redis objects for all arguments. */
for (c->argc = 0, j = 0; j < argc; j++) {
if (sdslen(argv[j])) {
- c->argv[c->argc] = createObject(REDIS_STRING,argv[j]);
+ c->argv[c->argc] = createObject(OBJ_STRING,argv[j]);
c->argc++;
} else {
sdsfree(argv[j]);
@@ -1104,7 +1104,7 @@ int processMultibulkBuffer(client *c) {
c->bulklen >= REDIS_MBULK_BIG_ARG &&
(signed) sdslen(c->querybuf) == c->bulklen+2)
{
- c->argv[c->argc++] = createObject(REDIS_STRING,c->querybuf);
+ c->argv[c->argc++] = createObject(OBJ_STRING,c->querybuf);
sdsIncrLen(c->querybuf,-2); /* remove CRLF */
c->querybuf = sdsempty();
/* Assume that if we saw a fat argument we'll see another one
diff --git a/src/notify.c b/src/notify.c
index 6c915e659..9af261ff0 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -110,7 +110,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {
chan = sdscatlen(chan, buf, len);
chan = sdscatlen(chan, "__:", 3);
chan = sdscatsds(chan, key->ptr);
- chanobj = createObject(REDIS_STRING, chan);
+ chanobj = createObject(OBJ_STRING, chan);
pubsubPublishMessage(chanobj, eventobj);
decrRefCount(chanobj);
}
@@ -122,7 +122,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {
chan = sdscatlen(chan, buf, len);
chan = sdscatlen(chan, "__:", 3);
chan = sdscatsds(chan, eventobj->ptr);
- chanobj = createObject(REDIS_STRING, chan);
+ chanobj = createObject(OBJ_STRING, chan);
pubsubPublishMessage(chanobj, key);
decrRefCount(chanobj);
}
diff --git a/src/object.c b/src/object.c
index d8fcf1658..d84f388c2 100644
--- a/src/object.c
+++ b/src/object.c
@@ -39,7 +39,7 @@
robj *createObject(int type, void *ptr) {
robj *o = zmalloc(sizeof(*o));
o->type = type;
- o->encoding = REDIS_ENCODING_RAW;
+ o->encoding = OBJ_ENCODING_RAW;
o->ptr = ptr;
o->refcount = 1;
@@ -48,21 +48,21 @@ robj *createObject(int type, void *ptr) {
return o;
}
-/* Create a string object with encoding REDIS_ENCODING_RAW, that is a plain
+/* Create a string object with encoding OBJ_ENCODING_RAW, that is a plain
* string object where o->ptr points to a proper sds string. */
robj *createRawStringObject(const char *ptr, size_t len) {
- return createObject(REDIS_STRING,sdsnewlen(ptr,len));
+ return createObject(OBJ_STRING,sdsnewlen(ptr,len));
}
-/* Create a string object with encoding REDIS_ENCODING_EMBSTR, that is
+/* Create a string object with encoding OBJ_ENCODING_EMBSTR, that is
* an object where the sds string is actually an unmodifiable string
* allocated in the same chunk as the object itself. */
robj *createEmbeddedStringObject(const char *ptr, size_t len) {
robj *o = zmalloc(sizeof(robj)+sizeof(struct sdshdr8)+len+1);
struct sdshdr8 *sh = (void*)(o+1);
- o->type = REDIS_STRING;
- o->encoding = REDIS_ENCODING_EMBSTR;
+ o->type = OBJ_STRING;
+ o->encoding = OBJ_ENCODING_EMBSTR;
o->ptr = sh+1;
o->refcount = 1;
o->lru = LRU_CLOCK();
@@ -85,9 +85,9 @@ robj *createEmbeddedStringObject(const char *ptr, size_t len) {
*
* The current limit of 39 is chosen so that the biggest string object
* we allocate as EMBSTR will still fit into the 64 byte arena of jemalloc. */
-#define REDIS_ENCODING_EMBSTR_SIZE_LIMIT 44
+#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 44
robj *createStringObject(const char *ptr, size_t len) {
- if (len <= REDIS_ENCODING_EMBSTR_SIZE_LIMIT)
+ if (len <= OBJ_ENCODING_EMBSTR_SIZE_LIMIT)
return createEmbeddedStringObject(ptr,len);
else
return createRawStringObject(ptr,len);
@@ -100,11 +100,11 @@ robj *createStringObjectFromLongLong(long long value) {
o = shared.integers[value];
} else {
if (value >= LONG_MIN && value <= LONG_MAX) {
- o = createObject(REDIS_STRING, NULL);
- o->encoding = REDIS_ENCODING_INT;
+ o = createObject(OBJ_STRING, NULL);
+ o->encoding = OBJ_ENCODING_INT;
o->ptr = (void*)((long)value);
} else {
- o = createObject(REDIS_STRING,sdsfromlonglong(value));
+ o = createObject(OBJ_STRING,sdsfromlonglong(value));
}
}
return o;
@@ -163,16 +163,16 @@ robj *createStringObjectFromLongDouble(long double value, int humanfriendly) {
robj *dupStringObject(robj *o) {
robj *d;
- redisAssert(o->type == REDIS_STRING);
+ redisAssert(o->type == OBJ_STRING);
switch(o->encoding) {
- case REDIS_ENCODING_RAW:
+ case OBJ_ENCODING_RAW:
return createRawStringObject(o->ptr,sdslen(o->ptr));
- case REDIS_ENCODING_EMBSTR:
+ case OBJ_ENCODING_EMBSTR:
return createEmbeddedStringObject(o->ptr,sdslen(o->ptr));
- case REDIS_ENCODING_INT:
- d = createObject(REDIS_STRING, NULL);
- d->encoding = REDIS_ENCODING_INT;
+ case OBJ_ENCODING_INT:
+ d = createObject(OBJ_STRING, NULL);
+ d->encoding = OBJ_ENCODING_INT;
d->ptr = o->ptr;
return d;
default:
@@ -183,36 +183,36 @@ robj *dupStringObject(robj *o) {
robj *createQuicklistObject(void) {
quicklist *l = quicklistCreate();
- robj *o = createObject(REDIS_LIST,l);
- o->encoding = REDIS_ENCODING_QUICKLIST;
+ robj *o = createObject(OBJ_LIST,l);
+ o->encoding = OBJ_ENCODING_QUICKLIST;
return o;
}
robj *createZiplistObject(void) {
unsigned char *zl = ziplistNew();
- robj *o = createObject(REDIS_LIST,zl);
- o->encoding = REDIS_ENCODING_ZIPLIST;
+ robj *o = createObject(OBJ_LIST,zl);
+ o->encoding = OBJ_ENCODING_ZIPLIST;
return o;
}
robj *createSetObject(void) {
dict *d = dictCreate(&setDictType,NULL);
- robj *o = createObject(REDIS_SET,d);
- o->encoding = REDIS_ENCODING_HT;
+ robj *o = createObject(OBJ_SET,d);
+ o->encoding = OBJ_ENCODING_HT;
return o;
}
robj *createIntsetObject(void) {
intset *is = intsetNew();
- robj *o = createObject(REDIS_SET,is);
- o->encoding = REDIS_ENCODING_INTSET;
+ robj *o = createObject(OBJ_SET,is);
+ o->encoding = OBJ_ENCODING_INTSET;
return o;
}
robj *createHashObject(void) {
unsigned char *zl = ziplistNew();
- robj *o = createObject(REDIS_HASH, zl);
- o->encoding = REDIS_ENCODING_ZIPLIST;
+ robj *o = createObject(OBJ_HASH, zl);
+ o->encoding = OBJ_ENCODING_ZIPLIST;
return o;
}
@@ -222,27 +222,27 @@ robj *createZsetObject(void) {
zs->dict = dictCreate(&zsetDictType,NULL);
zs->zsl = zslCreate();
- o = createObject(REDIS_ZSET,zs);
- o->encoding = REDIS_ENCODING_SKIPLIST;
+ o = createObject(OBJ_ZSET,zs);
+ o->encoding = OBJ_ENCODING_SKIPLIST;
return o;
}
robj *createZsetZiplistObject(void) {
unsigned char *zl = ziplistNew();
- robj *o = createObject(REDIS_ZSET,zl);
- o->encoding = REDIS_ENCODING_ZIPLIST;
+ robj *o = createObject(OBJ_ZSET,zl);
+ o->encoding = OBJ_ENCODING_ZIPLIST;
return o;
}
void freeStringObject(robj *o) {
- if (o->encoding == REDIS_ENCODING_RAW) {
+ if (o->encoding == OBJ_ENCODING_RAW) {
sdsfree(o->ptr);
}
}
void freeListObject(robj *o) {
switch (o->encoding) {
- case REDIS_ENCODING_QUICKLIST:
+ case OBJ_ENCODING_QUICKLIST:
quicklistRelease(o->ptr);
break;
default:
@@ -252,10 +252,10 @@ void freeListObject(robj *o) {
void freeSetObject(robj *o) {
switch (o->encoding) {
- case REDIS_ENCODING_HT:
+ case OBJ_ENCODING_HT:
dictRelease((dict*) o->ptr);
break;
- case REDIS_ENCODING_INTSET:
+ case OBJ_ENCODING_INTSET:
zfree(o->ptr);
break;
default:
@@ -266,13 +266,13 @@ void freeSetObject(robj *o) {
void freeZsetObject(robj *o) {
zset *zs;
switch (o->encoding) {
- case REDIS_ENCODING_SKIPLIST:
+ case OBJ_ENCODING_SKIPLIST:
zs = o->ptr;
dictRelease(zs->dict);
zslFree(zs->zsl);
zfree(zs);
break;
- case REDIS_ENCODING_ZIPLIST:
+ case OBJ_ENCODING_ZIPLIST:
zfree(o->ptr);
break;
default:
@@ -282,10 +282,10 @@ void freeZsetObject(robj *o) {
void freeHashObject(robj *o) {
switch (o->encoding) {
- case REDIS_ENCODING_HT:
+ case OBJ_ENCODING_HT:
dictRelease((dict*) o->ptr);
break;
- case REDIS_ENCODING_ZIPLIST:
+ case OBJ_ENCODING_ZIPLIST:
zfree(o->ptr);
break;
default:
@@ -302,11 +302,11 @@ void decrRefCount(robj *o) {
if (o->refcount <= 0) redisPanic("decrRefCount against refcount <= 0");
if (o->refcount == 1) {
switch(o->type) {
- case REDIS_STRING: freeStringObject(o); break;
- case REDIS_LIST: freeListObject(o); break;
- case REDIS_SET: freeSetObject(o); break;
- case REDIS_ZSET: freeZsetObject(o); break;
- case REDIS_HASH: freeHashObject(o); break;
+ case OBJ_STRING: freeStringObject(o); break;
+ case OBJ_LIST: freeListObject(o); break;
+ case OBJ_SET: freeSetObject(o); break;
+ case OBJ_ZSET: freeZsetObject(o); break;
+ case OBJ_HASH: freeHashObject(o); break;
default: redisPanic("Unknown object type"); break;
}
zfree(o);
@@ -348,8 +348,8 @@ int checkType(client *c, robj *o, int type) {
}
int isObjectRepresentableAsLongLong(robj *o, long long *llval) {
- redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
- if (o->encoding == REDIS_ENCODING_INT) {
+ redisAssertWithInfo(NULL,o,o->type == OBJ_STRING);
+ if (o->encoding == OBJ_ENCODING_INT) {
if (llval) *llval = (long) o->ptr;
return REDIS_OK;
} else {
@@ -367,7 +367,7 @@ robj *tryObjectEncoding(robj *o) {
* in this function. Other types use encoded memory efficient
* representations but are handled by the commands implementing
* the type. */
- redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
+ redisAssertWithInfo(NULL,o,o->type == OBJ_STRING);
/* We try some specialized encoding only for objects that are
* RAW or EMBSTR encoded, in other words objects that are still
@@ -398,8 +398,8 @@ robj *tryObjectEncoding(robj *o) {
incrRefCount(shared.integers[value]);
return shared.integers[value];
} else {
- if (o->encoding == REDIS_ENCODING_RAW) sdsfree(o->ptr);
- o->encoding = REDIS_ENCODING_INT;
+ if (o->encoding == OBJ_ENCODING_RAW) sdsfree(o->ptr);
+ o->encoding = OBJ_ENCODING_INT;
o->ptr = (void*) value;
return o;
}
@@ -409,10 +409,10 @@ robj *tryObjectEncoding(robj *o) {
* try the EMBSTR encoding which is more efficient.
* In this representation the object and the SDS string are allocated
* in the same chunk of memory to save space and cache misses. */
- if (len <= REDIS_ENCODING_EMBSTR_SIZE_LIMIT) {
+ if (len <= OBJ_ENCODING_EMBSTR_SIZE_LIMIT) {
robj *emb;
- if (o->encoding == REDIS_ENCODING_EMBSTR) return o;
+ if (o->encoding == OBJ_ENCODING_EMBSTR) return o;
emb = createEmbeddedStringObject(s,sdslen(s));
decrRefCount(o);
return emb;
@@ -426,8 +426,8 @@ robj *tryObjectEncoding(robj *o) {
*
* We do that only for relatively large strings as this branch
* is only entered if the length of the string is greater than
- * REDIS_ENCODING_EMBSTR_SIZE_LIMIT. */
- if (o->encoding == REDIS_ENCODING_RAW &&
+ * OBJ_ENCODING_EMBSTR_SIZE_LIMIT. */
+ if (o->encoding == OBJ_ENCODING_RAW &&
sdsavail(s) > len/10)
{
o->ptr = sdsRemoveFreeSpace(o->ptr);
@@ -446,7 +446,7 @@ robj *getDecodedObject(robj *o) {
incrRefCount(o);
return o;
}
- if (o->type == REDIS_STRING && o->encoding == REDIS_ENCODING_INT) {
+ if (o->type == OBJ_STRING && o->encoding == OBJ_ENCODING_INT) {
char buf[32];
ll2string(buf,32,(long)o->ptr);
@@ -469,7 +469,7 @@ robj *getDecodedObject(robj *o) {
#define REDIS_COMPARE_COLL (1<<1)
int compareStringObjectsWithFlags(robj *a, robj *b, int flags) {
- redisAssertWithInfo(NULL,a,a->type == REDIS_STRING && b->type == REDIS_STRING);
+ redisAssertWithInfo(NULL,a,a->type == OBJ_STRING && b->type == OBJ_STRING);
char bufa[128], bufb[128], *astr, *bstr;
size_t alen, blen, minlen;
@@ -515,8 +515,8 @@ int collateStringObjects(robj *a, robj *b) {
* this function is faster then checking for (compareStringObject(a,b) == 0)
* because it can perform some more optimization. */
int equalStringObjects(robj *a, robj *b) {
- if (a->encoding == REDIS_ENCODING_INT &&
- b->encoding == REDIS_ENCODING_INT){
+ if (a->encoding == OBJ_ENCODING_INT &&
+ b->encoding == OBJ_ENCODING_INT){
/* If both strings are integer encoded just check if the stored
* long is the same. */
return a->ptr == b->ptr;
@@ -526,7 +526,7 @@ int equalStringObjects(robj *a, robj *b) {
}
size_t stringObjectLen(robj *o) {
- redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
+ redisAssertWithInfo(NULL,o,o->type == OBJ_STRING);
if (sdsEncodedObject(o)) {
return sdslen(o->ptr);
} else {
@@ -541,7 +541,7 @@ int getDoubleFromObject(robj *o, double *target) {
if (o == NULL) {
value = 0;
} else {
- redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
+ redisAssertWithInfo(NULL,o,o->type == OBJ_STRING);
if (sdsEncodedObject(o)) {
errno = 0;
value = strtod(o->ptr, &eptr);
@@ -552,7 +552,7 @@ int getDoubleFromObject(robj *o, double *target) {
errno == EINVAL ||
isnan(value))
return REDIS_ERR;
- } else if (o->encoding == REDIS_ENCODING_INT) {
+ } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)o->ptr;
} else {
redisPanic("Unknown string encoding");
@@ -583,14 +583,14 @@ int getLongDoubleFromObject(robj *o, long double *target) {
if (o == NULL) {
value = 0;
} else {
- redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
+ redisAssertWithInfo(NULL,o,o->type == OBJ_STRING);
if (sdsEncodedObject(o)) {
errno = 0;
value = strtold(o->ptr, &eptr);
if (isspace(((char*)o->ptr)[0]) || eptr[0] != '\0' ||
errno == ERANGE || isnan(value))
return REDIS_ERR;
- } else if (o->encoding == REDIS_ENCODING_INT) {
+ } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)o->ptr;
} else {
redisPanic("Unknown string encoding");
@@ -621,14 +621,14 @@ int getLongLongFromObject(robj *o, long long *target) {
if (o == NULL) {
value = 0;
} else {
- redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
+ redisAssertWithInfo(NULL,o,o->type == OBJ_STRING);
if (sdsEncodedObject(o)) {
errno = 0;
value = strtoll(o->ptr, &eptr, 10);
if (isspace(((char*)o->ptr)[0]) || eptr[0] != '\0' ||
errno == ERANGE)
return REDIS_ERR;
- } else if (o->encoding == REDIS_ENCODING_INT) {
+ } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)o->ptr;
} else {
redisPanic("Unknown string encoding");
@@ -670,14 +670,14 @@ int getLongFromObjectOrReply(client *c, robj *o, long *target, const char *msg)
char *strEncoding(int encoding) {
switch(encoding) {
- case REDIS_ENCODING_RAW: return "raw";
- case REDIS_ENCODING_INT: return "int";
- case REDIS_ENCODING_HT: return "hashtable";
- case REDIS_ENCODING_QUICKLIST: return "quicklist";
- case REDIS_ENCODING_ZIPLIST: return "ziplist";
- case REDIS_ENCODING_INTSET: return "intset";
- case REDIS_ENCODING_SKIPLIST: return "skiplist";
- case REDIS_ENCODING_EMBSTR: return "embstr";
+ case OBJ_ENCODING_RAW: return "raw";
+ case OBJ_ENCODING_INT: return "int";
+ case OBJ_ENCODING_HT: return "hashtable";
+ case OBJ_ENCODING_QUICKLIST: return "quicklist";
+ case OBJ_ENCODING_ZIPLIST: return "ziplist";
+ case OBJ_ENCODING_INTSET: return "intset";
+ case OBJ_ENCODING_SKIPLIST: return "skiplist";
+ case OBJ_ENCODING_EMBSTR: return "embstr";
default: return "unknown";
}
}
diff --git a/src/rdb.c b/src/rdb.c
index 6bff4fc82..6bf03384b 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -209,7 +209,7 @@ void *rdbLoadIntegerObject(rio *rdb, int enctype, int flags) {
} else if (encode) {
return createStringObjectFromLongLong(val);
} else {
- return createObject(REDIS_STRING,sdsfromlonglong(val));
+ return createObject(OBJ_STRING,sdsfromlonglong(val));
}
}
@@ -303,7 +303,7 @@ void *rdbLoadLzfStringObject(rio *rdb, int flags) {
if (plain)
return val;
else
- return createObject(REDIS_STRING,val);
+ return createObject(OBJ_STRING,val);
err:
zfree(c);
if (plain)
@@ -370,7 +370,7 @@ ssize_t rdbSaveLongLongAsStringObject(rio *rdb, long long value) {
int rdbSaveStringObject(rio *rdb, robj *obj) {
/* Avoid to decode the object, then encode it again, if the
* object is already integer encoded. */
- if (obj->encoding == REDIS_ENCODING_INT) {
+ if (obj->encoding == OBJ_ENCODING_INT) {
return rdbSaveLongLongAsStringObject(rdb,(long)obj->ptr);
} else {
redisAssertWithInfo(NULL,obj,sdsEncodedObject(obj));
@@ -498,31 +498,31 @@ int rdbLoadDoubleValue(rio *rdb, double *val) {
/* Save the object type of object "o". */
int rdbSaveObjectType(rio *rdb, robj *o) {
switch (o->type) {
- case REDIS_STRING:
+ case OBJ_STRING:
return rdbSaveType(rdb,REDIS_RDB_TYPE_STRING);
- case REDIS_LIST:
- if (o->encoding == REDIS_ENCODING_QUICKLIST)
+ case OBJ_LIST:
+ if (o->encoding == OBJ_ENCODING_QUICKLIST)
return rdbSaveType(rdb,REDIS_RDB_TYPE_LIST_QUICKLIST);
else
redisPanic("Unknown list encoding");
- case REDIS_SET:
- if (o->encoding == REDIS_ENCODING_INTSET)
+ case OBJ_SET:
+ if (o->encoding == OBJ_ENCODING_INTSET)
return rdbSaveType(rdb,REDIS_RDB_TYPE_SET_INTSET);
- else if (o->encoding == REDIS_ENCODING_HT)
+ else if (o->encoding == OBJ_ENCODING_HT)
return rdbSaveType(rdb,REDIS_RDB_TYPE_SET);
else
redisPanic("Unknown set encoding");
- case REDIS_ZSET:
- if (o->encoding == REDIS_ENCODING_ZIPLIST)
+ case OBJ_ZSET:
+ if (o->encoding == OBJ_ENCODING_ZIPLIST)
return rdbSaveType(rdb,REDIS_RDB_TYPE_ZSET_ZIPLIST);
- else if (o->encoding == REDIS_ENCODING_SKIPLIST)
+ else if (o->encoding == OBJ_ENCODING_SKIPLIST)
return rdbSaveType(rdb,REDIS_RDB_TYPE_ZSET);
else
redisPanic("Unknown sorted set encoding");
- case REDIS_HASH:
- if (o->encoding == REDIS_ENCODING_ZIPLIST)
+ case OBJ_HASH:
+ if (o->encoding == OBJ_ENCODING_ZIPLIST)
return rdbSaveType(rdb,REDIS_RDB_TYPE_HASH_ZIPLIST);
- else if (o->encoding == REDIS_ENCODING_HT)
+ else if (o->encoding == OBJ_ENCODING_HT)
return rdbSaveType(rdb,REDIS_RDB_TYPE_HASH);
else
redisPanic("Unknown hash encoding");
@@ -545,13 +545,13 @@ int rdbLoadObjectType(rio *rdb) {
ssize_t rdbSaveObject(rio *rdb, robj *o) {
ssize_t n = 0, nwritten = 0;
- if (o->type == REDIS_STRING) {
+ if (o->type == OBJ_STRING) {
/* Save a string value */
if ((n = rdbSaveStringObject(rdb,o)) == -1) return -1;
nwritten += n;
- } else if (o->type == REDIS_LIST) {
+ } else if (o->type == OBJ_LIST) {
/* Save a list value */
- if (o->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (o->encoding == OBJ_ENCODING_QUICKLIST) {
quicklist *ql = o->ptr;
quicklistNode *node = ql->head;
@@ -572,9 +572,9 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
} else {
redisPanic("Unknown list encoding");
}
- } else if (o->type == REDIS_SET) {
+ } else if (o->type == OBJ_SET) {
/* Save a set value */
- if (o->encoding == REDIS_ENCODING_HT) {
+ if (o->encoding == OBJ_ENCODING_HT) {
dict *set = o->ptr;
dictIterator *di = dictGetIterator(set);
dictEntry *de;
@@ -588,7 +588,7 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
nwritten += n;
}
dictReleaseIterator(di);
- } else if (o->encoding == REDIS_ENCODING_INTSET) {
+ } else if (o->encoding == OBJ_ENCODING_INTSET) {
size_t l = intsetBlobLen((intset*)o->ptr);
if ((n = rdbSaveRawString(rdb,o->ptr,l)) == -1) return -1;
@@ -596,14 +596,14 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
} else {
redisPanic("Unknown set encoding");
}
- } else if (o->type == REDIS_ZSET) {
+ } else if (o->type == OBJ_ZSET) {
/* Save a sorted set value */
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
size_t l = ziplistBlobLen((unsigned char*)o->ptr);
if ((n = rdbSaveRawString(rdb,o->ptr,l)) == -1) return -1;
nwritten += n;
- } else if (o->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (o->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = o->ptr;
dictIterator *di = dictGetIterator(zs->dict);
dictEntry *de;
@@ -624,15 +624,15 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
} else {
redisPanic("Unknown sorted set encoding");
}
- } else if (o->type == REDIS_HASH) {
+ } else if (o->type == OBJ_HASH) {
/* Save a hash value */
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
size_t l = ziplistBlobLen((unsigned char*)o->ptr);
if ((n = rdbSaveRawString(rdb,o->ptr,l)) == -1) return -1;
nwritten += n;
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
dictIterator *di = dictGetIterator(o->ptr);
dictEntry *de;
@@ -979,19 +979,19 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
if ((ele = rdbLoadEncodedStringObject(rdb)) == NULL) return NULL;
ele = tryObjectEncoding(ele);
- if (o->encoding == REDIS_ENCODING_INTSET) {
+ if (o->encoding == OBJ_ENCODING_INTSET) {
/* Fetch integer value from element */
if (isObjectRepresentableAsLongLong(ele,&llval) == REDIS_OK) {
o->ptr = intsetAdd(o->ptr,llval,NULL);
} else {
- setTypeConvert(o,REDIS_ENCODING_HT);
+ setTypeConvert(o,OBJ_ENCODING_HT);
dictExpand(o->ptr,len);
}
}
/* This will also be called when the set was just converted
* to a regular hash table encoded set */
- if (o->encoding == REDIS_ENCODING_HT) {
+ if (o->encoding == OBJ_ENCODING_HT) {
dictAdd((dict*)o->ptr,ele,NULL);
} else {
decrRefCount(ele);
@@ -1029,7 +1029,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
/* Convert *after* loading, since sorted sets are not stored ordered. */
if (zsetLength(o) <= server.zset_max_ziplist_entries &&
maxelelen <= server.zset_max_ziplist_value)
- zsetConvert(o,REDIS_ENCODING_ZIPLIST);
+ zsetConvert(o,OBJ_ENCODING_ZIPLIST);
} else if (rdbtype == REDIS_RDB_TYPE_HASH) {
size_t len;
int ret;
@@ -1041,10 +1041,10 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
/* Too many entries? Use a hash table. */
if (len > server.hash_max_ziplist_entries)
- hashTypeConvert(o, REDIS_ENCODING_HT);
+ hashTypeConvert(o, OBJ_ENCODING_HT);
/* Load every field and value into the ziplist */
- while (o->encoding == REDIS_ENCODING_ZIPLIST && len > 0) {
+ while (o->encoding == OBJ_ENCODING_ZIPLIST && len > 0) {
robj *field, *value;
len--;
@@ -1065,7 +1065,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
{
decrRefCount(field);
decrRefCount(value);
- hashTypeConvert(o, REDIS_ENCODING_HT);
+ hashTypeConvert(o, OBJ_ENCODING_HT);
break;
}
decrRefCount(field);
@@ -1073,7 +1073,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
}
/* Load remaining fields and values into the hash table */
- while (o->encoding == REDIS_ENCODING_HT && len > 0) {
+ while (o->encoding == OBJ_ENCODING_HT && len > 0) {
robj *field, *value;
len--;
@@ -1114,7 +1114,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
{
unsigned char *encoded = rdbGenericLoadStringObject(rdb,RDB_LOAD_PLAIN);
if (encoded == NULL) return NULL;
- o = createObject(REDIS_STRING,encoded); /* Obj type fixed below. */
+ o = createObject(OBJ_STRING,encoded); /* Obj type fixed below. */
/* Fix the object encoding, and make sure to convert the encoded
* data type into the base type if accordingly to the current
@@ -1142,38 +1142,38 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
zfree(o->ptr);
o->ptr = zl;
- o->type = REDIS_HASH;
- o->encoding = REDIS_ENCODING_ZIPLIST;
+ o->type = OBJ_HASH;
+ o->encoding = OBJ_ENCODING_ZIPLIST;
if (hashTypeLength(o) > server.hash_max_ziplist_entries ||
maxlen > server.hash_max_ziplist_value)
{
- hashTypeConvert(o, REDIS_ENCODING_HT);
+ hashTypeConvert(o, OBJ_ENCODING_HT);
}
}
break;
case REDIS_RDB_TYPE_LIST_ZIPLIST:
- o->type = REDIS_LIST;
- o->encoding = REDIS_ENCODING_ZIPLIST;
- listTypeConvert(o,REDIS_ENCODING_QUICKLIST);
+ o->type = OBJ_LIST;
+ o->encoding = OBJ_ENCODING_ZIPLIST;
+ listTypeConvert(o,OBJ_ENCODING_QUICKLIST);
break;
case REDIS_RDB_TYPE_SET_INTSET:
- o->type = REDIS_SET;
- o->encoding = REDIS_ENCODING_INTSET;
+ o->type = OBJ_SET;
+ o->encoding = OBJ_ENCODING_INTSET;
if (intsetLen(o->ptr) > server.set_max_intset_entries)
- setTypeConvert(o,REDIS_ENCODING_HT);
+ setTypeConvert(o,OBJ_ENCODING_HT);
break;
case REDIS_RDB_TYPE_ZSET_ZIPLIST:
- o->type = REDIS_ZSET;
- o->encoding = REDIS_ENCODING_ZIPLIST;
+ o->type = OBJ_ZSET;
+ o->encoding = OBJ_ENCODING_ZIPLIST;
if (zsetLength(o) > server.zset_max_ziplist_entries)
- zsetConvert(o,REDIS_ENCODING_SKIPLIST);
+ zsetConvert(o,OBJ_ENCODING_SKIPLIST);
break;
case REDIS_RDB_TYPE_HASH_ZIPLIST:
- o->type = REDIS_HASH;
- o->encoding = REDIS_ENCODING_ZIPLIST;
+ o->type = OBJ_HASH;
+ o->encoding = OBJ_ENCODING_ZIPLIST;
if (hashTypeLength(o) > server.hash_max_ziplist_entries)
- hashTypeConvert(o, REDIS_ENCODING_HT);
+ hashTypeConvert(o, OBJ_ENCODING_HT);
break;
default:
rdbExitReportCorruptRDB("Unknown encoding");
diff --git a/src/replication.c b/src/replication.c
index fb983218c..f42285e2e 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -154,7 +154,7 @@ void feedReplicationBacklogWithObject(robj *o) {
void *p;
size_t len;
- if (o->encoding == REDIS_ENCODING_INT) {
+ if (o->encoding == OBJ_ENCODING_INT) {
len = ll2string(llstr,sizeof(llstr),(long)o->ptr);
p = llstr;
} else {
@@ -188,7 +188,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
int dictid_len;
dictid_len = ll2string(llstr,sizeof(llstr),dictid);
- selectcmd = createObject(REDIS_STRING,
+ selectcmd = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),
"*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n",
dictid_len, llstr));
@@ -277,7 +277,7 @@ void replicationFeedMonitors(client *c, list *monitors, int dictid, robj **argv,
}
for (j = 0; j < argc; j++) {
- if (argv[j]->encoding == REDIS_ENCODING_INT) {
+ if (argv[j]->encoding == OBJ_ENCODING_INT) {
cmdrepr = sdscatprintf(cmdrepr, "\"%ld\"", (long)argv[j]->ptr);
} else {
cmdrepr = sdscatrepr(cmdrepr,(char*)argv[j]->ptr,
@@ -287,7 +287,7 @@ void replicationFeedMonitors(client *c, list *monitors, int dictid, robj **argv,
cmdrepr = sdscatlen(cmdrepr," ",1);
}
cmdrepr = sdscatlen(cmdrepr,"\r\n",2);
- cmdobj = createObject(REDIS_STRING,cmdrepr);
+ cmdobj = createObject(OBJ_STRING,cmdrepr);
listRewind(monitors,&li);
while((ln = listNext(&li))) {
diff --git a/src/scripting.c b/src/scripting.c
index 6be950ace..9271ea6d0 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -415,8 +415,8 @@ cleanup:
* (we must be the only owner) for us to cache it. */
if (j < LUA_CMD_OBJCACHE_SIZE &&
o->refcount == 1 &&
- (o->encoding == REDIS_ENCODING_RAW ||
- o->encoding == REDIS_ENCODING_EMBSTR) &&
+ (o->encoding == OBJ_ENCODING_RAW ||
+ o->encoding == OBJ_ENCODING_EMBSTR) &&
sdslen(o->ptr) <= LUA_CMD_OBJCACHE_MAX_LEN)
{
sds s = o->ptr;
diff --git a/src/server.c b/src/server.c
index b9955115b..cc7d1a19b 100644
--- a/src/server.c
+++ b/src/server.c
@@ -495,8 +495,8 @@ int dictEncObjKeyCompare(void *privdata, const void *key1,
robj *o1 = (robj*) key1, *o2 = (robj*) key2;
int cmp;
- if (o1->encoding == REDIS_ENCODING_INT &&
- o2->encoding == REDIS_ENCODING_INT)
+ if (o1->encoding == OBJ_ENCODING_INT &&
+ o2->encoding == OBJ_ENCODING_INT)
return o1->ptr == o2->ptr;
o1 = getDecodedObject(o1);
@@ -513,7 +513,7 @@ unsigned int dictEncObjHash(const void *key) {
if (sdsEncodedObject(o)) {
return dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
} else {
- if (o->encoding == REDIS_ENCODING_INT) {
+ if (o->encoding == OBJ_ENCODING_INT) {
char buf[32];
int len;
@@ -1324,61 +1324,61 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
void createSharedObjects(void) {
int j;
- shared.crlf = createObject(REDIS_STRING,sdsnew("\r\n"));
- shared.ok = createObject(REDIS_STRING,sdsnew("+OK\r\n"));
- shared.err = createObject(REDIS_STRING,sdsnew("-ERR\r\n"));
- shared.emptybulk = createObject(REDIS_STRING,sdsnew("$0\r\n\r\n"));
- shared.czero = createObject(REDIS_STRING,sdsnew(":0\r\n"));
- shared.cone = createObject(REDIS_STRING,sdsnew(":1\r\n"));
- shared.cnegone = createObject(REDIS_STRING,sdsnew(":-1\r\n"));
- shared.nullbulk = createObject(REDIS_STRING,sdsnew("$-1\r\n"));
- shared.nullmultibulk = createObject(REDIS_STRING,sdsnew("*-1\r\n"));
- shared.emptymultibulk = createObject(REDIS_STRING,sdsnew("*0\r\n"));
- shared.pong = createObject(REDIS_STRING,sdsnew("+PONG\r\n"));
- shared.queued = createObject(REDIS_STRING,sdsnew("+QUEUED\r\n"));
- shared.emptyscan = createObject(REDIS_STRING,sdsnew("*2\r\n$1\r\n0\r\n*0\r\n"));
- shared.wrongtypeerr = createObject(REDIS_STRING,sdsnew(
+ shared.crlf = createObject(OBJ_STRING,sdsnew("\r\n"));
+ shared.ok = createObject(OBJ_STRING,sdsnew("+OK\r\n"));
+ shared.err = createObject(OBJ_STRING,sdsnew("-ERR\r\n"));
+ shared.emptybulk = createObject(OBJ_STRING,sdsnew("$0\r\n\r\n"));
+ shared.czero = createObject(OBJ_STRING,sdsnew(":0\r\n"));
+ shared.cone = createObject(OBJ_STRING,sdsnew(":1\r\n"));
+ shared.cnegone = createObject(OBJ_STRING,sdsnew(":-1\r\n"));
+ shared.nullbulk = createObject(OBJ_STRING,sdsnew("$-1\r\n"));
+ shared.nullmultibulk = createObject(OBJ_STRING,sdsnew("*-1\r\n"));
+ shared.emptymultibulk = createObject(OBJ_STRING,sdsnew("*0\r\n"));
+ shared.pong = createObject(OBJ_STRING,sdsnew("+PONG\r\n"));
+ shared.queued = createObject(OBJ_STRING,sdsnew("+QUEUED\r\n"));
+ shared.emptyscan = createObject(OBJ_STRING,sdsnew("*2\r\n$1\r\n0\r\n*0\r\n"));
+ shared.wrongtypeerr = createObject(OBJ_STRING,sdsnew(
"-WRONGTYPE Operation against a key holding the wrong kind of value\r\n"));
- shared.nokeyerr = createObject(REDIS_STRING,sdsnew(
+ shared.nokeyerr = createObject(OBJ_STRING,sdsnew(
"-ERR no such key\r\n"));
- shared.syntaxerr = createObject(REDIS_STRING,sdsnew(
+ shared.syntaxerr = createObject(OBJ_STRING,sdsnew(
"-ERR syntax error\r\n"));
- shared.sameobjecterr = createObject(REDIS_STRING,sdsnew(
+ shared.sameobjecterr = createObject(OBJ_STRING,sdsnew(
"-ERR source and destination objects are the same\r\n"));
- shared.outofrangeerr = createObject(REDIS_STRING,sdsnew(
+ shared.outofrangeerr = createObject(OBJ_STRING,sdsnew(
"-ERR index out of range\r\n"));
- shared.noscripterr = createObject(REDIS_STRING,sdsnew(
+ shared.noscripterr = createObject(OBJ_STRING,sdsnew(
"-NOSCRIPT No matching script. Please use EVAL.\r\n"));
- shared.loadingerr = createObject(REDIS_STRING,sdsnew(
+ shared.loadingerr = createObject(OBJ_STRING,sdsnew(
"-LOADING Redis is loading the dataset in memory\r\n"));
- shared.slowscripterr = createObject(REDIS_STRING,sdsnew(
+ shared.slowscripterr = createObject(OBJ_STRING,sdsnew(
"-BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.\r\n"));
- shared.masterdownerr = createObject(REDIS_STRING,sdsnew(
+ shared.masterdownerr = createObject(OBJ_STRING,sdsnew(
"-MASTERDOWN Link with MASTER is down and slave-serve-stale-data is set to 'no'.\r\n"));
- shared.bgsaveerr = createObject(REDIS_STRING,sdsnew(
+ shared.bgsaveerr = createObject(OBJ_STRING,sdsnew(
"-MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.\r\n"));
- shared.roslaveerr = createObject(REDIS_STRING,sdsnew(
+ shared.roslaveerr = createObject(OBJ_STRING,sdsnew(
"-READONLY You can't write against a read only slave.\r\n"));
- shared.noautherr = createObject(REDIS_STRING,sdsnew(
+ shared.noautherr = createObject(OBJ_STRING,sdsnew(
"-NOAUTH Authentication required.\r\n"));
- shared.oomerr = createObject(REDIS_STRING,sdsnew(
+ shared.oomerr = createObject(OBJ_STRING,sdsnew(
"-OOM command not allowed when used memory > 'maxmemory'.\r\n"));
- shared.execaborterr = createObject(REDIS_STRING,sdsnew(
+ shared.execaborterr = createObject(OBJ_STRING,sdsnew(
"-EXECABORT Transaction discarded because of previous errors.\r\n"));
- shared.noreplicaserr = createObject(REDIS_STRING,sdsnew(
+ shared.noreplicaserr = createObject(OBJ_STRING,sdsnew(
"-NOREPLICAS Not enough good slaves to write.\r\n"));
- shared.busykeyerr = createObject(REDIS_STRING,sdsnew(
+ shared.busykeyerr = createObject(OBJ_STRING,sdsnew(
"-BUSYKEY Target key name already exists.\r\n"));
- shared.space = createObject(REDIS_STRING,sdsnew(" "));
- shared.colon = createObject(REDIS_STRING,sdsnew(":"));
- shared.plus = createObject(REDIS_STRING,sdsnew("+"));
+ shared.space = createObject(OBJ_STRING,sdsnew(" "));
+ shared.colon = createObject(OBJ_STRING,sdsnew(":"));
+ shared.plus = createObject(OBJ_STRING,sdsnew("+"));
for (j = 0; j < REDIS_SHARED_SELECT_CMDS; j++) {
char dictid_str[64];
int dictid_len;
dictid_len = ll2string(dictid_str,sizeof(dictid_str),j);
- shared.select[j] = createObject(REDIS_STRING,
+ shared.select[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),
"*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n",
dictid_len, dictid_str));
@@ -1394,13 +1394,13 @@ void createSharedObjects(void) {
shared.lpop = createStringObject("LPOP",4);
shared.lpush = createStringObject("LPUSH",5);
for (j = 0; j < REDIS_SHARED_INTEGERS; j++) {
- shared.integers[j] = createObject(REDIS_STRING,(void*)(long)j);
- shared.integers[j]->encoding = REDIS_ENCODING_INT;
+ shared.integers[j] = createObject(OBJ_STRING,(void*)(long)j);
+ shared.integers[j]->encoding = OBJ_ENCODING_INT;
}
for (j = 0; j < REDIS_SHARED_BULKHDR_LEN; j++) {
- shared.mbulkhdr[j] = createObject(REDIS_STRING,
+ shared.mbulkhdr[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"*%d\r\n",j));
- shared.bulkhdr[j] = createObject(REDIS_STRING,
+ shared.bulkhdr[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"$%d\r\n",j));
}
/* The following two shared objects, minstring and maxstrings, are not
@@ -1472,13 +1472,13 @@ void initServerConfig(void) {
server.maxmemory = CONFIG_DEFAULT_MAXMEMORY;
server.maxmemory_policy = CONFIG_DEFAULT_MAXMEMORY_POLICY;
server.maxmemory_samples = CONFIG_DEFAULT_MAXMEMORY_SAMPLES;
- server.hash_max_ziplist_entries = REDIS_HASH_MAX_ZIPLIST_ENTRIES;
- server.hash_max_ziplist_value = REDIS_HASH_MAX_ZIPLIST_VALUE;
- server.list_max_ziplist_size = REDIS_LIST_MAX_ZIPLIST_SIZE;
- server.list_compress_depth = REDIS_LIST_COMPRESS_DEPTH;
- server.set_max_intset_entries = REDIS_SET_MAX_INTSET_ENTRIES;
- server.zset_max_ziplist_entries = REDIS_ZSET_MAX_ZIPLIST_ENTRIES;
- server.zset_max_ziplist_value = REDIS_ZSET_MAX_ZIPLIST_VALUE;
+ server.hash_max_ziplist_entries = OBJ_HASH_MAX_ZIPLIST_ENTRIES;
+ server.hash_max_ziplist_value = OBJ_HASH_MAX_ZIPLIST_VALUE;
+ server.list_max_ziplist_size = OBJ_LIST_MAX_ZIPLIST_SIZE;
+ server.list_compress_depth = OBJ_LIST_COMPRESS_DEPTH;
+ server.set_max_intset_entries = OBJ_SET_MAX_INTSET_ENTRIES;
+ server.zset_max_ziplist_entries = OBJ_ZSET_MAX_ZIPLIST_ENTRIES;
+ server.zset_max_ziplist_value = OBJ_ZSET_MAX_ZIPLIST_VALUE;
server.hll_sparse_max_bytes = CONFIG_DEFAULT_HLL_SPARSE_MAX_BYTES;
server.shutdown_asap = 0;
server.repl_ping_slave_period = REDIS_REPL_PING_SLAVE_PERIOD;
diff --git a/src/server.h b/src/server.h
index 71a52cc9a..7bed5be57 100644
--- a/src/server.h
+++ b/src/server.h
@@ -184,25 +184,25 @@ typedef long long mstime_t; /* millisecond time type. */
#define REDIS_CMD_FAST 8192 /* "F" flag */
/* Object types */
-#define REDIS_STRING 0
-#define REDIS_LIST 1
-#define REDIS_SET 2
-#define REDIS_ZSET 3
-#define REDIS_HASH 4
+#define OBJ_STRING 0
+#define OBJ_LIST 1
+#define OBJ_SET 2
+#define OBJ_ZSET 3
+#define OBJ_HASH 4
/* Objects encoding. Some kind of objects like Strings and Hashes can be
* internally represented in multiple ways. The 'encoding' field of the object
* is set to one of this fields for this object. */
-#define REDIS_ENCODING_RAW 0 /* Raw representation */
-#define REDIS_ENCODING_INT 1 /* Encoded as integer */
-#define REDIS_ENCODING_HT 2 /* Encoded as hash table */
-#define REDIS_ENCODING_ZIPMAP 3 /* Encoded as zipmap */
-#define REDIS_ENCODING_LINKEDLIST 4 /* Encoded as regular linked list */
-#define REDIS_ENCODING_ZIPLIST 5 /* Encoded as ziplist */
-#define REDIS_ENCODING_INTSET 6 /* Encoded as intset */
-#define REDIS_ENCODING_SKIPLIST 7 /* Encoded as skiplist */
-#define REDIS_ENCODING_EMBSTR 8 /* Embedded sds string encoding */
-#define REDIS_ENCODING_QUICKLIST 9 /* Encoded as linked list of ziplists */
+#define OBJ_ENCODING_RAW 0 /* Raw representation */
+#define OBJ_ENCODING_INT 1 /* Encoded as integer */
+#define OBJ_ENCODING_HT 2 /* Encoded as hash table */
+#define OBJ_ENCODING_ZIPMAP 3 /* Encoded as zipmap */
+#define OBJ_ENCODING_LINKEDLIST 4 /* Encoded as regular linked list */
+#define OBJ_ENCODING_ZIPLIST 5 /* Encoded as ziplist */
+#define OBJ_ENCODING_INTSET 6 /* Encoded as intset */
+#define OBJ_ENCODING_SKIPLIST 7 /* Encoded as skiplist */
+#define OBJ_ENCODING_EMBSTR 8 /* Embedded sds string encoding */
+#define OBJ_ENCODING_QUICKLIST 9 /* Encoded as linked list of ziplists */
/* Defines related to the dump file format. To store 32 bits lengths for short
* keys requires a lot of space, so we check the most significant 2 bits of
@@ -333,15 +333,15 @@ typedef long long mstime_t; /* millisecond time type. */
#define CONFIG_DEFAULT_AOF_FSYNC AOF_FSYNC_EVERYSEC
/* Zip structure related defaults */
-#define REDIS_HASH_MAX_ZIPLIST_ENTRIES 512
-#define REDIS_HASH_MAX_ZIPLIST_VALUE 64
-#define REDIS_SET_MAX_INTSET_ENTRIES 512
-#define REDIS_ZSET_MAX_ZIPLIST_ENTRIES 128
-#define REDIS_ZSET_MAX_ZIPLIST_VALUE 64
+#define OBJ_HASH_MAX_ZIPLIST_ENTRIES 512
+#define OBJ_HASH_MAX_ZIPLIST_VALUE 64
+#define OBJ_SET_MAX_INTSET_ENTRIES 512
+#define OBJ_ZSET_MAX_ZIPLIST_ENTRIES 128
+#define OBJ_ZSET_MAX_ZIPLIST_VALUE 64
/* List defaults */
-#define REDIS_LIST_MAX_ZIPLIST_SIZE -2
-#define REDIS_LIST_COMPRESS_DEPTH 0
+#define OBJ_LIST_MAX_ZIPLIST_SIZE -2
+#define OBJ_LIST_COMPRESS_DEPTH 0
/* HyperLogLog defines */
#define CONFIG_DEFAULT_HLL_SPARSE_MAX_BYTES 3000
@@ -446,8 +446,8 @@ typedef struct redisObject {
* bug #85 introduced exactly in this way. */
#define initStaticStringObject(_var,_ptr) do { \
_var.refcount = 1; \
- _var.type = REDIS_STRING; \
- _var.encoding = REDIS_ENCODING_RAW; \
+ _var.type = OBJ_STRING; \
+ _var.encoding = OBJ_ENCODING_RAW; \
_var.ptr = _ptr; \
} while(0);
@@ -1006,8 +1006,8 @@ typedef struct {
dictEntry *de;
} hashTypeIterator;
-#define REDIS_HASH_KEY 1
-#define REDIS_HASH_VALUE 2
+#define OBJ_HASH_KEY 1
+#define OBJ_HASH_VALUE 2
/*-----------------------------------------------------------------------------
* Extern declarations
@@ -1166,7 +1166,7 @@ int compareStringObjects(robj *a, robj *b);
int collateStringObjects(robj *a, robj *b);
int equalStringObjects(robj *a, robj *b);
unsigned long long estimateObjectIdleTime(robj *o);
-#define sdsEncodedObject(objptr) (objptr->encoding == REDIS_ENCODING_RAW || objptr->encoding == REDIS_ENCODING_EMBSTR)
+#define sdsEncodedObject(objptr) (objptr->encoding == OBJ_ENCODING_RAW || objptr->encoding == OBJ_ENCODING_EMBSTR)
/* Synchronous I/O with timeout */
ssize_t syncWrite(int fd, char *ptr, ssize_t size, long long timeout);
diff --git a/src/slowlog.c b/src/slowlog.c
index 7df37d26e..21f1842bf 100644
--- a/src/slowlog.c
+++ b/src/slowlog.c
@@ -57,12 +57,12 @@ slowlogEntry *slowlogCreateEntry(robj **argv, int argc, long long duration) {
* at SLOWLOG_ENTRY_MAX_ARGC, but use the last argument to specify
* how many remaining arguments there were in the original command. */
if (slargc != argc && j == slargc-1) {
- se->argv[j] = createObject(REDIS_STRING,
+ se->argv[j] = createObject(OBJ_STRING,
sdscatprintf(sdsempty(),"... (%d more arguments)",
argc-slargc+1));
} else {
/* Trim too long strings as well... */
- if (argv[j]->type == REDIS_STRING &&
+ if (argv[j]->type == OBJ_STRING &&
sdsEncodedObject(argv[j]) &&
sdslen(argv[j]->ptr) > SLOWLOG_ENTRY_MAX_STRING)
{
@@ -71,7 +71,7 @@ slowlogEntry *slowlogCreateEntry(robj **argv, int argc, long long duration) {
s = sdscatprintf(s,"... (%lu more bytes)",
(unsigned long)
sdslen(argv[j]->ptr) - SLOWLOG_ENTRY_MAX_STRING);
- se->argv[j] = createObject(REDIS_STRING,s);
+ se->argv[j] = createObject(OBJ_STRING,s);
} else {
se->argv[j] = argv[j];
incrRefCount(argv[j]);
diff --git a/src/sort.c b/src/sort.c
index 2bdea56bd..6662913c6 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -110,13 +110,13 @@ robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
if (o == NULL) goto noobj;
if (fieldobj) {
- if (o->type != REDIS_HASH) goto noobj;
+ if (o->type != OBJ_HASH) goto noobj;
/* Retrieve value from hash by the field name. This operation
* already increases the refcount of the returned object. */
o = hashTypeGetObject(o, fieldobj);
} else {
- if (o->type != REDIS_STRING) goto noobj;
+ if (o->type != OBJ_STRING) goto noobj;
/* Every object that this function returns needs to have its refcount
* increased. sortCommand decreases it again. */
@@ -200,9 +200,9 @@ void sortCommand(client *c) {
/* Lookup the key to sort. It must be of the right types */
sortval = lookupKeyRead(c->db,c->argv[1]);
- if (sortval && sortval->type != REDIS_SET &&
- sortval->type != REDIS_LIST &&
- sortval->type != REDIS_ZSET)
+ if (sortval && sortval->type != OBJ_SET &&
+ sortval->type != OBJ_LIST &&
+ sortval->type != OBJ_ZSET)
{
addReply(c,shared.wrongtypeerr);
return;
@@ -292,7 +292,7 @@ void sortCommand(client *c) {
* even if no sort order is requested, so they remain stable across
* scripting and replication. */
if (dontsort &&
- sortval->type == REDIS_SET &&
+ sortval->type == OBJ_SET &&
(storekey || c->flags & REDIS_LUA_CLIENT))
{
/* Force ALPHA sorting */
@@ -302,14 +302,14 @@ void sortCommand(client *c) {
}
/* Destructively convert encoded sorted sets for SORT. */
- if (sortval->type == REDIS_ZSET)
- zsetConvert(sortval, REDIS_ENCODING_SKIPLIST);
+ if (sortval->type == OBJ_ZSET)
+ zsetConvert(sortval, OBJ_ENCODING_SKIPLIST);
/* Objtain the length of the object to sort. */
switch(sortval->type) {
- case REDIS_LIST: vectorlen = listTypeLength(sortval); break;
- case REDIS_SET: vectorlen = setTypeSize(sortval); break;
- case REDIS_ZSET: vectorlen = dictSize(((zset*)sortval->ptr)->dict); break;
+ case OBJ_LIST: vectorlen = listTypeLength(sortval); break;
+ case OBJ_SET: vectorlen = setTypeSize(sortval); break;
+ case OBJ_ZSET: vectorlen = dictSize(((zset*)sortval->ptr)->dict); break;
default: vectorlen = 0; redisPanic("Bad SORT type"); /* Avoid GCC warning */
}
@@ -332,7 +332,7 @@ void sortCommand(client *c) {
* the number of elements to fetch, we also optimize to just load the
* range we are interested in and allocating a vector that is big enough
* for the selected range length. */
- if ((sortval->type == REDIS_ZSET || sortval->type == REDIS_LIST) &&
+ if ((sortval->type == OBJ_ZSET || sortval->type == OBJ_LIST) &&
dontsort &&
(start != 0 || end != vectorlen-1))
{
@@ -343,7 +343,7 @@ void sortCommand(client *c) {
vector = zmalloc(sizeof(redisSortObject)*vectorlen);
j = 0;
- if (sortval->type == REDIS_LIST && dontsort) {
+ if (sortval->type == OBJ_LIST && dontsort) {
/* Special handling for a list, if 'dontsort' is true.
* This makes sure we return elements in the list original
* ordering, accordingly to DESC / ASC options.
@@ -368,7 +368,7 @@ void sortCommand(client *c) {
end -= start;
start = 0;
}
- } else if (sortval->type == REDIS_LIST) {
+ } else if (sortval->type == OBJ_LIST) {
listTypeIterator *li = listTypeInitIterator(sortval,0,REDIS_TAIL);
listTypeEntry entry;
while(listTypeNext(li,&entry)) {
@@ -378,7 +378,7 @@ void sortCommand(client *c) {
j++;
}
listTypeReleaseIterator(li);
- } else if (sortval->type == REDIS_SET) {
+ } else if (sortval->type == OBJ_SET) {
setTypeIterator *si = setTypeInitIterator(sortval);
robj *ele;
while((ele = setTypeNextObject(si)) != NULL) {
@@ -388,7 +388,7 @@ void sortCommand(client *c) {
j++;
}
setTypeReleaseIterator(si);
- } else if (sortval->type == REDIS_ZSET && dontsort) {
+ } else if (sortval->type == OBJ_ZSET && dontsort) {
/* Special handling for a sorted set, if 'dontsort' is true.
* This makes sure we return elements in the sorted set original
* ordering, accordingly to DESC / ASC options.
@@ -427,7 +427,7 @@ void sortCommand(client *c) {
/* Fix start/end: output code is not aware of this optimization. */
end -= start;
start = 0;
- } else if (sortval->type == REDIS_ZSET) {
+ } else if (sortval->type == OBJ_ZSET) {
dict *set = ((zset*)sortval->ptr)->dict;
dictIterator *di;
dictEntry *setele;
@@ -469,7 +469,7 @@ void sortCommand(client *c) {
{
int_convertion_error = 1;
}
- } else if (byval->encoding == REDIS_ENCODING_INT) {
+ } else if (byval->encoding == OBJ_ENCODING_INT) {
/* Don't need to decode the object if it's
* integer-encoded (the only encoding supported) so
* far. We can just cast it */
@@ -577,7 +577,7 @@ void sortCommand(client *c) {
}
/* Cleanup */
- if (sortval->type == REDIS_LIST || sortval->type == REDIS_SET)
+ if (sortval->type == OBJ_LIST || sortval->type == OBJ_SET)
for (j = 0; j < vectorlen; j++)
decrRefCount(vector[j].obj);
decrRefCount(sortval);
diff --git a/src/t_hash.c b/src/t_hash.c
index 9d0cfee1e..b097b3201 100644
--- a/src/t_hash.c
+++ b/src/t_hash.c
@@ -40,13 +40,13 @@
void hashTypeTryConversion(robj *o, robj **argv, int start, int end) {
int i;
- if (o->encoding != REDIS_ENCODING_ZIPLIST) return;
+ if (o->encoding != OBJ_ENCODING_ZIPLIST) return;
for (i = start; i <= end; i++) {
if (sdsEncodedObject(argv[i]) &&
sdslen(argv[i]->ptr) > server.hash_max_ziplist_value)
{
- hashTypeConvert(o, REDIS_ENCODING_HT);
+ hashTypeConvert(o, OBJ_ENCODING_HT);
break;
}
}
@@ -54,7 +54,7 @@ void hashTypeTryConversion(robj *o, robj **argv, int start, int end) {
/* Encode given objects in-place when the hash uses a dict. */
void hashTypeTryObjectEncoding(robj *subject, robj **o1, robj **o2) {
- if (subject->encoding == REDIS_ENCODING_HT) {
+ if (subject->encoding == OBJ_ENCODING_HT) {
if (o1) *o1 = tryObjectEncoding(*o1);
if (o2) *o2 = tryObjectEncoding(*o2);
}
@@ -70,7 +70,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field,
unsigned char *zl, *fptr = NULL, *vptr = NULL;
int ret;
- redisAssert(o->encoding == REDIS_ENCODING_ZIPLIST);
+ redisAssert(o->encoding == OBJ_ENCODING_ZIPLIST);
field = getDecodedObject(field);
@@ -101,7 +101,7 @@ int hashTypeGetFromZiplist(robj *o, robj *field,
int hashTypeGetFromHashTable(robj *o, robj *field, robj **value) {
dictEntry *de;
- redisAssert(o->encoding == REDIS_ENCODING_HT);
+ redisAssert(o->encoding == OBJ_ENCODING_HT);
de = dictFind(o->ptr, field);
if (de == NULL) return -1;
@@ -118,7 +118,7 @@ int hashTypeGetFromHashTable(robj *o, robj *field, robj **value) {
robj *hashTypeGetObject(robj *o, robj *field) {
robj *value = NULL;
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;
unsigned int vlen = UINT_MAX;
long long vll = LLONG_MAX;
@@ -130,7 +130,7 @@ robj *hashTypeGetObject(robj *o, robj *field) {
value = createStringObjectFromLongLong(vll);
}
}
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
robj *aux;
if (hashTypeGetFromHashTable(o, field, &aux) == 0) {
@@ -148,14 +148,14 @@ robj *hashTypeGetObject(robj *o, robj *field) {
* exist. */
size_t hashTypeGetValueLength(robj *o, robj *field) {
size_t len = 0;
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;
unsigned int vlen = UINT_MAX;
long long vll = LLONG_MAX;
if (hashTypeGetFromZiplist(o, field, &vstr, &vlen, &vll) == 0)
len = vstr ? vlen : sdigits10(vll);
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
robj *aux;
if (hashTypeGetFromHashTable(o, field, &aux) == 0)
@@ -169,13 +169,13 @@ size_t hashTypeGetValueLength(robj *o, robj *field) {
/* Test if the specified field exists in the given hash. Returns 1 if the field
* exists, and 0 when it doesn't. */
int hashTypeExists(robj *o, robj *field) {
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;
unsigned int vlen = UINT_MAX;
long long vll = LLONG_MAX;
if (hashTypeGetFromZiplist(o, field, &vstr, &vlen, &vll) == 0) return 1;
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
robj *aux;
if (hashTypeGetFromHashTable(o, field, &aux) == 0) return 1;
@@ -192,7 +192,7 @@ int hashTypeExists(robj *o, robj *field) {
int hashTypeSet(robj *o, robj *field, robj *value) {
int update = 0;
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl, *fptr, *vptr;
field = getDecodedObject(field);
@@ -227,8 +227,8 @@ int hashTypeSet(robj *o, robj *field, robj *value) {
/* Check if the ziplist needs to be converted to a hash table */
if (hashTypeLength(o) > server.hash_max_ziplist_entries)
- hashTypeConvert(o, REDIS_ENCODING_HT);
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ hashTypeConvert(o, OBJ_ENCODING_HT);
+ } else if (o->encoding == OBJ_ENCODING_HT) {
if (dictReplace(o->ptr, field, value)) { /* Insert */
incrRefCount(field);
} else { /* Update */
@@ -246,7 +246,7 @@ int hashTypeSet(robj *o, robj *field, robj *value) {
int hashTypeDelete(robj *o, robj *field) {
int deleted = 0;
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl, *fptr;
field = getDecodedObject(field);
@@ -265,7 +265,7 @@ int hashTypeDelete(robj *o, robj *field) {
decrRefCount(field);
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
if (dictDelete((dict*)o->ptr, field) == REDIS_OK) {
deleted = 1;
@@ -284,9 +284,9 @@ int hashTypeDelete(robj *o, robj *field) {
unsigned long hashTypeLength(robj *o) {
unsigned long length = ULONG_MAX;
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
length = ziplistLen(o->ptr) / 2;
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
length = dictSize((dict*)o->ptr);
} else {
redisPanic("Unknown hash encoding");
@@ -300,10 +300,10 @@ hashTypeIterator *hashTypeInitIterator(robj *subject) {
hi->subject = subject;
hi->encoding = subject->encoding;
- if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
hi->fptr = NULL;
hi->vptr = NULL;
- } else if (hi->encoding == REDIS_ENCODING_HT) {
+ } else if (hi->encoding == OBJ_ENCODING_HT) {
hi->di = dictGetIterator(subject->ptr);
} else {
redisPanic("Unknown hash encoding");
@@ -313,7 +313,7 @@ hashTypeIterator *hashTypeInitIterator(robj *subject) {
}
void hashTypeReleaseIterator(hashTypeIterator *hi) {
- if (hi->encoding == REDIS_ENCODING_HT) {
+ if (hi->encoding == OBJ_ENCODING_HT) {
dictReleaseIterator(hi->di);
}
@@ -323,7 +323,7 @@ void hashTypeReleaseIterator(hashTypeIterator *hi) {
/* Move to the next entry in the hash. Return REDIS_OK when the next entry
* could be found and REDIS_ERR when the iterator reaches the end. */
int hashTypeNext(hashTypeIterator *hi) {
- if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl;
unsigned char *fptr, *vptr;
@@ -349,7 +349,7 @@ int hashTypeNext(hashTypeIterator *hi) {
/* fptr, vptr now point to the first or next pair */
hi->fptr = fptr;
hi->vptr = vptr;
- } else if (hi->encoding == REDIS_ENCODING_HT) {
+ } else if (hi->encoding == OBJ_ENCODING_HT) {
if ((hi->de = dictNext(hi->di)) == NULL) return REDIS_ERR;
} else {
redisPanic("Unknown hash encoding");
@@ -366,9 +366,9 @@ void hashTypeCurrentFromZiplist(hashTypeIterator *hi, int what,
{
int ret;
- redisAssert(hi->encoding == REDIS_ENCODING_ZIPLIST);
+ redisAssert(hi->encoding == OBJ_ENCODING_ZIPLIST);
- if (what & REDIS_HASH_KEY) {
+ if (what & OBJ_HASH_KEY) {
ret = ziplistGet(hi->fptr, vstr, vlen, vll);
redisAssert(ret);
} else {
@@ -380,9 +380,9 @@ void hashTypeCurrentFromZiplist(hashTypeIterator *hi, int what,
/* Get the field or value at iterator cursor, for an iterator on a hash value
* encoded as a ziplist. Prototype is similar to `hashTypeGetFromHashTable`. */
void hashTypeCurrentFromHashTable(hashTypeIterator *hi, int what, robj **dst) {
- redisAssert(hi->encoding == REDIS_ENCODING_HT);
+ redisAssert(hi->encoding == OBJ_ENCODING_HT);
- if (what & REDIS_HASH_KEY) {
+ if (what & OBJ_HASH_KEY) {
*dst = dictGetKey(hi->de);
} else {
*dst = dictGetVal(hi->de);
@@ -395,7 +395,7 @@ void hashTypeCurrentFromHashTable(hashTypeIterator *hi, int what, robj **dst) {
robj *hashTypeCurrentObject(hashTypeIterator *hi, int what) {
robj *dst;
- if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;
unsigned int vlen = UINT_MAX;
long long vll = LLONG_MAX;
@@ -406,7 +406,7 @@ robj *hashTypeCurrentObject(hashTypeIterator *hi, int what) {
} else {
dst = createStringObjectFromLongLong(vll);
}
- } else if (hi->encoding == REDIS_ENCODING_HT) {
+ } else if (hi->encoding == OBJ_ENCODING_HT) {
hashTypeCurrentFromHashTable(hi, what, &dst);
incrRefCount(dst);
} else {
@@ -421,7 +421,7 @@ robj *hashTypeLookupWriteOrCreate(client *c, robj *key) {
o = createHashObject();
dbAdd(c->db,key,o);
} else {
- if (o->type != REDIS_HASH) {
+ if (o->type != OBJ_HASH) {
addReply(c,shared.wrongtypeerr);
return NULL;
}
@@ -430,12 +430,12 @@ robj *hashTypeLookupWriteOrCreate(client *c, robj *key) {
}
void hashTypeConvertZiplist(robj *o, int enc) {
- redisAssert(o->encoding == REDIS_ENCODING_ZIPLIST);
+ redisAssert(o->encoding == OBJ_ENCODING_ZIPLIST);
- if (enc == REDIS_ENCODING_ZIPLIST) {
+ if (enc == OBJ_ENCODING_ZIPLIST) {
/* Nothing to do... */
- } else if (enc == REDIS_ENCODING_HT) {
+ } else if (enc == OBJ_ENCODING_HT) {
hashTypeIterator *hi;
dict *dict;
int ret;
@@ -446,9 +446,9 @@ void hashTypeConvertZiplist(robj *o, int enc) {
while (hashTypeNext(hi) != REDIS_ERR) {
robj *field, *value;
- field = hashTypeCurrentObject(hi, REDIS_HASH_KEY);
+ field = hashTypeCurrentObject(hi, OBJ_HASH_KEY);
field = tryObjectEncoding(field);
- value = hashTypeCurrentObject(hi, REDIS_HASH_VALUE);
+ value = hashTypeCurrentObject(hi, OBJ_HASH_VALUE);
value = tryObjectEncoding(value);
ret = dictAdd(dict, field, value);
if (ret != DICT_OK) {
@@ -461,7 +461,7 @@ void hashTypeConvertZiplist(robj *o, int enc) {
hashTypeReleaseIterator(hi);
zfree(o->ptr);
- o->encoding = REDIS_ENCODING_HT;
+ o->encoding = OBJ_ENCODING_HT;
o->ptr = dict;
} else {
@@ -470,9 +470,9 @@ void hashTypeConvertZiplist(robj *o, int enc) {
}
void hashTypeConvert(robj *o, int enc) {
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
hashTypeConvertZiplist(o, enc);
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
redisPanic("Not implemented");
} else {
redisPanic("Unknown hash encoding");
@@ -613,7 +613,7 @@ static void addHashFieldToReply(client *c, robj *o, robj *field) {
return;
}
- if (o->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (o->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;
unsigned int vlen = UINT_MAX;
long long vll = LLONG_MAX;
@@ -629,7 +629,7 @@ static void addHashFieldToReply(client *c, robj *o, robj *field) {
}
}
- } else if (o->encoding == REDIS_ENCODING_HT) {
+ } else if (o->encoding == OBJ_ENCODING_HT) {
robj *value;
ret = hashTypeGetFromHashTable(o, field, &value);
@@ -648,7 +648,7 @@ void hgetCommand(client *c) {
robj *o;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
- checkType(c,o,REDIS_HASH)) return;
+ checkType(c,o,OBJ_HASH)) return;
addHashFieldToReply(c, o, c->argv[2]);
}
@@ -660,7 +660,7 @@ void hmgetCommand(client *c) {
/* Don't abort when the key cannot be found. Non-existing keys are empty
* hashes, where HMGET should respond with a series of null bulks. */
o = lookupKeyRead(c->db, c->argv[1]);
- if (o != NULL && o->type != REDIS_HASH) {
+ if (o != NULL && o->type != OBJ_HASH) {
addReply(c, shared.wrongtypeerr);
return;
}
@@ -676,7 +676,7 @@ void hdelCommand(client *c) {
int j, deleted = 0, keyremoved = 0;
if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_HASH)) return;
+ checkType(c,o,OBJ_HASH)) return;
for (j = 2; j < c->argc; j++) {
if (hashTypeDelete(o,c->argv[j])) {
@@ -703,7 +703,7 @@ void hlenCommand(client *c) {
robj *o;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_HASH)) return;
+ checkType(c,o,OBJ_HASH)) return;
addReplyLongLong(c,hashTypeLength(o));
}
@@ -712,12 +712,12 @@ void hstrlenCommand(client *c) {
robj *o;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_HASH)) return;
+ checkType(c,o,OBJ_HASH)) return;
addReplyLongLong(c,hashTypeGetValueLength(o,c->argv[2]));
}
static void addHashIteratorCursorToReply(client *c, hashTypeIterator *hi, int what) {
- if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (hi->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;
unsigned int vlen = UINT_MAX;
long long vll = LLONG_MAX;
@@ -729,7 +729,7 @@ static void addHashIteratorCursorToReply(client *c, hashTypeIterator *hi, int wh
addReplyBulkLongLong(c, vll);
}
- } else if (hi->encoding == REDIS_ENCODING_HT) {
+ } else if (hi->encoding == OBJ_ENCODING_HT) {
robj *value;
hashTypeCurrentFromHashTable(hi, what, &value);
@@ -747,22 +747,22 @@ void genericHgetallCommand(client *c, int flags) {
int length, count = 0;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk)) == NULL
- || checkType(c,o,REDIS_HASH)) return;
+ || checkType(c,o,OBJ_HASH)) return;
- if (flags & REDIS_HASH_KEY) multiplier++;
- if (flags & REDIS_HASH_VALUE) multiplier++;
+ if (flags & OBJ_HASH_KEY) multiplier++;
+ if (flags & OBJ_HASH_VALUE) multiplier++;
length = hashTypeLength(o) * multiplier;
addReplyMultiBulkLen(c, length);
hi = hashTypeInitIterator(o);
while (hashTypeNext(hi) != REDIS_ERR) {
- if (flags & REDIS_HASH_KEY) {
- addHashIteratorCursorToReply(c, hi, REDIS_HASH_KEY);
+ if (flags & OBJ_HASH_KEY) {
+ addHashIteratorCursorToReply(c, hi, OBJ_HASH_KEY);
count++;
}
- if (flags & REDIS_HASH_VALUE) {
- addHashIteratorCursorToReply(c, hi, REDIS_HASH_VALUE);
+ if (flags & OBJ_HASH_VALUE) {
+ addHashIteratorCursorToReply(c, hi, OBJ_HASH_VALUE);
count++;
}
}
@@ -772,21 +772,21 @@ void genericHgetallCommand(client *c, int flags) {
}
void hkeysCommand(client *c) {
- genericHgetallCommand(c,REDIS_HASH_KEY);
+ genericHgetallCommand(c,OBJ_HASH_KEY);
}
void hvalsCommand(client *c) {
- genericHgetallCommand(c,REDIS_HASH_VALUE);
+ genericHgetallCommand(c,OBJ_HASH_VALUE);
}
void hgetallCommand(client *c) {
- genericHgetallCommand(c,REDIS_HASH_KEY|REDIS_HASH_VALUE);
+ genericHgetallCommand(c,OBJ_HASH_KEY|OBJ_HASH_VALUE);
}
void hexistsCommand(client *c) {
robj *o;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_HASH)) return;
+ checkType(c,o,OBJ_HASH)) return;
addReply(c, hashTypeExists(o,c->argv[2]) ? shared.cone : shared.czero);
}
@@ -797,6 +797,6 @@ void hscanCommand(client *c) {
if (parseScanCursorOrReply(c,c->argv[2],&cursor) == REDIS_ERR) return;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL ||
- checkType(c,o,REDIS_HASH)) return;
+ checkType(c,o,OBJ_HASH)) return;
scanGenericCommand(c,o,cursor);
}
diff --git a/src/t_list.c b/src/t_list.c
index 638290ead..b01df6698 100644
--- a/src/t_list.c
+++ b/src/t_list.c
@@ -39,7 +39,7 @@
* There is no need for the caller to increment the refcount of 'value' as
* the function takes care of it if needed. */
void listTypePush(robj *subject, robj *value, int where) {
- if (subject->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (subject->encoding == OBJ_ENCODING_QUICKLIST) {
int pos = (where == REDIS_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL;
value = getDecodedObject(value);
size_t len = sdslen(value->ptr);
@@ -59,7 +59,7 @@ robj *listTypePop(robj *subject, int where) {
robj *value = NULL;
int ql_where = where == REDIS_HEAD ? QUICKLIST_HEAD : QUICKLIST_TAIL;
- if (subject->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (subject->encoding == OBJ_ENCODING_QUICKLIST) {
if (quicklistPopCustom(subject->ptr, ql_where, (unsigned char **)&value,
NULL, &vlong, listPopSaver)) {
if (!value)
@@ -72,7 +72,7 @@ robj *listTypePop(robj *subject, int where) {
}
unsigned long listTypeLength(robj *subject) {
- if (subject->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (subject->encoding == OBJ_ENCODING_QUICKLIST) {
return quicklistCount(subject->ptr);
} else {
redisPanic("Unknown list encoding");
@@ -91,7 +91,7 @@ listTypeIterator *listTypeInitIterator(robj *subject, long index,
* REDIS_TAIL means start at HEAD and move *towards tail. */
int iter_direction =
direction == REDIS_HEAD ? AL_START_TAIL : AL_START_HEAD;
- if (li->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (li->encoding == OBJ_ENCODING_QUICKLIST) {
li->iter = quicklistGetIteratorAtIdx(li->subject->ptr,
iter_direction, index);
} else {
@@ -114,7 +114,7 @@ int listTypeNext(listTypeIterator *li, listTypeEntry *entry) {
redisAssert(li->subject->encoding == li->encoding);
entry->li = li;
- if (li->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (li->encoding == OBJ_ENCODING_QUICKLIST) {
return quicklistNext(li->iter, &entry->entry);
} else {
redisPanic("Unknown list encoding");
@@ -125,7 +125,7 @@ int listTypeNext(listTypeIterator *li, listTypeEntry *entry) {
/* Return entry or NULL at the current position of the iterator. */
robj *listTypeGet(listTypeEntry *entry) {
robj *value = NULL;
- if (entry->li->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (entry->li->encoding == OBJ_ENCODING_QUICKLIST) {
if (entry->entry.value) {
value = createStringObject((char *)entry->entry.value,
entry->entry.sz);
@@ -139,7 +139,7 @@ robj *listTypeGet(listTypeEntry *entry) {
}
void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
- if (entry->li->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (entry->li->encoding == OBJ_ENCODING_QUICKLIST) {
value = getDecodedObject(value);
sds str = value->ptr;
size_t len = sdslen(str);
@@ -158,7 +158,7 @@ void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
/* Compare the given object with the entry at the current position. */
int listTypeEqual(listTypeEntry *entry, robj *o) {
- if (entry->li->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (entry->li->encoding == OBJ_ENCODING_QUICKLIST) {
redisAssertWithInfo(NULL,o,sdsEncodedObject(o));
return quicklistCompare(entry->entry.zi,o->ptr,sdslen(o->ptr));
} else {
@@ -168,7 +168,7 @@ int listTypeEqual(listTypeEntry *entry, robj *o) {
/* Delete the element pointed to. */
void listTypeDelete(listTypeIterator *iter, listTypeEntry *entry) {
- if (entry->li->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (entry->li->encoding == OBJ_ENCODING_QUICKLIST) {
quicklistDelEntry(iter->iter, &entry->entry);
} else {
redisPanic("Unknown list encoding");
@@ -177,14 +177,14 @@ void listTypeDelete(listTypeIterator *iter, listTypeEntry *entry) {
/* Create a quicklist from a single ziplist */
void listTypeConvert(robj *subject, int enc) {
- redisAssertWithInfo(NULL,subject,subject->type==REDIS_LIST);
- redisAssertWithInfo(NULL,subject,subject->encoding==REDIS_ENCODING_ZIPLIST);
+ redisAssertWithInfo(NULL,subject,subject->type==OBJ_LIST);
+ redisAssertWithInfo(NULL,subject,subject->encoding==OBJ_ENCODING_ZIPLIST);
- if (enc == REDIS_ENCODING_QUICKLIST) {
+ if (enc == OBJ_ENCODING_QUICKLIST) {
size_t zlen = server.list_max_ziplist_size;
int depth = server.list_compress_depth;
subject->ptr = quicklistCreateFromZiplist(zlen, depth, subject->ptr);
- subject->encoding = REDIS_ENCODING_QUICKLIST;
+ subject->encoding = OBJ_ENCODING_QUICKLIST;
} else {
redisPanic("Unsupported list conversion");
}
@@ -198,7 +198,7 @@ void pushGenericCommand(client *c, int where) {
int j, waiting = 0, pushed = 0;
robj *lobj = lookupKeyWrite(c->db,c->argv[1]);
- if (lobj && lobj->type != REDIS_LIST) {
+ if (lobj && lobj->type != OBJ_LIST) {
addReply(c,shared.wrongtypeerr);
return;
}
@@ -239,7 +239,7 @@ void pushxGenericCommand(client *c, robj *refval, robj *val, int where) {
int inserted = 0;
if ((subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,subject,REDIS_LIST)) return;
+ checkType(c,subject,OBJ_LIST)) return;
if (refval != NULL) {
/* Seek refval from head to tail */
@@ -298,20 +298,20 @@ void linsertCommand(client *c) {
void llenCommand(client *c) {
robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.czero);
- if (o == NULL || checkType(c,o,REDIS_LIST)) return;
+ if (o == NULL || checkType(c,o,OBJ_LIST)) return;
addReplyLongLong(c,listTypeLength(o));
}
void lindexCommand(client *c) {
robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk);
- if (o == NULL || checkType(c,o,REDIS_LIST)) return;
+ if (o == NULL || checkType(c,o,OBJ_LIST)) return;
long index;
robj *value = NULL;
if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != REDIS_OK))
return;
- if (o->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (o->encoding == OBJ_ENCODING_QUICKLIST) {
quicklistEntry entry;
if (quicklistIndex(o->ptr, index, &entry)) {
if (entry.value) {
@@ -331,14 +331,14 @@ void lindexCommand(client *c) {
void lsetCommand(client *c) {
robj *o = lookupKeyWriteOrReply(c,c->argv[1],shared.nokeyerr);
- if (o == NULL || checkType(c,o,REDIS_LIST)) return;
+ if (o == NULL || checkType(c,o,OBJ_LIST)) return;
long index;
robj *value = c->argv[3];
if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != REDIS_OK))
return;
- if (o->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (o->encoding == OBJ_ENCODING_QUICKLIST) {
quicklist *ql = o->ptr;
int replaced = quicklistReplaceAtIndex(ql, index,
value->ptr, sdslen(value->ptr));
@@ -357,7 +357,7 @@ void lsetCommand(client *c) {
void popGenericCommand(client *c, int where) {
robj *o = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk);
- if (o == NULL || checkType(c,o,REDIS_LIST)) return;
+ if (o == NULL || checkType(c,o,OBJ_LIST)) return;
robj *value = listTypePop(o,where);
if (value == NULL) {
@@ -394,7 +394,7 @@ void lrangeCommand(client *c) {
(getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != REDIS_OK)) return;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk)) == NULL
- || checkType(c,o,REDIS_LIST)) return;
+ || checkType(c,o,OBJ_LIST)) return;
llen = listTypeLength(o);
/* convert negative indexes */
@@ -413,7 +413,7 @@ void lrangeCommand(client *c) {
/* Return the result in form of a multi-bulk reply */
addReplyMultiBulkLen(c,rangelen);
- if (o->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (o->encoding == OBJ_ENCODING_QUICKLIST) {
listTypeIterator *iter = listTypeInitIterator(o, start, REDIS_TAIL);
while(rangelen--) {
@@ -440,7 +440,7 @@ void ltrimCommand(client *c) {
(getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != REDIS_OK)) return;
if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.ok)) == NULL ||
- checkType(c,o,REDIS_LIST)) return;
+ checkType(c,o,OBJ_LIST)) return;
llen = listTypeLength(o);
/* convert negative indexes */
@@ -461,7 +461,7 @@ void ltrimCommand(client *c) {
}
/* Remove list elements to perform the trim */
- if (o->encoding == REDIS_ENCODING_QUICKLIST) {
+ if (o->encoding == OBJ_ENCODING_QUICKLIST) {
quicklistDelRange(o->ptr,0,ltrim);
quicklistDelRange(o->ptr,-rtrim,rtrim);
} else {
@@ -488,7 +488,7 @@ void lremCommand(client *c) {
return;
subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero);
- if (subject == NULL || checkType(c,subject,REDIS_LIST)) return;
+ if (subject == NULL || checkType(c,subject,OBJ_LIST)) return;
listTypeIterator *li;
if (toremove < 0) {
@@ -551,7 +551,7 @@ void rpoplpushHandlePush(client *c, robj *dstkey, robj *dstobj, robj *value) {
void rpoplpushCommand(client *c) {
robj *sobj, *value;
if ((sobj = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
- checkType(c,sobj,REDIS_LIST)) return;
+ checkType(c,sobj,OBJ_LIST)) return;
if (listTypeLength(sobj) == 0) {
/* This may only happen after loading very old RDB files. Recent
@@ -561,7 +561,7 @@ void rpoplpushCommand(client *c) {
robj *dobj = lookupKeyWrite(c->db,c->argv[2]);
robj *touchedkey = c->argv[1];
- if (dobj && checkType(c,dobj,REDIS_LIST)) return;
+ if (dobj && checkType(c,dobj,OBJ_LIST)) return;
value = listTypePop(sobj,REDIS_TAIL);
/* We saved touched key, and protect it, since rpoplpushHandlePush
* may change the client command argument vector (it does not
@@ -743,7 +743,7 @@ int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, redisDb
robj *dstobj =
lookupKeyWrite(receiver->db,dstkey);
if (!(dstobj &&
- checkType(receiver,dstobj,REDIS_LIST)))
+ checkType(receiver,dstobj,OBJ_LIST)))
{
/* Propagate the RPOP operation. */
argv[0] = shared.rpop;
@@ -803,7 +803,7 @@ void handleClientsBlockedOnLists(void) {
/* If the key exists and it's a list, serve blocked clients
* with data. */
robj *o = lookupKeyWrite(rl->db,rl->key);
- if (o != NULL && o->type == REDIS_LIST) {
+ if (o != NULL && o->type == OBJ_LIST) {
dictEntry *de;
/* We serve clients in the same order they blocked for
@@ -874,7 +874,7 @@ void blockingPopGenericCommand(client *c, int where) {
for (j = 1; j < c->argc-1; j++) {
o = lookupKeyWrite(c->db,c->argv[j]);
if (o != NULL) {
- if (o->type != REDIS_LIST) {
+ if (o->type != OBJ_LIST) {
addReply(c,shared.wrongtypeerr);
return;
} else {
@@ -945,7 +945,7 @@ void brpoplpushCommand(client *c) {
blockForKeys(c, c->argv + 1, 1, timeout, c->argv[2]);
}
} else {
- if (key->type != REDIS_LIST) {
+ if (key->type != OBJ_LIST) {
addReply(c, shared.wrongtypeerr);
} else {
/* The list exists and has elements, so
diff --git a/src/t_set.c b/src/t_set.c
index 6736fb844..f71f5de48 100644
--- a/src/t_set.c
+++ b/src/t_set.c
@@ -52,12 +52,12 @@ robj *setTypeCreate(robj *value) {
* returned, otherwise the new element is added and 1 is returned. */
int setTypeAdd(robj *subject, robj *value) {
long long llval;
- if (subject->encoding == REDIS_ENCODING_HT) {
+ if (subject->encoding == OBJ_ENCODING_HT) {
if (dictAdd(subject->ptr,value,NULL) == DICT_OK) {
incrRefCount(value);
return 1;
}
- } else if (subject->encoding == REDIS_ENCODING_INTSET) {
+ } else if (subject->encoding == OBJ_ENCODING_INTSET) {
if (isObjectRepresentableAsLongLong(value,&llval) == REDIS_OK) {
uint8_t success = 0;
subject->ptr = intsetAdd(subject->ptr,llval,&success);
@@ -65,12 +65,12 @@ int setTypeAdd(robj *subject, robj *value) {
/* Convert to regular set when the intset contains
* too many entries. */
if (intsetLen(subject->ptr) > server.set_max_intset_entries)
- setTypeConvert(subject,REDIS_ENCODING_HT);
+ setTypeConvert(subject,OBJ_ENCODING_HT);
return 1;
}
} else {
/* Failed to get integer from object, convert to regular set. */
- setTypeConvert(subject,REDIS_ENCODING_HT);
+ setTypeConvert(subject,OBJ_ENCODING_HT);
/* The set *was* an intset and this value is not integer
* encodable, so dictAdd should always work. */
@@ -87,12 +87,12 @@ int setTypeAdd(robj *subject, robj *value) {
int setTypeRemove(robj *setobj, robj *value) {
long long llval;
- if (setobj->encoding == REDIS_ENCODING_HT) {
+ if (setobj->encoding == OBJ_ENCODING_HT) {
if (dictDelete(setobj->ptr,value) == DICT_OK) {
if (htNeedsResize(setobj->ptr)) dictResize(setobj->ptr);
return 1;
}
- } else if (setobj->encoding == REDIS_ENCODING_INTSET) {
+ } else if (setobj->encoding == OBJ_ENCODING_INTSET) {
if (isObjectRepresentableAsLongLong(value,&llval) == REDIS_OK) {
int success;
setobj->ptr = intsetRemove(setobj->ptr,llval,&success);
@@ -106,9 +106,9 @@ int setTypeRemove(robj *setobj, robj *value) {
int setTypeIsMember(robj *subject, robj *value) {
long long llval;
- if (subject->encoding == REDIS_ENCODING_HT) {
+ if (subject->encoding == OBJ_ENCODING_HT) {
return dictFind((dict*)subject->ptr,value) != NULL;
- } else if (subject->encoding == REDIS_ENCODING_INTSET) {
+ } else if (subject->encoding == OBJ_ENCODING_INTSET) {
if (isObjectRepresentableAsLongLong(value,&llval) == REDIS_OK) {
return intsetFind((intset*)subject->ptr,llval);
}
@@ -122,9 +122,9 @@ setTypeIterator *setTypeInitIterator(robj *subject) {
setTypeIterator *si = zmalloc(sizeof(setTypeIterator));
si->subject = subject;
si->encoding = subject->encoding;
- if (si->encoding == REDIS_ENCODING_HT) {
+ if (si->encoding == OBJ_ENCODING_HT) {
si->di = dictGetIterator(subject->ptr);
- } else if (si->encoding == REDIS_ENCODING_INTSET) {
+ } else if (si->encoding == OBJ_ENCODING_INTSET) {
si->ii = 0;
} else {
redisPanic("Unknown set encoding");
@@ -133,7 +133,7 @@ setTypeIterator *setTypeInitIterator(robj *subject) {
}
void setTypeReleaseIterator(setTypeIterator *si) {
- if (si->encoding == REDIS_ENCODING_HT)
+ if (si->encoding == OBJ_ENCODING_HT)
dictReleaseIterator(si->di);
zfree(si);
}
@@ -154,12 +154,12 @@ void setTypeReleaseIterator(setTypeIterator *si) {
* Returned objects ref count is not incremented, so this function is
* copy on write friendly. */
int setTypeNext(setTypeIterator *si, robj **objele, int64_t *llele) {
- if (si->encoding == REDIS_ENCODING_HT) {
+ if (si->encoding == OBJ_ENCODING_HT) {
dictEntry *de = dictNext(si->di);
if (de == NULL) return -1;
*objele = dictGetKey(de);
*llele = -123456789; /* Not needed. Defensive. */
- } else if (si->encoding == REDIS_ENCODING_INTSET) {
+ } else if (si->encoding == OBJ_ENCODING_INTSET) {
if (!intsetGet(si->subject->ptr,si->ii++,llele))
return -1;
*objele = NULL; /* Not needed. Defensive. */
@@ -184,9 +184,9 @@ robj *setTypeNextObject(setTypeIterator *si) {
encoding = setTypeNext(si,&objele,&intele);
switch(encoding) {
case -1: return NULL;
- case REDIS_ENCODING_INTSET:
+ case OBJ_ENCODING_INTSET:
return createStringObjectFromLongLong(intele);
- case REDIS_ENCODING_HT:
+ case OBJ_ENCODING_HT:
incrRefCount(objele);
return objele;
default:
@@ -213,11 +213,11 @@ robj *setTypeNextObject(setTypeIterator *si) {
* of the object is not incremented so this function can be considered
* copy on write friendly. */
int setTypeRandomElement(robj *setobj, robj **objele, int64_t *llele) {
- if (setobj->encoding == REDIS_ENCODING_HT) {
+ if (setobj->encoding == OBJ_ENCODING_HT) {
dictEntry *de = dictGetRandomKey(setobj->ptr);
*objele = dictGetKey(de);
*llele = -123456789; /* Not needed. Defensive. */
- } else if (setobj->encoding == REDIS_ENCODING_INTSET) {
+ } else if (setobj->encoding == OBJ_ENCODING_INTSET) {
*llele = intsetRandom(setobj->ptr);
*objele = NULL; /* Not needed. Defensive. */
} else {
@@ -227,9 +227,9 @@ int setTypeRandomElement(robj *setobj, robj **objele, int64_t *llele) {
}
unsigned long setTypeSize(robj *subject) {
- if (subject->encoding == REDIS_ENCODING_HT) {
+ if (subject->encoding == OBJ_ENCODING_HT) {
return dictSize((dict*)subject->ptr);
- } else if (subject->encoding == REDIS_ENCODING_INTSET) {
+ } else if (subject->encoding == OBJ_ENCODING_INTSET) {
return intsetLen((intset*)subject->ptr);
} else {
redisPanic("Unknown set encoding");
@@ -241,10 +241,10 @@ unsigned long setTypeSize(robj *subject) {
* set. */
void setTypeConvert(robj *setobj, int enc) {
setTypeIterator *si;
- redisAssertWithInfo(NULL,setobj,setobj->type == REDIS_SET &&
- setobj->encoding == REDIS_ENCODING_INTSET);
+ redisAssertWithInfo(NULL,setobj,setobj->type == OBJ_SET &&
+ setobj->encoding == OBJ_ENCODING_INTSET);
- if (enc == REDIS_ENCODING_HT) {
+ if (enc == OBJ_ENCODING_HT) {
int64_t intele;
dict *d = dictCreate(&setDictType,NULL);
robj *element;
@@ -261,7 +261,7 @@ void setTypeConvert(robj *setobj, int enc) {
}
setTypeReleaseIterator(si);
- setobj->encoding = REDIS_ENCODING_HT;
+ setobj->encoding = OBJ_ENCODING_HT;
zfree(setobj->ptr);
setobj->ptr = d;
} else {
@@ -278,7 +278,7 @@ void saddCommand(client *c) {
set = setTypeCreate(c->argv[2]);
dbAdd(c->db,c->argv[1],set);
} else {
- if (set->type != REDIS_SET) {
+ if (set->type != OBJ_SET) {
addReply(c,shared.wrongtypeerr);
return;
}
@@ -301,7 +301,7 @@ void sremCommand(client *c) {
int j, deleted = 0, keyremoved = 0;
if ((set = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,set,REDIS_SET)) return;
+ checkType(c,set,OBJ_SET)) return;
for (j = 2; j < c->argc; j++) {
if (setTypeRemove(set,c->argv[j])) {
@@ -338,8 +338,8 @@ void smoveCommand(client *c) {
/* If the source key has the wrong type, or the destination key
* is set and has the wrong type, return with an error. */
- if (checkType(c,srcset,REDIS_SET) ||
- (dstset && checkType(c,dstset,REDIS_SET))) return;
+ if (checkType(c,srcset,OBJ_SET) ||
+ (dstset && checkType(c,dstset,OBJ_SET))) return;
/* If srcset and dstset are equal, SMOVE is a no-op */
if (srcset == dstset) {
@@ -381,7 +381,7 @@ void sismemberCommand(client *c) {
robj *set;
if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,set,REDIS_SET)) return;
+ checkType(c,set,OBJ_SET)) return;
c->argv[2] = tryObjectEncoding(c->argv[2]);
if (setTypeIsMember(set,c->argv[2]))
@@ -394,7 +394,7 @@ void scardCommand(client *c) {
robj *o;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_SET)) return;
+ checkType(c,o,OBJ_SET)) return;
addReplyLongLong(c,setTypeSize(o));
}
@@ -424,7 +424,7 @@ void spopWithCountCommand(client *c) {
/* Make sure a key with the name inputted exists, and that it's type is
* indeed a set. Otherwise, return nil */
if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk))
- == NULL || checkType(c,set,REDIS_SET)) return;
+ == NULL || checkType(c,set,OBJ_SET)) return;
/* If count is zero, serve an empty multibulk ASAP to avoid special
* cases later. */
@@ -481,7 +481,7 @@ void spopWithCountCommand(client *c) {
if (remaining*SPOP_MOVE_STRATEGY_MUL > count) {
while(count--) {
encoding = setTypeRandomElement(set,&objele,&llele);
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
objele = createStringObjectFromLongLong(llele);
} else {
incrRefCount(objele);
@@ -511,7 +511,7 @@ void spopWithCountCommand(client *c) {
/* Create a new set with just the remaining elements. */
while(remaining--) {
encoding = setTypeRandomElement(set,&objele,&llele);
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
objele = createStringObjectFromLongLong(llele);
} else {
incrRefCount(objele);
@@ -530,7 +530,7 @@ void spopWithCountCommand(client *c) {
setTypeIterator *si;
si = setTypeInitIterator(set);
while((encoding = setTypeNext(si,&objele,&llele)) != -1) {
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
objele = createStringObjectFromLongLong(llele);
} else {
incrRefCount(objele);
@@ -572,13 +572,13 @@ void spopCommand(client *c) {
/* Make sure a key with the name inputted exists, and that it's type is
* indeed a set */
if ((set = lookupKeyWriteOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
- checkType(c,set,REDIS_SET)) return;
+ checkType(c,set,OBJ_SET)) return;
/* Get a random element from the set */
encoding = setTypeRandomElement(set,&ele,&llele);
/* Remove the element from the set */
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
ele = createStringObjectFromLongLong(llele);
set->ptr = intsetRemove(set->ptr,llele,NULL);
} else {
@@ -637,7 +637,7 @@ void srandmemberWithCountCommand(client *c) {
}
if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk))
- == NULL || checkType(c,set,REDIS_SET)) return;
+ == NULL || checkType(c,set,OBJ_SET)) return;
size = setTypeSize(set);
/* If count is zero, serve it ASAP to avoid special cases later. */
@@ -654,7 +654,7 @@ void srandmemberWithCountCommand(client *c) {
addReplyMultiBulkLen(c,count);
while(count--) {
encoding = setTypeRandomElement(set,&ele,&llele);
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
addReplyBulkLongLong(c,llele);
} else {
addReplyBulk(c,ele);
@@ -691,7 +691,7 @@ void srandmemberWithCountCommand(client *c) {
while((encoding = setTypeNext(si,&ele,&llele)) != -1) {
int retval = DICT_ERR;
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
retval = dictAdd(d,createStringObjectFromLongLong(llele),NULL);
} else {
retval = dictAdd(d,dupStringObject(ele),NULL);
@@ -720,7 +720,7 @@ void srandmemberWithCountCommand(client *c) {
while(added < count) {
encoding = setTypeRandomElement(set,&ele,&llele);
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
ele = createStringObjectFromLongLong(llele);
} else {
ele = dupStringObject(ele);
@@ -763,10 +763,10 @@ void srandmemberCommand(client *c) {
}
if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
- checkType(c,set,REDIS_SET)) return;
+ checkType(c,set,OBJ_SET)) return;
encoding = setTypeRandomElement(set,&ele,&llele);
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
addReplyBulkLongLong(c,llele);
} else {
addReplyBulk(c,ele);
@@ -812,7 +812,7 @@ void sinterGenericCommand(client *c, robj **setkeys,
}
return;
}
- if (checkType(c,setobj,REDIS_SET)) {
+ if (checkType(c,setobj,OBJ_SET)) {
zfree(sets);
return;
}
@@ -842,16 +842,16 @@ void sinterGenericCommand(client *c, robj **setkeys,
while((encoding = setTypeNext(si,&eleobj,&intobj)) != -1) {
for (j = 1; j < setnum; j++) {
if (sets[j] == sets[0]) continue;
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
/* intset with intset is simple... and fast */
- if (sets[j]->encoding == REDIS_ENCODING_INTSET &&
+ if (sets[j]->encoding == OBJ_ENCODING_INTSET &&
!intsetFind((intset*)sets[j]->ptr,intobj))
{
break;
/* in order to compare an integer with an object we
* have to use the generic function, creating an object
* for this */
- } else if (sets[j]->encoding == REDIS_ENCODING_HT) {
+ } else if (sets[j]->encoding == OBJ_ENCODING_HT) {
eleobj = createStringObjectFromLongLong(intobj);
if (!setTypeIsMember(sets[j],eleobj)) {
decrRefCount(eleobj);
@@ -859,12 +859,12 @@ void sinterGenericCommand(client *c, robj **setkeys,
}
decrRefCount(eleobj);
}
- } else if (encoding == REDIS_ENCODING_HT) {
+ } else if (encoding == OBJ_ENCODING_HT) {
/* Optimization... if the source object is integer
* encoded AND the target set is an intset, we can get
* a much faster path. */
- if (eleobj->encoding == REDIS_ENCODING_INT &&
- sets[j]->encoding == REDIS_ENCODING_INTSET &&
+ if (eleobj->encoding == OBJ_ENCODING_INT &&
+ sets[j]->encoding == OBJ_ENCODING_INTSET &&
!intsetFind((intset*)sets[j]->ptr,(long)eleobj->ptr))
{
break;
@@ -879,13 +879,13 @@ void sinterGenericCommand(client *c, robj **setkeys,
/* Only take action when all sets contain the member */
if (j == setnum) {
if (!dstkey) {
- if (encoding == REDIS_ENCODING_HT)
+ if (encoding == OBJ_ENCODING_HT)
addReplyBulk(c,eleobj);
else
addReplyBulkLongLong(c,intobj);
cardinality++;
} else {
- if (encoding == REDIS_ENCODING_INTSET) {
+ if (encoding == OBJ_ENCODING_INTSET) {
eleobj = createStringObjectFromLongLong(intobj);
setTypeAdd(dstset,eleobj);
decrRefCount(eleobj);
@@ -949,7 +949,7 @@ void sunionDiffGenericCommand(client *c, robj **setkeys, int setnum,
sets[j] = NULL;
continue;
}
- if (checkType(c,setobj,REDIS_SET)) {
+ if (checkType(c,setobj,OBJ_SET)) {
zfree(sets);
return;
}
@@ -1114,6 +1114,6 @@ void sscanCommand(client *c) {
if (parseScanCursorOrReply(c,c->argv[2],&cursor) == REDIS_ERR) return;
if ((set = lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL ||
- checkType(c,set,REDIS_SET)) return;
+ checkType(c,set,OBJ_SET)) return;
scanGenericCommand(c,set,cursor);
}
diff --git a/src/t_string.c b/src/t_string.c
index 5cc428ec4..5bc1534e5 100644
--- a/src/t_string.c
+++ b/src/t_string.c
@@ -58,11 +58,11 @@ static int checkStringLength(client *c, long long size) {
* If ok_reply is NULL "+OK" is used.
* If abort_reply is NULL, "$-1" is used. */
-#define REDIS_SET_NO_FLAGS 0
-#define REDIS_SET_NX (1<<0) /* Set if key not exists. */
-#define REDIS_SET_XX (1<<1) /* Set if key exists. */
-#define REDIS_SET_EX (1<<2) /* Set if time in seconds is given */
-#define REDIS_SET_PX (1<<3) /* Set if time in ms in given */
+#define OBJ_SET_NO_FLAGS 0
+#define OBJ_SET_NX (1<<0) /* Set if key not exists. */
+#define OBJ_SET_XX (1<<1) /* Set if key exists. */
+#define OBJ_SET_EX (1<<2) /* Set if time in seconds is given */
+#define OBJ_SET_PX (1<<3) /* Set if time in ms in given */
void setGenericCommand(client *c, int flags, robj *key, robj *val, robj *expire, int unit, robj *ok_reply, robj *abort_reply) {
long long milliseconds = 0; /* initialized to avoid any harmness warning */
@@ -77,8 +77,8 @@ void setGenericCommand(client *c, int flags, robj *key, robj *val, robj *expire,
if (unit == UNIT_SECONDS) milliseconds *= 1000;
}
- if ((flags & REDIS_SET_NX && lookupKeyWrite(c->db,key) != NULL) ||
- (flags & REDIS_SET_XX && lookupKeyWrite(c->db,key) == NULL))
+ if ((flags & OBJ_SET_NX && lookupKeyWrite(c->db,key) != NULL) ||
+ (flags & OBJ_SET_XX && lookupKeyWrite(c->db,key) == NULL))
{
addReply(c, abort_reply ? abort_reply : shared.nullbulk);
return;
@@ -97,7 +97,7 @@ void setCommand(client *c) {
int j;
robj *expire = NULL;
int unit = UNIT_SECONDS;
- int flags = REDIS_SET_NO_FLAGS;
+ int flags = OBJ_SET_NO_FLAGS;
for (j = 3; j < c->argc; j++) {
char *a = c->argv[j]->ptr;
@@ -105,27 +105,27 @@ void setCommand(client *c) {
if ((a[0] == 'n' || a[0] == 'N') &&
(a[1] == 'x' || a[1] == 'X') && a[2] == '\0' &&
- !(flags & REDIS_SET_XX))
+ !(flags & OBJ_SET_XX))
{
- flags |= REDIS_SET_NX;
+ flags |= OBJ_SET_NX;
} else if ((a[0] == 'x' || a[0] == 'X') &&
(a[1] == 'x' || a[1] == 'X') && a[2] == '\0' &&
- !(flags & REDIS_SET_NX))
+ !(flags & OBJ_SET_NX))
{
- flags |= REDIS_SET_XX;
+ flags |= OBJ_SET_XX;
} else if ((a[0] == 'e' || a[0] == 'E') &&
(a[1] == 'x' || a[1] == 'X') && a[2] == '\0' &&
- !(flags & REDIS_SET_PX) && next)
+ !(flags & OBJ_SET_PX) && next)
{
- flags |= REDIS_SET_EX;
+ flags |= OBJ_SET_EX;
unit = UNIT_SECONDS;
expire = next;
j++;
} else if ((a[0] == 'p' || a[0] == 'P') &&
(a[1] == 'x' || a[1] == 'X') && a[2] == '\0' &&
- !(flags & REDIS_SET_EX) && next)
+ !(flags & OBJ_SET_EX) && next)
{
- flags |= REDIS_SET_PX;
+ flags |= OBJ_SET_PX;
unit = UNIT_MILLISECONDS;
expire = next;
j++;
@@ -141,17 +141,17 @@ void setCommand(client *c) {
void setnxCommand(client *c) {
c->argv[2] = tryObjectEncoding(c->argv[2]);
- setGenericCommand(c,REDIS_SET_NX,c->argv[1],c->argv[2],NULL,0,shared.cone,shared.czero);
+ setGenericCommand(c,OBJ_SET_NX,c->argv[1],c->argv[2],NULL,0,shared.cone,shared.czero);
}
void setexCommand(client *c) {
c->argv[3] = tryObjectEncoding(c->argv[3]);
- setGenericCommand(c,REDIS_SET_NO_FLAGS,c->argv[1],c->argv[3],c->argv[2],UNIT_SECONDS,NULL,NULL);
+ setGenericCommand(c,OBJ_SET_NO_FLAGS,c->argv[1],c->argv[3],c->argv[2],UNIT_SECONDS,NULL,NULL);
}
void psetexCommand(client *c) {
c->argv[3] = tryObjectEncoding(c->argv[3]);
- setGenericCommand(c,REDIS_SET_NO_FLAGS,c->argv[1],c->argv[3],c->argv[2],UNIT_MILLISECONDS,NULL,NULL);
+ setGenericCommand(c,OBJ_SET_NO_FLAGS,c->argv[1],c->argv[3],c->argv[2],UNIT_MILLISECONDS,NULL,NULL);
}
int getGenericCommand(client *c) {
@@ -160,7 +160,7 @@ int getGenericCommand(client *c) {
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL)
return REDIS_OK;
- if (o->type != REDIS_STRING) {
+ if (o->type != OBJ_STRING) {
addReply(c,shared.wrongtypeerr);
return REDIS_ERR;
} else {
@@ -206,13 +206,13 @@ void setrangeCommand(client *c) {
if (checkStringLength(c,offset+sdslen(value)) != REDIS_OK)
return;
- o = createObject(REDIS_STRING,sdsnewlen(NULL, offset+sdslen(value)));
+ o = createObject(OBJ_STRING,sdsnewlen(NULL, offset+sdslen(value)));
dbAdd(c->db,c->argv[1],o);
} else {
size_t olen;
/* Key exists, check type */
- if (checkType(c,o,REDIS_STRING))
+ if (checkType(c,o,OBJ_STRING))
return;
/* Return existing string length when setting nothing */
@@ -252,9 +252,9 @@ void getrangeCommand(client *c) {
if (getLongLongFromObjectOrReply(c,c->argv[3],&end,NULL) != REDIS_OK)
return;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptybulk)) == NULL ||
- checkType(c,o,REDIS_STRING)) return;
+ checkType(c,o,OBJ_STRING)) return;
- if (o->encoding == REDIS_ENCODING_INT) {
+ if (o->encoding == OBJ_ENCODING_INT) {
str = llbuf;
strlen = ll2string(llbuf,sizeof(llbuf),(long)o->ptr);
} else {
@@ -287,7 +287,7 @@ void mgetCommand(client *c) {
if (o == NULL) {
addReply(c,shared.nullbulk);
} else {
- if (o->type != REDIS_STRING) {
+ if (o->type != OBJ_STRING) {
addReply(c,shared.nullbulk);
} else {
addReplyBulk(c,o);
@@ -339,7 +339,7 @@ void incrDecrCommand(client *c, long long incr) {
robj *o, *new;
o = lookupKeyWrite(c->db,c->argv[1]);
- if (o != NULL && checkType(c,o,REDIS_STRING)) return;
+ if (o != NULL && checkType(c,o,OBJ_STRING)) return;
if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return;
oldvalue = value;
@@ -350,7 +350,7 @@ void incrDecrCommand(client *c, long long incr) {
}
value += incr;
- if (o && o->refcount == 1 && o->encoding == REDIS_ENCODING_INT &&
+ if (o && o->refcount == 1 && o->encoding == OBJ_ENCODING_INT &&
(value < 0 || value >= REDIS_SHARED_INTEGERS) &&
value >= LONG_MIN && value <= LONG_MAX)
{
@@ -399,7 +399,7 @@ void incrbyfloatCommand(client *c) {
robj *o, *new, *aux;
o = lookupKeyWrite(c->db,c->argv[1]);
- if (o != NULL && checkType(c,o,REDIS_STRING)) return;
+ if (o != NULL && checkType(c,o,OBJ_STRING)) return;
if (getLongDoubleFromObjectOrReply(c,o,&value,NULL) != REDIS_OK ||
getLongDoubleFromObjectOrReply(c,c->argv[2],&incr,NULL) != REDIS_OK)
return;
@@ -441,7 +441,7 @@ void appendCommand(client *c) {
totlen = stringObjectLen(c->argv[2]);
} else {
/* Key exists, check type */
- if (checkType(c,o,REDIS_STRING))
+ if (checkType(c,o,OBJ_STRING))
return;
/* "append" is an argument, so always an sds */
@@ -464,6 +464,6 @@ void appendCommand(client *c) {
void strlenCommand(client *c) {
robj *o;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
- checkType(c,o,REDIS_STRING)) return;
+ checkType(c,o,OBJ_STRING)) return;
addReplyLongLong(c,stringObjectLen(o));
}
diff --git a/src/t_zset.c b/src/t_zset.c
index 790073e26..9bad44264 100644
--- a/src/t_zset.c
+++ b/src/t_zset.c
@@ -435,7 +435,7 @@ static int zslParseRange(robj *min, robj *max, zrangespec *spec) {
* by the "(" character, it's considered "open". For instance
* ZRANGEBYSCORE zset (1.5 (2.5 will match min < x < max
* ZRANGEBYSCORE zset 1.5 2.5 will instead match min <= x <= max */
- if (min->encoding == REDIS_ENCODING_INT) {
+ if (min->encoding == OBJ_ENCODING_INT) {
spec->min = (long)min->ptr;
} else {
if (((char*)min->ptr)[0] == '(') {
@@ -447,7 +447,7 @@ static int zslParseRange(robj *min, robj *max, zrangespec *spec) {
if (eptr[0] != '\0' || isnan(spec->min)) return REDIS_ERR;
}
}
- if (max->encoding == REDIS_ENCODING_INT) {
+ if (max->encoding == OBJ_ENCODING_INT) {
spec->max = (long)max->ptr;
} else {
if (((char*)max->ptr)[0] == '(') {
@@ -515,8 +515,8 @@ int zslParseLexRangeItem(robj *item, robj **dest, int *ex) {
static int zslParseLexRange(robj *min, robj *max, zlexrangespec *spec) {
/* The range can't be valid if objects are integer encoded.
* Every item must start with ( or [. */
- if (min->encoding == REDIS_ENCODING_INT ||
- max->encoding == REDIS_ENCODING_INT) return REDIS_ERR;
+ if (min->encoding == OBJ_ENCODING_INT ||
+ max->encoding == OBJ_ENCODING_INT) return REDIS_ERR;
spec->min = spec->max = NULL;
if (zslParseLexRangeItem(min, &spec->min, &spec->minex) == REDIS_ERR ||
@@ -1080,9 +1080,9 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
unsigned int zsetLength(robj *zobj) {
int length = -1;
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
length = zzlLength(zobj->ptr);
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
length = ((zset*)zobj->ptr)->zsl->length;
} else {
redisPanic("Unknown sorted set encoding");
@@ -1097,14 +1097,14 @@ void zsetConvert(robj *zobj, int encoding) {
double score;
if (zobj->encoding == encoding) return;
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
unsigned char *vstr;
unsigned int vlen;
long long vlong;
- if (encoding != REDIS_ENCODING_SKIPLIST)
+ if (encoding != OBJ_ENCODING_SKIPLIST)
redisPanic("Unknown target encoding");
zs = zmalloc(sizeof(*zs));
@@ -1133,11 +1133,11 @@ void zsetConvert(robj *zobj, int encoding) {
zfree(zobj->ptr);
zobj->ptr = zs;
- zobj->encoding = REDIS_ENCODING_SKIPLIST;
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ zobj->encoding = OBJ_ENCODING_SKIPLIST;
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
unsigned char *zl = ziplistNew();
- if (encoding != REDIS_ENCODING_ZIPLIST)
+ if (encoding != OBJ_ENCODING_ZIPLIST)
redisPanic("Unknown target encoding");
/* Approach similar to zslFree(), since we want to free the skiplist at
@@ -1160,7 +1160,7 @@ void zsetConvert(robj *zobj, int encoding) {
zfree(zs);
zobj->ptr = zl;
- zobj->encoding = REDIS_ENCODING_ZIPLIST;
+ zobj->encoding = OBJ_ENCODING_ZIPLIST;
} else {
redisPanic("Unknown sorted set encoding");
}
@@ -1173,9 +1173,9 @@ void zsetConvert(robj *zobj, int encoding) {
int zsetScore(robj *zobj, robj *member, double *score) {
if (!zobj || !member) return REDIS_ERR;
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
if (zzlFind(zobj->ptr, member, score) == NULL) return REDIS_ERR;
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
dictEntry *de = dictFind(zs->dict, member);
if (de == NULL) return REDIS_ERR;
@@ -1276,7 +1276,7 @@ void zaddGenericCommand(client *c, int flags) {
}
dbAdd(c->db,key,zobj);
} else {
- if (zobj->type != REDIS_ZSET) {
+ if (zobj->type != OBJ_ZSET) {
addReply(c,shared.wrongtypeerr);
goto cleanup;
}
@@ -1285,7 +1285,7 @@ void zaddGenericCommand(client *c, int flags) {
for (j = 0; j < elements; j++) {
score = scores[j];
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *eptr;
/* Prefer non-encoded element when dealing with ziplists. */
@@ -1313,14 +1313,14 @@ void zaddGenericCommand(client *c, int flags) {
* becomes too long *before* executing zzlInsert. */
zobj->ptr = zzlInsert(zobj->ptr,ele,score);
if (zzlLength(zobj->ptr) > server.zset_max_ziplist_entries)
- zsetConvert(zobj,REDIS_ENCODING_SKIPLIST);
+ zsetConvert(zobj,OBJ_ENCODING_SKIPLIST);
if (sdslen(ele->ptr) > server.zset_max_ziplist_value)
- zsetConvert(zobj,REDIS_ENCODING_SKIPLIST);
+ zsetConvert(zobj,OBJ_ENCODING_SKIPLIST);
server.dirty++;
added++;
processed++;
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplistNode *znode;
dictEntry *de;
@@ -1402,9 +1402,9 @@ void zremCommand(client *c) {
int deleted = 0, keyremoved = 0, j;
if ((zobj = lookupKeyWriteOrReply(c,key,shared.czero)) == NULL ||
- checkType(c,zobj,REDIS_ZSET)) return;
+ checkType(c,zobj,OBJ_ZSET)) return;
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *eptr;
for (j = 2; j < c->argc; j++) {
@@ -1418,7 +1418,7 @@ void zremCommand(client *c) {
}
}
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
dictEntry *de;
double score;
@@ -1488,7 +1488,7 @@ void zremrangeGenericCommand(client *c, int rangetype) {
/* Step 2: Lookup & range sanity checks if needed. */
if ((zobj = lookupKeyWriteOrReply(c,key,shared.czero)) == NULL ||
- checkType(c,zobj,REDIS_ZSET)) goto cleanup;
+ checkType(c,zobj,OBJ_ZSET)) goto cleanup;
if (rangetype == ZRANGE_RANK) {
/* Sanitize indexes. */
@@ -1507,7 +1507,7 @@ void zremrangeGenericCommand(client *c, int rangetype) {
}
/* Step 3: Perform the range deletion operation. */
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
switch(rangetype) {
case ZRANGE_RANK:
zobj->ptr = zzlDeleteRangeByRank(zobj->ptr,start+1,end+1,&deleted);
@@ -1523,7 +1523,7 @@ void zremrangeGenericCommand(client *c, int rangetype) {
dbDelete(c->db,key);
keyremoved = 1;
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
switch(rangetype) {
case ZRANGE_RANK:
@@ -1635,28 +1635,28 @@ void zuiInitIterator(zsetopsrc *op) {
if (op->subject == NULL)
return;
- if (op->type == REDIS_SET) {
+ if (op->type == OBJ_SET) {
iterset *it = &op->iter.set;
- if (op->encoding == REDIS_ENCODING_INTSET) {
+ if (op->encoding == OBJ_ENCODING_INTSET) {
it->is.is = op->subject->ptr;
it->is.ii = 0;
- } else if (op->encoding == REDIS_ENCODING_HT) {
+ } else if (op->encoding == OBJ_ENCODING_HT) {
it->ht.dict = op->subject->ptr;
it->ht.di = dictGetIterator(op->subject->ptr);
it->ht.de = dictNext(it->ht.di);
} else {
redisPanic("Unknown set encoding");
}
- } else if (op->type == REDIS_ZSET) {
+ } else if (op->type == OBJ_ZSET) {
iterzset *it = &op->iter.zset;
- if (op->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (op->encoding == OBJ_ENCODING_ZIPLIST) {
it->zl.zl = op->subject->ptr;
it->zl.eptr = ziplistIndex(it->zl.zl,0);
if (it->zl.eptr != NULL) {
it->zl.sptr = ziplistNext(it->zl.zl,it->zl.eptr);
redisAssert(it->zl.sptr != NULL);
}
- } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (op->encoding == OBJ_ENCODING_SKIPLIST) {
it->sl.zs = op->subject->ptr;
it->sl.node = it->sl.zs->zsl->header->level[0].forward;
} else {
@@ -1671,20 +1671,20 @@ void zuiClearIterator(zsetopsrc *op) {
if (op->subject == NULL)
return;
- if (op->type == REDIS_SET) {
+ if (op->type == OBJ_SET) {
iterset *it = &op->iter.set;
- if (op->encoding == REDIS_ENCODING_INTSET) {
+ if (op->encoding == OBJ_ENCODING_INTSET) {
REDIS_NOTUSED(it); /* skip */
- } else if (op->encoding == REDIS_ENCODING_HT) {
+ } else if (op->encoding == OBJ_ENCODING_HT) {
dictReleaseIterator(it->ht.di);
} else {
redisPanic("Unknown set encoding");
}
- } else if (op->type == REDIS_ZSET) {
+ } else if (op->type == OBJ_ZSET) {
iterzset *it = &op->iter.zset;
- if (op->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (op->encoding == OBJ_ENCODING_ZIPLIST) {
REDIS_NOTUSED(it); /* skip */
- } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (op->encoding == OBJ_ENCODING_SKIPLIST) {
REDIS_NOTUSED(it); /* skip */
} else {
redisPanic("Unknown sorted set encoding");
@@ -1698,19 +1698,19 @@ int zuiLength(zsetopsrc *op) {
if (op->subject == NULL)
return 0;
- if (op->type == REDIS_SET) {
- if (op->encoding == REDIS_ENCODING_INTSET) {
+ if (op->type == OBJ_SET) {
+ if (op->encoding == OBJ_ENCODING_INTSET) {
return intsetLen(op->subject->ptr);
- } else if (op->encoding == REDIS_ENCODING_HT) {
+ } else if (op->encoding == OBJ_ENCODING_HT) {
dict *ht = op->subject->ptr;
return dictSize(ht);
} else {
redisPanic("Unknown set encoding");
}
- } else if (op->type == REDIS_ZSET) {
- if (op->encoding == REDIS_ENCODING_ZIPLIST) {
+ } else if (op->type == OBJ_ZSET) {
+ if (op->encoding == OBJ_ENCODING_ZIPLIST) {
return zzlLength(op->subject->ptr);
- } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (op->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = op->subject->ptr;
return zs->zsl->length;
} else {
@@ -1733,9 +1733,9 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
memset(val,0,sizeof(zsetopval));
- if (op->type == REDIS_SET) {
+ if (op->type == OBJ_SET) {
iterset *it = &op->iter.set;
- if (op->encoding == REDIS_ENCODING_INTSET) {
+ if (op->encoding == OBJ_ENCODING_INTSET) {
int64_t ell;
if (!intsetGet(it->is.is,it->is.ii,&ell))
@@ -1745,7 +1745,7 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
/* Move to next element. */
it->is.ii++;
- } else if (op->encoding == REDIS_ENCODING_HT) {
+ } else if (op->encoding == OBJ_ENCODING_HT) {
if (it->ht.de == NULL)
return 0;
val->ele = dictGetKey(it->ht.de);
@@ -1756,9 +1756,9 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
} else {
redisPanic("Unknown set encoding");
}
- } else if (op->type == REDIS_ZSET) {
+ } else if (op->type == OBJ_ZSET) {
iterzset *it = &op->iter.zset;
- if (op->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (op->encoding == OBJ_ENCODING_ZIPLIST) {
/* No need to check both, but better be explicit. */
if (it->zl.eptr == NULL || it->zl.sptr == NULL)
return 0;
@@ -1767,7 +1767,7 @@ int zuiNext(zsetopsrc *op, zsetopval *val) {
/* Move to next element. */
zzlNext(it->zl.zl,&it->zl.eptr,&it->zl.sptr);
- } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (op->encoding == OBJ_ENCODING_SKIPLIST) {
if (it->sl.node == NULL)
return 0;
val->ele = it->sl.node->obj;
@@ -1789,7 +1789,7 @@ int zuiLongLongFromValue(zsetopval *val) {
val->flags |= OPVAL_DIRTY_LL;
if (val->ele != NULL) {
- if (val->ele->encoding == REDIS_ENCODING_INT) {
+ if (val->ele->encoding == OBJ_ENCODING_INT) {
val->ell = (long)val->ele->ptr;
val->flags |= OPVAL_VALID_LL;
} else if (sdsEncodedObject(val->ele)) {
@@ -1824,7 +1824,7 @@ robj *zuiObjectFromValue(zsetopval *val) {
int zuiBufferFromValue(zsetopval *val) {
if (val->estr == NULL) {
if (val->ele != NULL) {
- if (val->ele->encoding == REDIS_ENCODING_INT) {
+ if (val->ele->encoding == OBJ_ENCODING_INT) {
val->elen = ll2string((char*)val->_buf,sizeof(val->_buf),(long)val->ele->ptr);
val->estr = val->_buf;
} else if (sdsEncodedObject(val->ele)) {
@@ -1847,8 +1847,8 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
if (op->subject == NULL)
return 0;
- if (op->type == REDIS_SET) {
- if (op->encoding == REDIS_ENCODING_INTSET) {
+ if (op->type == OBJ_SET) {
+ if (op->encoding == OBJ_ENCODING_INTSET) {
if (zuiLongLongFromValue(val) &&
intsetFind(op->subject->ptr,val->ell))
{
@@ -1857,7 +1857,7 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
} else {
return 0;
}
- } else if (op->encoding == REDIS_ENCODING_HT) {
+ } else if (op->encoding == OBJ_ENCODING_HT) {
dict *ht = op->subject->ptr;
zuiObjectFromValue(val);
if (dictFind(ht,val->ele) != NULL) {
@@ -1869,17 +1869,17 @@ int zuiFind(zsetopsrc *op, zsetopval *val, double *score) {
} else {
redisPanic("Unknown set encoding");
}
- } else if (op->type == REDIS_ZSET) {
+ } else if (op->type == OBJ_ZSET) {
zuiObjectFromValue(val);
- if (op->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (op->encoding == OBJ_ENCODING_ZIPLIST) {
if (zzlFind(op->subject->ptr,val->ele,score) != NULL) {
/* Score is already set by zzlFind. */
return 1;
} else {
return 0;
}
- } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (op->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = op->subject->ptr;
dictEntry *de;
if ((de = dictFind(zs->dict,val->ele)) != NULL) {
@@ -1956,7 +1956,7 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
for (i = 0, j = 3; i < setnum; i++, j++) {
robj *obj = lookupKeyWrite(c->db,c->argv[j]);
if (obj != NULL) {
- if (obj->type != REDIS_ZSET && obj->type != REDIS_SET) {
+ if (obj->type != OBJ_ZSET && obj->type != OBJ_SET) {
zfree(src);
addReply(c,shared.wrongtypeerr);
return;
@@ -2145,7 +2145,7 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
/* Convert to ziplist when in limits. */
if (dstzset->zsl->length <= server.zset_max_ziplist_entries &&
maxelelen <= server.zset_max_ziplist_value)
- zsetConvert(dstobj,REDIS_ENCODING_ZIPLIST);
+ zsetConvert(dstobj,OBJ_ENCODING_ZIPLIST);
dbAdd(c->db,dstkey,dstobj);
addReplyLongLong(c,zsetLength(dstobj));
@@ -2191,7 +2191,7 @@ void zrangeGenericCommand(client *c, int reverse) {
}
if ((zobj = lookupKeyReadOrReply(c,key,shared.emptymultibulk)) == NULL
- || checkType(c,zobj,REDIS_ZSET)) return;
+ || checkType(c,zobj,OBJ_ZSET)) return;
/* Sanitize indexes. */
llen = zsetLength(zobj);
@@ -2211,7 +2211,7 @@ void zrangeGenericCommand(client *c, int reverse) {
/* Return the result in form of a multi-bulk reply */
addReplyMultiBulkLen(c, withscores ? (rangelen*2) : rangelen);
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
unsigned char *vstr;
@@ -2243,7 +2243,7 @@ void zrangeGenericCommand(client *c, int reverse) {
zzlNext(zl,&eptr,&sptr);
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *ln;
@@ -2329,9 +2329,9 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
/* Ok, lookup the key and get the range */
if ((zobj = lookupKeyReadOrReply(c,key,shared.emptymultibulk)) == NULL ||
- checkType(c,zobj,REDIS_ZSET)) return;
+ checkType(c,zobj,OBJ_ZSET)) return;
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
unsigned char *vstr;
@@ -2402,7 +2402,7 @@ void genericZrangebyscoreCommand(client *c, int reverse) {
zzlNext(zl,&eptr,&sptr);
}
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *ln;
@@ -2490,9 +2490,9 @@ void zcountCommand(client *c) {
/* Lookup the sorted set */
if ((zobj = lookupKeyReadOrReply(c, key, shared.czero)) == NULL ||
- checkType(c, zobj, REDIS_ZSET)) return;
+ checkType(c, zobj, OBJ_ZSET)) return;
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
double score;
@@ -2523,7 +2523,7 @@ void zcountCommand(client *c) {
zzlNext(zl,&eptr,&sptr);
}
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *zn;
@@ -2567,13 +2567,13 @@ void zlexcountCommand(client *c) {
/* Lookup the sorted set */
if ((zobj = lookupKeyReadOrReply(c, key, shared.czero)) == NULL ||
- checkType(c, zobj, REDIS_ZSET))
+ checkType(c, zobj, OBJ_ZSET))
{
zslFreeLexRange(&range);
return;
}
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
@@ -2601,7 +2601,7 @@ void zlexcountCommand(client *c) {
zzlNext(zl,&eptr,&sptr);
}
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *zn;
@@ -2677,13 +2677,13 @@ void genericZrangebylexCommand(client *c, int reverse) {
/* Ok, lookup the key and get the range */
if ((zobj = lookupKeyReadOrReply(c,key,shared.emptymultibulk)) == NULL ||
- checkType(c,zobj,REDIS_ZSET))
+ checkType(c,zobj,OBJ_ZSET))
{
zslFreeLexRange(&range);
return;
}
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
unsigned char *vstr;
@@ -2749,7 +2749,7 @@ void genericZrangebylexCommand(client *c, int reverse) {
zzlNext(zl,&eptr,&sptr);
}
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
zskiplistNode *ln;
@@ -2822,7 +2822,7 @@ void zcardCommand(client *c) {
robj *zobj;
if ((zobj = lookupKeyReadOrReply(c,key,shared.czero)) == NULL ||
- checkType(c,zobj,REDIS_ZSET)) return;
+ checkType(c,zobj,OBJ_ZSET)) return;
addReplyLongLong(c,zsetLength(zobj));
}
@@ -2833,7 +2833,7 @@ void zscoreCommand(client *c) {
double score;
if ((zobj = lookupKeyReadOrReply(c,key,shared.nullbulk)) == NULL ||
- checkType(c,zobj,REDIS_ZSET)) return;
+ checkType(c,zobj,OBJ_ZSET)) return;
if (zsetScore(zobj,c->argv[2],&score) == REDIS_ERR) {
addReply(c,shared.nullbulk);
@@ -2850,12 +2850,12 @@ void zrankGenericCommand(client *c, int reverse) {
unsigned long rank;
if ((zobj = lookupKeyReadOrReply(c,key,shared.nullbulk)) == NULL ||
- checkType(c,zobj,REDIS_ZSET)) return;
+ checkType(c,zobj,OBJ_ZSET)) return;
llen = zsetLength(zobj);
redisAssertWithInfo(c,ele,sdsEncodedObject(ele));
- if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+ if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
unsigned char *zl = zobj->ptr;
unsigned char *eptr, *sptr;
@@ -2880,7 +2880,7 @@ void zrankGenericCommand(client *c, int reverse) {
} else {
addReply(c,shared.nullbulk);
}
- } else if (zobj->encoding == REDIS_ENCODING_SKIPLIST) {
+ } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
zset *zs = zobj->ptr;
zskiplist *zsl = zs->zsl;
dictEntry *de;
@@ -2918,6 +2918,6 @@ void zscanCommand(client *c) {
if (parseScanCursorOrReply(c,c->argv[2],&cursor) == REDIS_ERR) return;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL ||
- checkType(c,o,REDIS_ZSET)) return;
+ checkType(c,o,OBJ_ZSET)) return;
scanGenericCommand(c,o,cursor);
}