performs binary search, returns the rightmost index of a match assuming 'v' exists in 'array'
| 68 | // performs binary search, returns the rightmost index of a match |
| 69 | // assuming 'v' exists in 'array' |
| 70 | static bool _binarySearchRightmost |
| 71 | ( |
| 72 | uint *idx, |
| 73 | Record *array, |
| 74 | uint array_len, |
| 75 | int join_key_idx, |
| 76 | SIValue v |
| 77 | ) { |
| 78 | ASSERT(idx != NULL); |
| 79 | |
| 80 | SIValue x; |
| 81 | uint pos = 0; |
| 82 | uint left = 0; |
| 83 | uint right = array_len; |
| 84 | |
| 85 | while(left < right) { |
| 86 | pos = (right + left) / 2; |
| 87 | x = Record_Get(array[pos], join_key_idx); |
| 88 | if(SIValue_Compare(v, x, NULL) < 0) right = pos; |
| 89 | else left = pos + 1; |
| 90 | } |
| 91 | |
| 92 | *idx = right - 1; |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | // retrive the next intersecting record |
| 97 | // if such exists, otherwise returns NULL |
no test coverage detected