Commit 3f9e2322 authored by antirez's avatar antirez
Browse files

Rax library updated.

parent 1409c545
...@@ -1315,9 +1315,9 @@ void slotToKeyUpdateKey(robj *key, int add) { ...@@ -1315,9 +1315,9 @@ void slotToKeyUpdateKey(robj *key, int add) {
indexed[1] = hashslot & 0xff; indexed[1] = hashslot & 0xff;
memcpy(indexed+2,key->ptr,keylen); memcpy(indexed+2,key->ptr,keylen);
if (add) { if (add) {
raxInsert(server.cluster->slots_to_keys,indexed,keylen+2,NULL); raxInsert(server.cluster->slots_to_keys,indexed,keylen+2,NULL,NULL);
} else { } else {
raxRemove(server.cluster->slots_to_keys,indexed,keylen+2); raxRemove(server.cluster->slots_to_keys,indexed,keylen+2,NULL);
} }
if (indexed != buf) zfree(indexed); if (indexed != buf) zfree(indexed);
} }
...@@ -1348,8 +1348,8 @@ unsigned int getKeysInSlot(unsigned int hashslot, robj **keys, unsigned int coun ...@@ -1348,8 +1348,8 @@ unsigned int getKeysInSlot(unsigned int hashslot, robj **keys, unsigned int coun
indexed[0] = (hashslot >> 8) & 0xff; indexed[0] = (hashslot >> 8) & 0xff;
indexed[1] = hashslot & 0xff; indexed[1] = hashslot & 0xff;
raxStart(&iter,server.cluster->slots_to_keys); raxStart(&iter,server.cluster->slots_to_keys);
raxSeek(&iter,indexed,2,">="); raxSeek(&iter,">=",indexed,2);
while(count-- && raxNext(&iter,NULL,0,NULL)) { while(count-- && raxNext(&iter)) {
if (iter.key[0] != indexed[0] || iter.key[1] != indexed[1]) break; if (iter.key[0] != indexed[0] || iter.key[1] != indexed[1]) break;
keys[j++] = createStringObject((char*)iter.key+2,iter.key_len-2); keys[j++] = createStringObject((char*)iter.key+2,iter.key_len-2);
} }
...@@ -1368,8 +1368,8 @@ unsigned int delKeysInSlot(unsigned int hashslot) { ...@@ -1368,8 +1368,8 @@ unsigned int delKeysInSlot(unsigned int hashslot) {
indexed[1] = hashslot & 0xff; indexed[1] = hashslot & 0xff;
raxStart(&iter,server.cluster->slots_to_keys); raxStart(&iter,server.cluster->slots_to_keys);
while(server.cluster->slots_keys_count[hashslot]) { while(server.cluster->slots_keys_count[hashslot]) {
raxSeek(&iter,indexed,2,">="); raxSeek(&iter,">=",indexed,2);
raxNext(&iter,NULL,0,NULL); raxNext(&iter);
robj *key = createStringObject((char*)iter.key+2,iter.key_len-2); robj *key = createStringObject((char*)iter.key+2,iter.key_len-2);
dbDelete(&server.db[0],key); dbDelete(&server.db[0],key);
......
This diff is collapsed.
...@@ -144,14 +144,16 @@ extern void *raxNotFound; ...@@ -144,14 +144,16 @@ extern void *raxNotFound;
/* Exported API. */ /* Exported API. */
rax *raxNew(void); rax *raxNew(void);
int raxInsert(rax *rax, unsigned char *s, size_t len, void *data); int raxInsert(rax *rax, unsigned char *s, size_t len, void *data, void **old);
int raxRemove(rax *rax, unsigned char *s, size_t len); int raxRemove(rax *rax, unsigned char *s, size_t len, void **old);
void *raxFind(rax *rax, unsigned char *s, size_t len); void *raxFind(rax *rax, unsigned char *s, size_t len);
void raxFree(rax *rax); void raxFree(rax *rax);
void raxStart(raxIterator *it, rax *rt); void raxStart(raxIterator *it, rax *rt);
int raxSeek(raxIterator *it, unsigned char *ele, size_t len, const char *op); int raxSeek(raxIterator *it, const char *op, unsigned char *ele, size_t len);
int raxNext(raxIterator *it, unsigned char *stop, size_t stoplen, char *op); int raxNext(raxIterator *it);
int raxPrev(raxIterator *it, unsigned char *stop, size_t stoplen, char *op); int raxPrev(raxIterator *it);
int raxRandomWalk(raxIterator *it, size_t steps);
int raxCompare(raxIterator *iter, const char *op, unsigned char *key, size_t key_len);
void raxStop(raxIterator *it); void raxStop(raxIterator *it);
void raxShow(rax *rax); void raxShow(rax *rax);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment