Go to the source code of this file.
Defines | |
#define | MYFETCH(p, f) ccn_btree_fetchval(&((p)->f[0]), sizeof((p)->f)) |
#define | MYSTORE(p, f, v) ccn_btree_storeval(&((p)->f[0]), sizeof((p)->f), (v)) |
#define | MIN_NODE_BYTES (sizeof(struct ccn_btree_node_header) + sizeof(struct ccn_btree_entry_trailer)) |
Minimum size of a non-empty node. | |
#define | MSG(fmt,...) ((void)0) |
#define | CCN_BTREE_MAGIC 0x53ade78 |
#define | CCN_BTREE_VERSION 1 |
#define | CCN_BTREE_MAX_NODE_BYTES (8U<<20) |
#define | MSG(fmt,...) if (outfp != NULL) fprintf(outfp, fmt "\n", __VA_ARGS__) |
Functions | |
static void | ccn_btree_update_cached_parent (struct ccn_btree *btree, struct ccn_btree_internal_payload *olink, ccn_btnodeid parentid) |
BTree implementation. | |
unsigned | ccn_btree_fetchval (const unsigned char *p, int size) |
void | ccn_btree_storeval (unsigned char *p, int size, unsigned v) |
static struct ccn_btree_entry_trailer * | seek_trailer (struct ccn_btree_node *node, int i) |
Find the entry trailer associated with entry i of the btree node. | |
void * | ccn_btree_node_getentry (size_t payload_bytes, struct ccn_btree_node *node, int i) |
Get the address of the indexed entry within the node. | |
static struct ccn_btree_internal_payload * | ccn_btree_node_internal_entry (struct ccn_btree_node *node, int i) |
Get the address of entry within an internal (non-leaf) node. | |
int | ccn_btree_node_nent (struct ccn_btree_node *node) |
Number of entries within the btree node. | |
int | ccn_btree_node_getentrysize (struct ccn_btree_node *node) |
Size, in bytes, of entries within the node. | |
int | ccn_btree_node_payloadsize (struct ccn_btree_node *node) |
Size, in bytes, of payloads within the node. | |
int | ccn_btree_node_level (struct ccn_btree_node *node) |
Node level (leaves are at level 0). | |
int | ccn_btree_key_fetch (struct ccn_charbuf *dst, struct ccn_btree_node *node, int i) |
Fetch the key within the indexed entry of node. | |
int | ccn_btree_key_append (struct ccn_charbuf *dst, struct ccn_btree_node *node, int i) |
Append the key within the indexed entry of node to dst. | |
int | ccn_btree_compare (const unsigned char *key, size_t size, struct ccn_btree_node *node, int i) |
Compare given key with the key in the indexed entry of the node. | |
int | ccn_btree_searchnode (const unsigned char *key, size_t size, struct ccn_btree_node *node) |
Search the node for the given key. | |
int | ccn_btree_lookup (struct ccn_btree *btree, const unsigned char *key, size_t size, struct ccn_btree_node **leafp) |
Do a btree lookup, starting from the default root. | |
int | ccn_btree_lookup_internal (struct ccn_btree *btree, struct ccn_btree_node *root, int stoplevel, const unsigned char *key, size_t size, struct ccn_btree_node **ansp) |
Do a btree lookup, starting from the provided root and stopping at stoplevel. | |
static int | ccn_btree_smallest_key_under (struct ccn_btree *btree, struct ccn_btree_node *node, struct ccn_charbuf *result) |
Extracts the smallest key under the node. | |
static void | scan_reusable (const unsigned char *key, size_t keysize, struct ccn_btree_node *node, int ndx, unsigned reuse[2]) |
int | ccn_btree_insert_entry (struct ccn_btree_node *node, int i, const unsigned char *key, size_t keysize, void *payload, size_t payload_bytes) |
Insert a new entry into a node. | |
int | ccn_btree_delete_entry (struct ccn_btree_node *node, int i) |
Remove an entry from a btree node. | |
static struct ccn_btree_node * | ccn_btree_grow_a_level (struct ccn_btree *btree, struct ccn_btree_node *node) |
Given an old root, add a level to the tree to prepare for a split. | |
static int | ccn_btree_shrink_a_level (struct ccn_btree *btree) |
If the root is a singleton and not a leaf, remove a level. | |
int | ccn_btree_oversize (struct ccn_btree *btree, struct ccn_btree_node *node) |
Test for an oversize node. | |
int | ccn_btree_unbalance (struct ccn_btree *btree, struct ccn_btree_node *node) |
Test for an unbalanced node. | |
int | ccn_btree_split (struct ccn_btree *btree, struct ccn_btree_node *node) |
Split a btree node. | |
int | ccn_btree_index_in_parent (struct ccn_btree_node *parent, ccn_btnodeid nodeid) |
Search for nodeid in parent. | |
int | ccn_btree_spill (struct ccn_btree *btree, struct ccn_btree_node *node) |
Eliminate a node by combining it with a sibling. | |
int | ccn_btree_next_leaf (struct ccn_btree *btree, struct ccn_btree_node *node, struct ccn_btree_node **ansp) |
Find the leaf that comes after the given node. | |
int | ccn_btree_prev_leaf (struct ccn_btree *btree, struct ccn_btree_node *node, struct ccn_btree_node **ansp) |
Find the leaf that comes before the given node. | |
int | ccn_btree_close_node (struct ccn_btree *btree, struct ccn_btree_node *node) |
Write out any pending changes, mark the node clean, and release node iodata. | |
static void | finalize_node (struct hashtb_enumerator *e) |
void | ccn_btree_note_error (struct ccn_btree *bt, int info) |
Keep count of noticed errors. | |
struct ccn_btree * | ccn_btree_create (void) |
Create a new btree handle, not attached to any external files. | |
int | ccn_btree_destroy (struct ccn_btree **pbt) |
Destroys a btree handle, shutting things down cleanly. | |
int | ccn_btree_init_node (struct ccn_btree_node *node, int level, unsigned char nodetype, unsigned char extsz) |
Initialize the btree node. | |
struct ccn_btree_node * | ccn_btree_getnode (struct ccn_btree *bt, ccn_btnodeid nodeid, ccn_btnodeid parentid) |
Access a btree node, creating or reading it if necessary. | |
struct ccn_btree_node * | ccn_btree_rnode (struct ccn_btree *bt, ccn_btnodeid nodeid) |
Access a btree node that is already resident. | |
int | ccn_btree_chknode (struct ccn_btree_node *node) |
Check a node for internal consistency. | |
int | ccn_btree_prepare_for_update (struct ccn_btree *bt, struct ccn_btree_node *node) |
Get ready to update a btree node. | |
static int | compare_lexical (struct ccn_charbuf *a, struct ccn_charbuf *b) |
static void | ccn_charbuf_append_escaped (struct ccn_charbuf *dst, struct ccn_charbuf *src) |
int | ccn_btree_check (struct ccn_btree *btree, FILE *outfp) |
Check the structure of the btree for consistency. |
#define CCN_BTREE_MAGIC 0x53ade78 |
Definition at line 1210 of file ccn_btree.c.
Referenced by ccn_btree_chknode(), ccn_btree_create(), ccn_btree_destroy(), ccn_btree_getnode(), ccn_btree_init_node(), and finalize_node().
#define CCN_BTREE_MAX_NODE_BYTES (8U<<20) |
Definition at line 1356 of file ccn_btree.c.
Referenced by ccn_btree_getnode().
#define CCN_BTREE_VERSION 1 |
Definition at line 1211 of file ccn_btree.c.
Referenced by ccn_btree_chknode(), and ccn_btree_init_node().
#define MIN_NODE_BYTES (sizeof(struct ccn_btree_node_header) + sizeof(struct ccn_btree_entry_trailer)) |
Minimum size of a non-empty node.
Definition at line 65 of file ccn_btree.c.
Referenced by ccn_btree_node_getentrysize(), ccn_btree_node_nent(), and seek_trailer().
#define MSG | ( | fmt, | |||
... | ) | if (outfp != NULL) fprintf(outfp, fmt "\n", __VA_ARGS__) |
Definition at line 1588 of file ccn_btree.c.
#define MSG | ( | fmt, | |||
... | ) | ((void)0) |
Definition at line 1588 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_grow_a_level(), ccn_btree_spill(), ccn_btree_split(), and ccn_btree_update_cached_parent().
#define MYFETCH | ( | p, | |||
f | ) | ccn_btree_fetchval(&((p)->f[0]), sizeof((p)->f)) |
Definition at line 37 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_chknode(), ccn_btree_compare(), ccn_btree_content_cobsz(), ccn_btree_delete_entry(), ccn_btree_index_in_parent(), ccn_btree_key_append(), ccn_btree_lookup_internal(), ccn_btree_match_interest(), ccn_btree_next_leaf(), ccn_btree_node_getentry(), ccn_btree_node_getentrysize(), ccn_btree_node_internal_entry(), ccn_btree_node_level(), ccn_btree_node_nent(), ccn_btree_prev_leaf(), ccn_btree_shrink_a_level(), ccn_btree_spill(), ccn_btree_split(), ccn_btree_update_cached_parent(), and seek_trailer().
#define MYSTORE | ( | p, | |||
f, | |||||
v | ) | ccn_btree_storeval(&((p)->f[0]), sizeof((p)->f), (v)) |
Definition at line 51 of file ccn_btree.c.
Referenced by ccn_btree_delete_entry(), ccn_btree_grow_a_level(), ccn_btree_init_node(), ccn_btree_insert_content(), ccn_btree_insert_entry(), and ccn_btree_split().
int ccn_btree_check | ( | struct ccn_btree * | btree, | |
FILE * | outfp | |||
) |
Check the structure of the btree for consistency.
If outfp is not NULL, information about structure will be written.
Definition at line 1597 of file ccn_btree.c.
Referenced by r_store_init(), test_btree_inserts_from_stdin(), and test_btree_lookup().
int ccn_btree_chknode | ( | struct ccn_btree_node * | node | ) |
Check a node for internal consistency.
Sets or clears node->corrupt as appropriate. In case of success, sets the correct value for node->freelow
Definition at line 1450 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_getnode(), ccn_btree_insert_entry(), ccn_btree_prepare_for_update(), ccn_btree_split(), example_btree_small(), r_store_index_cleaner(), test_basic_btree_delete_entry(), test_basic_btree_insert_entry(), test_btree_chknode(), test_btree_inserts_from_stdin(), and test_insert_content().
int ccn_btree_close_node | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node | |||
) |
Write out any pending changes, mark the node clean, and release node iodata.
Retains the cached node data in memory.
Definition at line 1221 of file ccn_btree.c.
Referenced by ccn_btree_check(), finalize_node(), and r_store_index_cleaner().
int ccn_btree_compare | ( | const unsigned char * | key, | |
size_t | size, | |||
struct ccn_btree_node * | node, | |||
int | i | |||
) |
Compare given key with the key in the indexed entry of the node.
The comparison is a standard lexicographic one on unsigned bytes; that is, there is no assumption of what the bytes actually encode.
The special return value -9999 indicates the key is a strict prefix. This does not matter to the btree lookup, but is useful for higher levels.
Definition at line 271 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_searchnode(), r_store_lookup_backwards(), test_btree_compare(), and testhelp_count_matches().
struct ccn_btree* ccn_btree_create | ( | void | ) | [read] |
Create a new btree handle, not attached to any external files.
Definition at line 1273 of file ccn_btree.c.
Referenced by example_btree_small(), r_store_init(), test_btree_init(), test_btree_inserts_from_stdin(), and test_insert_content().
int ccn_btree_delete_entry | ( | struct ccn_btree_node * | node, | |
int | i | |||
) |
Remove an entry from a btree node.
The caller is responsible for triggering a merge.
Definition at line 598 of file ccn_btree.c.
Referenced by ccn_btree_spill(), test_basic_btree_delete_entry(), and test_btree_inserts_from_stdin().
int ccn_btree_destroy | ( | struct ccn_btree ** | pbt | ) |
Destroys a btree handle, shutting things down cleanly.
Definition at line 1301 of file ccn_btree.c.
Referenced by r_store_final(), r_store_init(), test_basic_btree_delete_entry(), test_basic_btree_insert_entry(), test_btree_init(), test_btree_inserts_from_stdin(), and test_btree_lookup().
unsigned ccn_btree_fetchval | ( | const unsigned char * | p, | |
int | size | |||
) |
Definition at line 40 of file ccn_btree.c.
struct ccn_btree_node* ccn_btree_getnode | ( | struct ccn_btree * | bt, | |
ccn_btnodeid | nodeid, | |||
ccn_btnodeid | parentid | |||
) | [read] |
Access a btree node, creating or reading it if necessary.
Care should be taken to not store the node handle in data structures, since it will become invalid when the node gets flushed from the resident cache.
Definition at line 1368 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_grow_a_level(), ccn_btree_lookup(), ccn_btree_lookup_internal(), ccn_btree_next_leaf(), ccn_btree_prev_leaf(), ccn_btree_shrink_a_level(), ccn_btree_spill(), ccn_btree_split(), example_btree_small(), r_store_content_btree_insert(), r_store_init(), test_btree_init(), test_btree_inserts_from_stdin(), and test_insert_content().
static struct ccn_btree_node* ccn_btree_grow_a_level | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node | |||
) | [static, read] |
Given an old root, add a level to the tree to prepare for a split.
Definition at line 649 of file ccn_btree.c.
Referenced by ccn_btree_split().
int ccn_btree_index_in_parent | ( | struct ccn_btree_node * | parent, | |
ccn_btnodeid | nodeid | |||
) |
Search for nodeid in parent.
This does not rely on the keys, but just scans the entries.
Definition at line 970 of file ccn_btree.c.
Referenced by ccn_btree_prev_leaf(), and ccn_btree_spill().
int ccn_btree_init_node | ( | struct ccn_btree_node * | node, | |
int | level, | |||
unsigned char | nodetype, | |||
unsigned char | extsz | |||
) |
Initialize the btree node.
It is the caller's responsibility to be sure that the node does not contain any useful information.
Leaves alone nodeid, iodata, and activity fields.
Definition at line 1331 of file ccn_btree.c.
Referenced by ccn_btree_grow_a_level(), ccn_btree_shrink_a_level(), ccn_btree_split(), r_store_init(), test_btree_inserts_from_stdin(), and test_insert_content().
int ccn_btree_insert_entry | ( | struct ccn_btree_node * | node, | |
int | i, | |||
const unsigned char * | key, | |||
size_t | keysize, | |||
void * | payload, | |||
size_t | payload_bytes | |||
) |
Insert a new entry into a node.
The caller is responsible for providing the correct index i, which will become the index of the new entry.
The caller is also responsible for triggering a split.
Definition at line 491 of file ccn_btree.c.
Referenced by ccn_btree_grow_a_level(), ccn_btree_insert_content(), ccn_btree_shrink_a_level(), ccn_btree_spill(), ccn_btree_split(), test_basic_btree_insert_entry(), and test_btree_inserts_from_stdin().
int ccn_btree_key_append | ( | struct ccn_charbuf * | dst, | |
struct ccn_btree_node * | node, | |||
int | i | |||
) |
Append the key within the indexed entry of node to dst.
Definition at line 231 of file ccn_btree.c.
Referenced by ccn_btree_key_fetch(), and test_btree_key_fetch().
int ccn_btree_key_fetch | ( | struct ccn_charbuf * | dst, | |
struct ccn_btree_node * | node, | |||
int | i | |||
) |
Fetch the key within the indexed entry of node.
Definition at line 218 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_match_interest(), ccn_btree_next_leaf(), ccn_btree_shrink_a_level(), ccn_btree_smallest_key_under(), ccn_btree_spill(), ccn_btree_split(), r_store_look(), r_store_lookup_backwards(), and test_btree_key_fetch().
int ccn_btree_lookup | ( | struct ccn_btree * | btree, | |
const unsigned char * | key, | |||
size_t | size, | |||
struct ccn_btree_node ** | leafp | |||
) |
Do a btree lookup, starting from the default root.
In the absence of errors, if *leafp is not NULL the handle for the appropriate leaf node will be stored. See ccn_btree_getnode() for warning about lifetime of the resulting pointer.
The return value is encoded as for ccn_btree_searchnode().
Definition at line 371 of file ccn_btree.c.
Referenced by r_store_content_btree_insert(), r_store_look(), r_store_lookup(), r_store_lookup_backwards(), r_store_set_accession_from_offset(), r_sync_enumerate_action(), test_basic_btree_delete_entry(), test_basic_btree_insert_entry(), test_btree_inserts_from_stdin(), test_btree_lookup(), test_insert_content(), and testhelp_count_matches().
int ccn_btree_lookup_internal | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | root, | |||
int | stoplevel, | |||
const unsigned char * | key, | |||
size_t | size, | |||
struct ccn_btree_node ** | ansp | |||
) |
Do a btree lookup, starting from the provided root and stopping at stoplevel.
In the absence of errors, if *ansp is not NULL the handle for the appropriate node will be stored. See ccn_btree_getnode() for warning about lifetime of the resulting pointer.
The return value is encoded as for ccn_btree_searchnode().
Definition at line 395 of file ccn_btree.c.
Referenced by ccn_btree_lookup(), ccn_btree_next_leaf(), and ccn_btree_smallest_key_under().
int ccn_btree_next_leaf | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node, | |||
struct ccn_btree_node ** | ansp | |||
) |
Find the leaf that comes after the given node.
This may be used to walk though the leaf nodes in order. If success, sets *ansp to a leaf pointer or NULL
Definition at line 1101 of file ccn_btree.c.
Referenced by r_store_look(), and test_btree_inserts_from_stdin().
void* ccn_btree_node_getentry | ( | size_t | payload_bytes, | |
struct ccn_btree_node * | node, | |||
int | i | |||
) |
Get the address of the indexed entry within the node.
payload_bytes must be divisible by CCN_BT_SIZE_UNITS.
Definition at line 108 of file ccn_btree.c.
Referenced by ccn_btree_content_cobid(), ccn_btree_content_cobsz(), ccn_btree_content_set_cobid(), ccn_btree_insert_entry(), ccn_btree_match_interest(), ccn_btree_node_internal_entry(), ccn_btree_shrink_a_level(), ccn_btree_spill(), and ccn_btree_split().
int ccn_btree_node_getentrysize | ( | struct ccn_btree_node * | node | ) |
Size, in bytes, of entries within the node.
If there are no entries, returns 0. This size includes the entry trailer.
Definition at line 166 of file ccn_btree.c.
Referenced by ccn_btree_delete_entry(), ccn_btree_insert_entry(), and ccn_btree_node_payloadsize().
static struct ccn_btree_internal_payload* ccn_btree_node_internal_entry | ( | struct ccn_btree_node * | node, | |
int | i | |||
) | [static, read] |
Get the address of entry within an internal (non-leaf) node.
Definition at line 126 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_index_in_parent(), ccn_btree_lookup_internal(), ccn_btree_next_leaf(), ccn_btree_prev_leaf(), ccn_btree_shrink_a_level(), ccn_btree_spill(), and ccn_btree_split().
int ccn_btree_node_level | ( | struct ccn_btree_node * | node | ) |
Node level (leaves are at level 0).
Definition at line 203 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_grow_a_level(), ccn_btree_insert_entry(), ccn_btree_lookup_internal(), ccn_btree_prev_leaf(), ccn_btree_shrink_a_level(), ccn_btree_spill(), ccn_btree_split(), ccn_btree_unbalance(), scan_reusable(), and test_btree_lookup().
int ccn_btree_node_nent | ( | struct ccn_btree_node * | node | ) |
Number of entries within the btree node.
Definition at line 144 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_chknode(), ccn_btree_delete_entry(), ccn_btree_index_in_parent(), ccn_btree_insert_entry(), ccn_btree_next_leaf(), ccn_btree_prev_leaf(), ccn_btree_searchnode(), ccn_btree_shrink_a_level(), ccn_btree_spill(), ccn_btree_split(), ccn_btree_unbalance(), r_store_look(), r_store_lookup_backwards(), test_btree_searchnode(), and testhelp_count_matches().
int ccn_btree_node_payloadsize | ( | struct ccn_btree_node * | node | ) |
Size, in bytes, of payloads within the node.
If there are no entries, returns 0. This does not include the entry trailer, but will include padding to a multiple of CCN_BT_SIZE_UNITS.
Definition at line 189 of file ccn_btree.c.
Referenced by ccn_btree_shrink_a_level(), ccn_btree_spill(), and ccn_btree_split().
void ccn_btree_note_error | ( | struct ccn_btree * | bt, | |
int | info | |||
) |
Keep count of noticed errors.
Do this in one place so it is easy to set a breakpoint.
Definition at line 1263 of file ccn_btree.c.
Referenced by ccn_btree_check(), ccn_btree_close_node(), ccn_btree_getnode(), ccn_btree_grow_a_level(), ccn_btree_lookup_internal(), ccn_btree_prepare_for_update(), ccn_btree_shrink_a_level(), ccn_btree_spill(), and ccn_btree_split().
int ccn_btree_oversize | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node | |||
) |
Test for an oversize node.
This takes into account both the size of a node and the count of entries.
Definition at line 759 of file ccn_btree.c.
Referenced by ccn_btree_split(), and r_store_content_btree_insert().
int ccn_btree_prepare_for_update | ( | struct ccn_btree * | bt, | |
struct ccn_btree_node * | node | |||
) |
Get ready to update a btree node.
If applicable, open the node so that it will be in a good state to write later on.
Definition at line 1537 of file ccn_btree.c.
Referenced by ccn_btree_grow_a_level(), ccn_btree_shrink_a_level(), ccn_btree_spill(), ccn_btree_split(), r_store_content_btree_insert(), and r_store_set_accession_from_offset().
int ccn_btree_prev_leaf | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node, | |||
struct ccn_btree_node ** | ansp | |||
) |
Find the leaf that comes before the given node.
This may be used to walk though the leaf nodes in reverse order. If success, sets *ansp to a leaf pointer or NULL
Definition at line 1168 of file ccn_btree.c.
Referenced by r_store_lookup_backwards(), and test_btree_inserts_from_stdin().
struct ccn_btree_node* ccn_btree_rnode | ( | struct ccn_btree * | bt, | |
ccn_btnodeid | nodeid | |||
) | [read] |
Access a btree node that is already resident.
Care should be taken to not store the node handle in data structures, since it will become invalid when the node gets flushed from the resident cache.
This call does not bump the activity counter.
Definition at line 1436 of file ccn_btree.c.
Referenced by ccn_btree_update_cached_parent(), r_store_index_cleaner(), test_btree_init(), and test_btree_inserts_from_stdin().
int ccn_btree_searchnode | ( | const unsigned char * | key, | |
size_t | size, | |||
struct ccn_btree_node * | node | |||
) |
Search the node for the given key.
The return value is encoded as 2 * index + (found ? 1 : 0); that is, a successful search returns an odd number and an unsuccessful search returns an even number. In the case of an unsuccessful search, the index indicates where the item would go if it were to be inserted.
Uses a binary search, so the keys in the node must be sorted and unique.
Definition at line 332 of file ccn_btree.c.
Referenced by ccn_btree_lookup_internal(), ccn_btree_next_leaf(), ccn_btree_split(), and test_btree_searchnode().
static int ccn_btree_shrink_a_level | ( | struct ccn_btree * | btree | ) | [static] |
If the root is a singleton and not a leaf, remove a level.
Definition at line 694 of file ccn_btree.c.
Referenced by ccn_btree_spill().
static int ccn_btree_smallest_key_under | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node, | |||
struct ccn_charbuf * | result | |||
) | [static] |
Extracts the smallest key under the node.
Definition at line 452 of file ccn_btree.c.
Referenced by ccn_btree_spill().
int ccn_btree_spill | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node | |||
) |
Eliminate a node by combining it with a sibling.
In success case, the node will be emptied out completely, and The parent node will have one fewer child. It is possible for a sibling to need splitting; in this case btree->nextsplit will be set accordingly.
btree->nextspill will be set if there are more nodes to spill.
Definition at line 999 of file ccn_btree.c.
Referenced by test_btree_inserts_from_stdin().
int ccn_btree_split | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node | |||
) |
Split a btree node.
This creates a new sibling, and distributes the entries of node between the two.
The node's parent gains a child; if in doing so, it grows too large, the parent will be noted in btree->nextsplit for the caller to deal with.
Definition at line 828 of file ccn_btree.c.
Referenced by r_store_content_btree_insert(), test_basic_btree_insert_entry(), and test_btree_inserts_from_stdin().
void ccn_btree_storeval | ( | unsigned char * | p, | |
int | size, | |||
unsigned | v | |||
) |
Definition at line 54 of file ccn_btree.c.
int ccn_btree_unbalance | ( | struct ccn_btree * | btree, | |
struct ccn_btree_node * | node | |||
) |
Test for an unbalanced node.
This takes into account both the size of a node and the count of entries.
Definition at line 773 of file ccn_btree.c.
Referenced by ccn_btree_oversize(), and ccn_btree_spill().
static void ccn_btree_update_cached_parent | ( | struct ccn_btree * | btree, | |
struct ccn_btree_internal_payload * | olink, | |||
ccn_btnodeid | parentid | |||
) | [static] |
BTree implementation.
Update the cached parent pointer if necessary.
Definition at line 797 of file ccn_btree.c.
Referenced by ccn_btree_shrink_a_level(), ccn_btree_spill(), and ccn_btree_split().
static void ccn_charbuf_append_escaped | ( | struct ccn_charbuf * | dst, | |
struct ccn_charbuf * | src | |||
) | [static] |
Definition at line 1572 of file ccn_btree.c.
Referenced by ccn_btree_check().
static int compare_lexical | ( | struct ccn_charbuf * | a, | |
struct ccn_charbuf * | b | |||
) | [static] |
Definition at line 1558 of file ccn_btree.c.
Referenced by ccn_btree_check().
static void finalize_node | ( | struct hashtb_enumerator * | e | ) | [static] |
Definition at line 1246 of file ccn_btree.c.
Referenced by ccn_btree_create().
static void scan_reusable | ( | const unsigned char * | key, | |
size_t | keysize, | |||
struct ccn_btree_node * | node, | |||
int | ndx, | |||
unsigned | reuse[2] | |||
) | [static] |
Definition at line 470 of file ccn_btree.c.
Referenced by ccn_btree_insert_entry().
static struct ccn_btree_entry_trailer* seek_trailer | ( | struct ccn_btree_node * | node, | |
int | i | |||
) | [static, read] |
Find the entry trailer associated with entry i of the btree node.
Sets node->corrupt if a problem with the node's structure is discovered.
Definition at line 74 of file ccn_btree.c.
Referenced by ccn_btree_chknode(), ccn_btree_compare(), ccn_btree_key_append(), and ccn_btree_node_getentry().