MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _binarySearchRightmost

Function _binarySearchRightmost

src/execution_plan/ops/op_value_hash_join.c:70–94  ·  view source on GitHub ↗

performs binary search, returns the rightmost index of a match assuming 'v' exists in 'array'

Source from the content-addressed store, hash-verified

68// performs binary search, returns the rightmost index of a match
69// assuming 'v' exists in 'array'
70static 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

Callers 1

_set_intersection_idxFunction · 0.85

Calls 2

Record_GetFunction · 0.85
SIValue_CompareFunction · 0.85

Tested by

no test coverage detected