Binary search to find position for key */
| 66 | |
| 67 | /* Binary search to find position for key */ |
| 68 | int 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 */ |
| 92 | BPlusNode* node_create(NodeType type, uint16_t capacity) { |
no test coverage detected