Skip to content

Commit

Permalink
internal: bptree: add bptree_reset_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
prajnoha committed Jun 25, 2024
1 parent dfb9515 commit 58167eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/include/internal/bptree.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void *bptree_iter_current(bptree_iter_t *iter, const char **key, size_t
const char *bptree_iter_current_key(bptree_iter_t *iter);
void *bptree_iter_next(bptree_iter_t *iter, const char **key, size_t *data_size, unsigned *data_ref_count);
void bptree_iter_reset(bptree_iter_t *iter, const char *key_start, const char *key_end);
void bptree_iter_reset_prefix(bptree_iter_t *iter, const char *prefix);
void bptree_iter_destroy(bptree_iter_t *iter);

#ifdef __cplusplus
Expand Down
11 changes: 11 additions & 0 deletions src/internal/bptree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,10 +1513,21 @@ void bptree_iter_reset(bptree_iter_t *iter, const char *key_start, const char *k
{
iter->c = NULL;
iter->i = 0;
iter->method = LOOKUP_EXACT;
iter->key_start = key_start;
iter->key_end = key_end;
}

void bptree_iter_reset_prefix(bptree_iter_t *iter, const char *prefix)
{
iter->c = NULL;
iter->i = 0;
iter->method = LOOKUP_PREFIX;
iter->key_start = prefix;
iter->key_end = NULL;
iter->key_start_len = strlen(prefix);
}

void bptree_iter(bptree_t *bptree, const char *key_start, const char *key_end, bptree_iterate_fn_t fn, void *fn_arg)
{
bptree_iter_t iter = {.bptree = bptree, .key_start = key_start, .key_end = key_end, .c = NULL, .i = 0};
Expand Down

0 comments on commit 58167eb

Please sign in to comment.