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

Function BulkInsert

src/bulk_insert/bulk_insert.c:336–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336int BulkInsert
337(
338 RedisModuleCtx* ctx,
339 GraphContext* gc,
340 RedisModuleString** argv,
341 int argc,
342 uint node_count,
343 uint edge_count
344) {
345 ASSERT(gc != NULL);
346 ASSERT(ctx != NULL);
347 ASSERT(argv != NULL);
348
349 if (argc < 2) {
350 RedisModule_ReplyWithError(ctx, "Bulk insert format error, \
351 failed to parse bulk insert sections.");
352 return BULK_FAIL;
353 }
354
355 // read the number of node tokens
356 long long node_token_count;
357 long long relation_token_count;
358
359 if (RedisModule_StringToLongLong(*argv++, &node_token_count) != REDISMODULE_OK) {
360 RedisModule_ReplyWithError(ctx, "Error parsing number of node \
361 descriptor tokens.");
362 return BULK_FAIL;
363 }
364
365 // read the number of relation tokens
366 if (RedisModule_StringToLongLong(*argv++, &relation_token_count) != REDISMODULE_OK) {
367 RedisModule_ReplyWithError(ctx, "Error parsing number of relation \
368 descriptor tokens.");
369 return BULK_FAIL;
370 }
371
372 Graph* g = gc->g;
373 int res = BULK_OK;
374
375 // lock graph under write lock
376 // allocate space for new nodes and edges
377 // set graph sync policy to resize only
378 Graph_AcquireWriteLock(g);
379 Graph_SetMatrixPolicy(g, SYNC_POLICY_RESIZE);
380 Graph_AllocateNodes(g, node_count);
381 Graph_AllocateEdges(g, edge_count);
382
383 argc -= 2;
384
385 if (node_token_count > 0) {
386 ASSERT(argc >= node_token_count);
387 // process all node files
388 if (_BulkInsert_ProcessTokens(gc, node_token_count, argv,
389 SCHEMA_NODE)
390 != BULK_OK) {
391 res = BULK_FAIL;
392 goto cleanup;
393 }

Callers 1

Graph_BulkInsertFunction · 0.85

Calls 6

Graph_AcquireWriteLockFunction · 0.85
Graph_SetMatrixPolicyFunction · 0.85
Graph_AllocateNodesFunction · 0.85
Graph_AllocateEdgesFunction · 0.85
Graph_ReleaseLockFunction · 0.85

Tested by

no test coverage detected