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

Function _removeEntryFromMultiValArr

src/graph/rg_matrix/rg_remove_entry.c:13–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "../../util/rmalloc.h"
12
13static bool _removeEntryFromMultiValArr
14(
15 uint64_t **entries, // multi-value array
16 uint64_t entry // element to remove output new value
17) {
18 ASSERT(*entries != NULL);
19
20 uint i = 0;
21 uint n = array_len(*entries);
22
23 // search for entry
24 for(; i < n; i++) {
25 if((*entries)[i] == entry) {
26 break;
27 }
28 }
29
30 ASSERT(i < n);
31
32 // remove located entry
33 // migrate last element and reduce array size
34 array_del_fast(*entries, i);
35
36 // incase we're left with a single entry revert back to scalar
37 if(array_len(*entries) == 1) {
38 entry = (*entries)[0];
39 array_free(*entries);
40 *entries = (uint64_t *)entry;
41 return true;
42 }
43
44 return false;
45}
46
47static GrB_Info _removeElementMultiVal
48(

Callers 1

_removeElementMultiValFunction · 0.85

Calls 2

array_lenFunction · 0.85
array_freeFunction · 0.85

Tested by

no test coverage detected