summaryrefslogtreecommitdiff
path: root/src/rax.c
diff options
context:
space:
mode:
authorOran Agra <oran@redislabs.com>2018-06-26 14:14:35 +0300
committerOran Agra <oran@redislabs.com>2018-06-27 15:00:41 +0300
commit5616d4c6036eeea416f38aa2e41a57249e69277f (patch)
treefe9b4126768f6c190f63e457fbfaa9476e7c6e5e /src/rax.c
parente8099cabd19c4e3a46c94c39e69e13191d43f5eb (diff)
downloadredis-5616d4c6036eeea416f38aa2e41a57249e69277f.tar.gz
add active defrag support for streams
Diffstat (limited to 'src/rax.c')
-rw-r--r--src/rax.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rax.c b/src/rax.c
index 8764dd8c9..fff580272 100644
--- a/src/rax.c
+++ b/src/rax.c
@@ -1167,6 +1167,7 @@ void raxStart(raxIterator *it, rax *rt) {
it->key = it->key_static_string;
it->key_max = RAX_ITER_STATIC_LEN;
it->data = NULL;
+ it->node_cb = NULL;
raxStackInit(&it->stack);
}
@@ -1240,6 +1241,8 @@ int raxIteratorNextStep(raxIterator *it, int noup) {
if (!raxIteratorAddChars(it,it->node->data,
it->node->iscompr ? it->node->size : 1)) return 0;
memcpy(&it->node,cp,sizeof(it->node));
+ if (it->node_cb && it->node_cb(&it->node))
+ memcpy(cp,&it->node,sizeof(it->node));
/* For "next" step, stop every time we find a key along the
* way, since the key is lexicograhically smaller compared to
* what follows in the sub-children. */
@@ -1292,6 +1295,8 @@ int raxIteratorNextStep(raxIterator *it, int noup) {
raxIteratorAddChars(it,it->node->data+i,1);
if (!raxStackPush(&it->stack,it->node)) return 0;
memcpy(&it->node,cp,sizeof(it->node));
+ if (it->node_cb && it->node_cb(&it->node))
+ memcpy(cp,&it->node,sizeof(it->node));
if (it->node->iskey) {
it->data = raxGetData(it->node);
return 1;
@@ -1325,7 +1330,7 @@ int raxSeekGreatest(raxIterator *it) {
/* Like raxIteratorNextStep() but implements an iteration step moving
* to the lexicographically previous element. The 'noup' option has a similar
- * effect to the one of raxIteratorPrevSte(). */
+ * effect to the one of raxIteratorNextStep(). */
int raxIteratorPrevStep(raxIterator *it, int noup) {
if (it->flags & RAX_ITER_EOF) {
return 1;