int oc_bpt_insert_range_b( struct Oc_wu *wu_p, Oc_bpt_state *s_p, int length, struct Oc_bpt_key *key_array, struct Oc_bpt_data *data_array) { int rc; if (0 == length) return 0; oc_bpt_trace_wu_lvl( 2, OC_EV_BPT_INSERT_RANGE, wu_p, "tid=%Lu [%s]", s_p->tid, oc_bpt_nd_string_of_2key( s_p, oc_bpt_nd_key_array_kth(s_p, key_array, 0), oc_bpt_nd_key_array_kth(s_p, key_array, length-1))); oc_utl_debugassert(s_p->cfg_p->initialized); oc_utl_trk_crt_lock_read(wu_p, &s_p->lock); rc = oc_bpt_op_insert_range_b(wu_p, s_p, length, key_array, data_array); oc_utl_trk_crt_unlock(wu_p, &s_p->lock); oc_bpt_trace_wu_lvl(3, OC_EV_BPT_INSERT_RANGE, wu_p, "rc=%d", rc); return rc; }
void oc_bpt_lookup_range_b( struct Oc_wu *wu_p, Oc_bpt_state *s_p, struct Oc_bpt_key *min_key_p, struct Oc_bpt_key *max_key_p, int max_num_keys_i, struct Oc_bpt_key *key_array_po, struct Oc_bpt_data *data_array_po, int *nkeys_found_po) { struct Oc_bpt_op_lookup_range lkr; oc_bpt_trace_wu_lvl(2, OC_EV_BPT_LOOKUP_RANGE, wu_p, "tid=%Lu [%s]", s_p->tid, oc_bpt_nd_string_of_2key(s_p, min_key_p, max_key_p)); oc_utl_debugassert(s_p->cfg_p->initialized); lkr.min_key_p = min_key_p; lkr.max_key_p = max_key_p; lkr.max_num_keys_i = max_num_keys_i; lkr.key_array_po = key_array_po; lkr.data_array_po = data_array_po; lkr.nkeys_found_po = nkeys_found_po; // There are too many arguments, we stuff them into a single structure oc_utl_trk_crt_lock_read(wu_p, &s_p->lock); oc_bpt_op_lookup_range_b(wu_p, s_p, &lkr); oc_utl_trk_crt_unlock(wu_p, &s_p->lock); }
static Oc_bpt_node* node_get_sl(Oc_wu *wu_p, uint64 addr) { Oc_bpt_node *node_p; while (1) { node_p = node_get(wu_p, addr); oc_utl_trk_crt_lock_read(wu_p, &node_p->lock); if (node_p->disk_addr != addr) { node_release(wu_p, node_p); } else break; } oc_utl_debugassert(addr == node_p->disk_addr); return node_p; }
bool oc_bpt_remove_key_b( struct Oc_wu *wu_p, struct Oc_bpt_state *s_p, struct Oc_bpt_key *key_p) { bool rc; oc_bpt_trace_wu_lvl(2, OC_EV_BPT_REMOVE_KEY, wu_p, "tid=%Lu %s", s_p->tid, oc_bpt_nd_string_of_key(s_p, key_p)); oc_utl_debugassert(s_p->cfg_p->initialized); oc_utl_trk_crt_lock_read(wu_p, &s_p->lock); rc = oc_bpt_op_remove_key_b(wu_p, s_p, key_p); oc_utl_trk_crt_unlock(wu_p, &s_p->lock); return rc; }
bool oc_bpt_lookup_key_b( struct Oc_wu *wu_p, struct Oc_bpt_state *s_p, struct Oc_bpt_key *key_p, struct Oc_bpt_data *data_po) { bool rc; oc_bpt_trace_wu_lvl(2, OC_EV_BPT_LOOKUP_KEY, wu_p, "tid=%Lu key=%s", s_p->tid, oc_bpt_nd_string_of_key(s_p, key_p)); oc_utl_debugassert(s_p->cfg_p->initialized); oc_utl_trk_crt_lock_read(wu_p, &s_p->lock); rc = oc_bpt_op_lookup_b(wu_p, s_p, key_p, data_po); oc_utl_trk_crt_unlock(wu_p, &s_p->lock); return rc; }
void oc_bpt_delete_b( struct Oc_wu *wu_p, struct Oc_bpt_state *s_p) { oc_bpt_trace_wu_lvl(2, OC_EV_BPT_DELETE, wu_p, "tid=%Lu", s_p->tid); oc_utl_debugassert(s_p->cfg_p->initialized); oc_utl_trk_crt_lock_write(wu_p, &s_p->lock); /* We need to upgrade the root-lock to a shared-lock * because the delete-code unlocks all the pages after * deleting them. This means that the root cannot remain * unlocked, as usual. */ oc_utl_trk_crt_lock_read(wu_p, &s_p->root_node_p->lock); oc_bpt_utl_delete_subtree_b(wu_p, s_p, s_p->root_node_p); s_p->root_node_p = NULL; oc_utl_trk_crt_unlock(wu_p, &s_p->lock); }