Skip to content

Commit

Permalink
[pgmoneta#359] Remove obsolete/unused APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jubilee101 committed Aug 20, 2024
1 parent 76fe122 commit 7342509
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 300 deletions.
21 changes: 0 additions & 21 deletions src/include/art.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,6 @@ pgmoneta_art_search(struct art* t, unsigned char* key, uint32_t key_len);
bool
pgmoneta_art_contains_key(struct art* t, unsigned char* key, uint32_t key_len);

/**
* Iterates through the entries pairs in the map,
* invoking a callback for each. The call back gets a
* key, value for each and returns an integer stop value
* If the callback returns non-zero, then the iteration stops
* @param t The tree to iterate over
* @param cb The callback function to invoke
* @param data Opaque handle passed to the callback
* @return 0 on success, or the return of the callback
*/
int
pgmoneta_art_iterate(struct art* t, art_callback cb, void* data);

/**
* Create an art iterator
* @param t The tree
Expand All @@ -159,14 +146,6 @@ pgmoneta_art_iterator_destroy(struct art_iterator* iter);
bool
pgmoneta_art_iterator_next(struct art_iterator* iter);

/**
* Check if iterator has next
* @param iter The iterator
* @return true if the iterator has the next leaf, otherwise false
*/
bool
pgmoneta_art_iterator_has_next(struct art_iterator* iter);

/**
* Convert the ART tree to string
* @param t The ART tree
Expand Down
85 changes: 7 additions & 78 deletions src/include/deque.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,76 +129,6 @@ pgmoneta_deque_peek(struct deque* deque, char** tag);
uintptr_t
pgmoneta_deque_get(struct deque* deque, char* tag);

/**
* Check if deque contains certain tag
* @param deque The deque
* @param tag The tag
* @return true if the tag exists, false if otherwise
*/
bool
pgmoneta_deque_contains_tag(struct deque* deque, char* tag);

/**
* Set the value of a tag if it exists
* @param deque The deque
* @param tag The tag
* @param val The value data
* @param type The value type
* @return 0 if success, 1 if otherwise
*/
int
pgmoneta_deque_set(struct deque* deque, char* tag, uintptr_t val, enum value_type type);

/**
* Get the next deque node
* The function is thread safe for put/add but not for polling,
* meaning that the returned node could get destroyed by other thread
* @param deque The deque
* @param node The current node
* @return The next node if there is a next node, NULL if otherwise
*/
struct deque_node*
pgmoneta_deque_next(struct deque* deque, struct deque_node* node);

/**
* Get the previous deque node
* The function is thread safe for put/add but not for polling,
* meaning that the returned node could get destroyed by other thread
* @param deque The deque
* @param node The current node
* @return The next node if there is a previous node, NULL if otherwise
*/
struct deque_node*
pgmoneta_deque_prev(struct deque* deque, struct deque_node* node);

/**
* Get the head of the deque.
* The function is thread safe, but it doesn't protect the head from being removed
* @param deque The deque
* @return The head, or NULL if deque is empty
*/
struct deque_node*
pgmoneta_deque_head(struct deque* deque);

/**
* Get the tail of the deque.
* The function is thread safe, but it doesn't protect the head from being removed
* @param deque The deque
* @return The tail, or NULL if deque is empty
*/
struct deque_node*
pgmoneta_deque_tail(struct deque* deque);

/**
* Remove a node from the deque.
* The function is thread safe, but it does not protect the returned node from being removed
* @param deque The deque
* @param node The node
* @return Next node of the deleted node, or NULL if there is no next node
*/
struct deque_node*
pgmoneta_deque_remove(struct deque* deque, struct deque_node* node);

/**
* Get the size of the deque
* @param deque The deque
Expand Down Expand Up @@ -250,27 +180,26 @@ int
pgmoneta_deque_iterator_create(struct deque* deque, struct deque_iterator** iter);

/**
* Destroy a deque iterator
* Remove the current node iterator points to and place the iterator to the previous node
* @param iter The iterator
*/
void
pgmoneta_deque_iterator_destroy(struct deque_iterator* iter);
pgmoneta_deque_iterator_remove(struct deque_iterator* iter);

/**
* Get the next deque value
* Destroy a deque iterator
* @param iter The iterator
* @return true if has next, false if otherwise
*/
bool
pgmoneta_deque_iterator_next(struct deque_iterator* iter);
void
pgmoneta_deque_iterator_destroy(struct deque_iterator* iter);

/**
* Check if deque has next value
* Get the next deque value
* @param iter The iterator
* @return true if has next, false if otherwise
*/
bool
pgmoneta_deque_iterator_has_next(struct deque_iterator* iter);
pgmoneta_deque_iterator_next(struct deque_iterator* iter);

#ifdef __cplusplus
}
Expand Down
8 changes: 0 additions & 8 deletions src/include/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,6 @@ pgmoneta_json_iterator_destroy(struct json_iterator* iter);
bool
pgmoneta_json_iterator_next(struct json_iterator* iter);

/**
* Check if the JSON object has next kv pair/entry
* @param iter The iterator
* @return true if has next, false if otherwise
*/
bool
pgmoneta_json_iterator_has_next(struct json_iterator* iter);

/**
* Parse a string into json item
* @param str The string
Expand Down
29 changes: 11 additions & 18 deletions src/libpgmoneta/art.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ create_art_node256(struct art_node256** node);
static void
destroy_art_node(struct art_node* node);

static int
art_iterate(struct art* t, art_callback cb, void* data);

/**
* Get where the keys diverge starting from depth.
* This function only compares within the partial prefix range
Expand Down Expand Up @@ -368,12 +371,6 @@ pgmoneta_art_delete(struct art* t, unsigned char* key, uint32_t key_len)
return 0;
}

int
pgmoneta_art_iterate(struct art* t, art_callback cb, void* data)
{
return art_node_iterate(t->root, cb, data);
}

char*
pgmoneta_art_to_string(struct art* t, int32_t format, char* tag, int indent)
{
Expand Down Expand Up @@ -1407,16 +1404,6 @@ pgmoneta_art_iterator_destroy(struct art_iterator* iter)
free(iter);
}

bool
pgmoneta_art_iterator_has_next(struct art_iterator* iter)
{
if (iter == NULL)
{
return false;
}
return iter->count < iter->tree->size;
}

void
pgmoneta_art_destroy_value_noop(void* val)
{
Expand Down Expand Up @@ -1541,7 +1528,7 @@ to_json_string(struct art* t, char* tag, int indent)
.t = t,
.cnt = 0,
};
pgmoneta_art_iterate(t, art_to_json_string_cb, &param);
art_iterate(t, art_to_json_string_cb, &param);
ret = param.str;
ret = pgmoneta_indent(ret, NULL, indent);
ret = pgmoneta_append(ret, "}");
Expand Down Expand Up @@ -1570,7 +1557,13 @@ to_text_string(struct art* t, char* tag, int indent)
.cnt = 0,
.tag = tag
};
pgmoneta_art_iterate(t, art_to_text_string_cb, &param);
art_iterate(t, art_to_text_string_cb, &param);
ret = param.str;
return ret;
}

static int
art_iterate(struct art* t, art_callback cb, void* data)
{
return art_node_iterate(t->root, cb, data);
}
Loading

0 comments on commit 7342509

Please sign in to comment.