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

Function ApplyLabels

src/effects/effects_apply.c:166–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166static void ApplyLabels
167(
168 FILE *stream, // effects stream
169 GraphContext *gc, // graph to operate on
170 bool add // add or remove labels
171) {
172 //--------------------------------------------------------------------------
173 // effect format:
174 // effect type
175 // node ID
176 // labels count
177 // label IDs
178 //--------------------------------------------------------------------------
179
180 //--------------------------------------------------------------------------
181 // read node ID
182 //--------------------------------------------------------------------------
183
184 EntityID id;
185 fread_assert(&id, sizeof(id), stream);
186
187 //--------------------------------------------------------------------------
188 // get updated node
189 //--------------------------------------------------------------------------
190
191 Node n;
192 Graph *g = gc->g;
193
194 bool found = Graph_GetNode(g, id, &n);
195 ASSERT(found == true);
196
197 //--------------------------------------------------------------------------
198 // read labels count
199 //--------------------------------------------------------------------------
200
201 uint8_t lbl_count;
202 fread_assert(&lbl_count, sizeof(lbl_count), stream);
203 ASSERT(lbl_count > 0);
204
205 // TODO: move to LabelID
206 uint n_add_labels = 0;
207 uint n_remove_labels = 0;
208 const char **add_labels = NULL;
209 const char **remove_labels = NULL;
210 const char *lbl[lbl_count];
211
212 // assign lbl to the appropriate array
213 if(add) {
214 add_labels = lbl;
215 n_add_labels = lbl_count;
216 } else {
217 remove_labels = lbl;
218 n_remove_labels = lbl_count;
219 }
220
221 //--------------------------------------------------------------------------
222 // read labels
223 //--------------------------------------------------------------------------

Callers 1

Effects_ApplyFunction · 0.85

Calls 4

Graph_GetNodeFunction · 0.85
Schema_GetNameFunction · 0.85
UpdateNodeLabelsFunction · 0.85

Tested by

no test coverage detected