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

Function AttributeSet_Add

src/graph/entities/attribute_set.c:217–246  ·  view source on GitHub ↗

adds an attribute to the set

Source from the content-addressed store, hash-verified

215
216// adds an attribute to the set
217void AttributeSet_Add
218(
219 AttributeSet *set, // set to update
220 Attribute_ID attr_id, // attribute identifier
221 SIValue value // attribute value
222) {
223 ASSERT(set != NULL);
224
225 // return if set is read-only
226 if(unlikely(ATTRIBUTE_SET_IS_READONLY(*set))) {
227 return;
228 }
229
230#ifdef RG_DEBUG
231 // value must be a valid property type
232 ASSERT(SI_TYPE(value) & SI_VALID_PROPERTY_VALUE);
233 // make sure attribute isn't already in set
234 ASSERT(AttributeSet_Get(*set, attr_id) == ATTRIBUTE_NOTFOUND);
235#endif
236
237 AttributeSet _set = AttributeSet_AddPrepare(set, 1);
238
239 // set attribute
240 Attribute *attr = _set->attributes + _set->attr_count - 1;
241 attr->id = attr_id;
242 attr->value = SI_CloneValue(value);
243
244 // update pointer
245 *set = _set;
246}
247
248// add, remove or update an attribute
249// this function allows NULL value to be added to the set

Callers 1

GraphEntity_AddPropertyFunction · 0.85

Calls 3

AttributeSet_GetFunction · 0.85
AttributeSet_AddPrepareFunction · 0.85
SI_CloneValueFunction · 0.85

Tested by

no test coverage detected