MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / node_find_position

Function node_find_position

python/bplustree_c_src/node_ops.c:68–89  ·  view source on GitHub ↗

Binary search to find position for key */

Source from the content-addressed store, hash-verified

66
67/* Binary search to find position for key */
68int node_find_position(BPlusNode *node, PyObject *key) {
69 int left = 0;
70 int right = node->num_keys;
71
72 while (left < right) {
73 int mid = (left + right) / 2;
74 PyObject *mid_key = node_get_key(node, mid);
75
76 int result = fast_compare_lt(mid_key, key);
77 if (result < 0) {
78 return -1; /* Error in comparison */
79 }
80
81 if (result) {
82 left = mid + 1;
83 } else {
84 right = mid;
85 }
86 }
87
88 return left;
89}
90
91/* Create a new node */
92BPlusNode* node_create(NodeType type, uint16_t capacity) {

Callers 6

tree_find_leafFunction · 0.85
tree_insert_recursiveFunction · 0.85
node_insert_branchFunction · 0.85
node_insert_leafFunction · 0.85
node_deleteFunction · 0.85
node_getFunction · 0.85

Calls 2

node_get_keyFunction · 0.85
fast_compare_ltFunction · 0.85

Tested by

no test coverage detected