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

Function _BulkInsert_ProcessNodeFile

src/bulk_insert/bulk_insert.c:197–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197static int _BulkInsert_ProcessNodeFile
198(
199 GraphContext* gc,
200 const char* data,
201 size_t data_len
202) {
203 uint prop_count;
204 size_t data_idx = 0;
205
206 // read the CSV file header labels and update all schemas
207 int* label_ids = _BulkInsert_ReadHeaderLabels(gc, SCHEMA_NODE, data, &data_idx);
208 uint label_count = array_len(label_ids);
209 // read the CSV header properties and collect their indices
210 Attribute_ID* prop_indices = _BulkInsert_ReadHeaderProperties(gc, SCHEMA_NODE, data,
211 &data_idx, &prop_count);
212
213 // sync each matrix once
214 ASSERT(Graph_GetMatrixPolicy(gc->g) == SYNC_POLICY_RESIZE);
215
216 for (uint i = 0; i < label_count; i++) {
217 Graph_GetLabelMatrix(gc->g, label_ids[i]);
218 }
219
220 // sync node-label matrix
221 Graph_GetNodeLabelMatrix(gc->g);
222 Graph_SetMatrixPolicy(gc->g, SYNC_POLICY_NOP);
223
224 //--------------------------------------------------------------------------
225 // load nodes
226 //--------------------------------------------------------------------------
227
228 while (data_idx < data_len) {
229 Node n = GE_NEW_NODE();
230 GraphEntity* ge;
231 Graph_CreateNode(gc->g, &n, label_ids, label_count);
232 ge = (GraphEntity*)&n;
233 // process entity attributes
234 for (uint i = 0; i < prop_count; i++) {
235 SIValue value = _BulkInsert_ReadProperty(data, &data_idx);
236 // skip invalid attribute values
237 if (!(SI_TYPE(value) & SI_VALID_PROPERTY_VALUE))
238 continue;
239 GraphEntity_AddProperty(ge, prop_indices[i], value);
240 }
241 }
242
243 Graph_SetMatrixPolicy(gc->g, SYNC_POLICY_RESIZE);
244 if (prop_indices) rm_free(prop_indices);
245 array_free(label_ids);
246
247 return BULK_OK;
248}
249
250static int _BulkInsert_ProcessEdgeFile
251(

Callers 1

Calls 12

array_lenFunction · 0.85
Graph_GetMatrixPolicyFunction · 0.85
Graph_GetLabelMatrixFunction · 0.85
Graph_GetNodeLabelMatrixFunction · 0.85
Graph_SetMatrixPolicyFunction · 0.85
Graph_CreateNodeFunction · 0.85
_BulkInsert_ReadPropertyFunction · 0.85
GraphEntity_AddPropertyFunction · 0.85
rm_freeFunction · 0.85
array_freeFunction · 0.85

Tested by

no test coverage detected