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

Function Map_Get

src/datatypes/map.c:139–159  ·  view source on GitHub ↗

retrieves value under key, map[key] sets 'value' to NULL if key isn't in map

Source from the content-addressed store, hash-verified

137// retrieves value under key, map[key]
138// sets 'value' to NULL if key isn't in map
139bool Map_Get
140(
141 SIValue map,
142 SIValue key,
143 SIValue *value
144) {
145 ASSERT(SI_TYPE(map) & T_MAP);
146 ASSERT(SI_TYPE(key) & T_STRING);
147 ASSERT(value != NULL);
148
149 int idx = Map_KeyIdx(map, key);
150
151 // key isn't in map, set 'value' to NULL and return
152 if(idx == -1) {
153 *value = SI_NullVal();
154 return false;
155 } else {
156 *value = SI_ShareValue(map.map[idx].val);
157 return true;
158 }
159}
160
161void Map_GetIdx
162(

Callers 4

AR_PROPERTYFunction · 0.85
test_empty_mapFunction · 0.85
test_map_addFunction · 0.85
test_map_removeFunction · 0.85

Calls 3

Map_KeyIdxFunction · 0.85
SI_NullValFunction · 0.85
SI_ShareValueFunction · 0.85

Tested by 3

test_empty_mapFunction · 0.68
test_map_addFunction · 0.68
test_map_removeFunction · 0.68