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

Function AttributeSet_AddNoClone

src/graph/entities/attribute_set.c:169–214  ·  view source on GitHub ↗

adds an attribute to the set without cloning the SIvalue

Source from the content-addressed store, hash-verified

167
168// adds an attribute to the set without cloning the SIvalue
169void AttributeSet_AddNoClone
170(
171 AttributeSet *set, // set to update
172 Attribute_ID *ids, // identifiers
173 SIValue *values, // values
174 ushort n, // number of values to add
175 bool allowNull // accept NULLs
176) {
177 ASSERT(set != NULL);
178
179 // return if set is read-only
180 if(unlikely(ATTRIBUTE_SET_IS_READONLY(*set))) {
181 return;
182 }
183
184 // validate value type
185 // value must be a valid property type
186#ifdef RG_DEBUG
187 SIType t = SI_VALID_PROPERTY_VALUE;
188 if(allowNull == true) {
189 t |= T_NULL;
190 }
191
192 for(ushort i = 0; i < n; i++) {
193 ASSERT(SI_TYPE(values[i]) & t);
194 // make sure attribute isn't already in set
195 ASSERT(AttributeSet_Get(*set, ids[i]) == ATTRIBUTE_NOTFOUND);
196 // make sure value isn't volotile
197 ASSERT(SI_ALLOCATION(values + i) != M_VOLATILE);
198 }
199#endif
200
201 ushort prev_count = AttributeSet_Count(*set);
202 AttributeSet _set = AttributeSet_AddPrepare(set, n);
203 Attribute *attrs = _set->attributes + prev_count;
204
205 // add attributes to set
206 for(ushort i = 0; i < n; i++) {
207 Attribute *attr = attrs + i;
208 attr->id = ids[i];
209 attr->value = values[i];
210 }
211
212 // update pointer
213 *set = _set;
214}
215
216// adds an attribute to the set
217void AttributeSet_Add

Callers 11

_RdbLoadEntityFunction · 0.85
_RdbLoadEntityFunction · 0.85
_RdbLoadEntityFunction · 0.85
_RdbLoadEntityFunction · 0.85
_RdbLoadEntityFunction · 0.85
_RdbLoadEntityFunction · 0.85
ReadAttributeSetFunction · 0.85
UpdateNodePropertyFunction · 0.85
UpdateEdgePropertyFunction · 0.85
ConvertPropertyMapFunction · 0.85

Calls 3

AttributeSet_GetFunction · 0.85
AttributeSet_CountFunction · 0.85
AttributeSet_AddPrepareFunction · 0.85

Tested by

no test coverage detected