Lines Matching defs:leaf
69 * The leaf nodes just stay as-is until they are reclaimed.
189 * - Intermediate nodes -- arrays pointing to another level or a leaf;
394 const thmap_leaf_t *leaf, unsigned level)
396 const void *key = THMAP_GETPTR(thmap, leaf->key);
401 return (hash(thmap->seed, key, leaf->len, i) >> shift) & LEVEL_MASK;
406 const thmap_leaf_t *leaf)
411 return hashval_getleafslot(thmap, leaf, 0);
415 key_cmp_p(const thmap_t *thmap, const thmap_leaf_t *leaf,
418 const void *leafkey = THMAP_GETPTR(thmap, leaf->key);
419 return len == leaf->len && memcmp(key, leafkey, len) == 0;
484 * LEAF OPERATIONS.
490 thmap_leaf_t *leaf;
497 leaf = THMAP_GETPTR(thmap, leaf_off);
498 ASSERT(THMAP_ALIGNED_P(leaf));
510 leaf->key = key_off;
513 leaf->key = (uintptr_t)key;
515 leaf->len = len;
516 leaf->val = val;
517 return leaf;
521 leaf_free(const thmap_t *thmap, thmap_leaf_t *leaf)
524 gc_free(thmap, leaf->key, leaf->len);
526 gc_free(thmap, THMAP_GETOFF(thmap, leaf), sizeof(thmap_leaf_t));
553 root_try_put(thmap_t *thmap, const thmap_query_t *query, thmap_leaf_t *leaf)
579 slot = hashval_getl0slot(thmap, query, leaf);
580 node_insert(node, slot, THMAP_GETOFF(thmap, leaf) | THMAP_LEAF_BIT);
624 /* Descend the tree until we find a leaf or empty slot. */
698 thmap_leaf_t *leaf;
706 leaf = get_leaf(thmap, parent, slot);
707 if (!leaf) {
710 if (!key_cmp_p(thmap, leaf, key, len)) {
713 return leaf->val;
726 thmap_leaf_t *leaf, *other;
732 * First, pre-allocate and initialize the leaf node.
734 leaf = leaf_create(thmap, key, len, val);
735 if (__predict_false(!leaf)) {
743 switch (root_try_put(thmap, &query, leaf)) {
745 /* Success: the leaf was inserted; no locking involved. */
771 * Empty slot: simply insert the new leaf. The release
774 target = THMAP_GETOFF(thmap, leaf) | THMAP_LEAF_BIT;
785 * Duplicate. Free the pre-allocated leaf and
788 leaf_free(thmap, leaf);
800 leaf_free(thmap, leaf);
807 * Insert the other (colliding) leaf first. The new child is
816 * It becomes the new parent for the our new leaf.
818 * Ensure that stores to the child (and leaf) reach global
839 * Insert our new leaf once we expanded enough. The release
842 target = THMAP_GETOFF(thmap, leaf) | THMAP_LEAF_BIT;
856 thmap_leaf_t *leaf;
867 leaf = get_leaf(thmap, parent, slot);
868 if (!leaf || !key_cmp_p(thmap, leaf, key, len)) {
874 /* Remove the leaf. */
876 == leaf);
947 * Save the value and stage the leaf for G/C.
949 val = leaf->val;
951 stage_mem_gc(thmap, leaf->key, leaf->len);
953 stage_mem_gc(thmap, THMAP_GETOFF(thmap, leaf), sizeof(thmap_leaf_t));