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

Function CommitUpdates

src/execution_plan/ops/shared/update_functions.c:42–118  ·  view source on GitHub ↗

commits delayed updates

Source from the content-addressed store, hash-verified

40
41// commits delayed updates
42void CommitUpdates
43(
44 GraphContext *gc,
45 dict *updates,
46 EntityType type
47) {
48 ASSERT(gc != NULL);
49 ASSERT(updates != NULL);
50 ASSERT(type != ENTITY_UNKNOWN);
51
52 uint update_count = HashTableElemCount(updates);
53 bool constraint_violation = false;
54
55 // return early if no updates are enqueued
56 if(update_count == 0) return;
57
58 dictEntry *entry;
59 dictIterator *it = HashTableGetIterator(updates);
60 MATRIX_POLICY policy = Graph_GetMatrixPolicy(gc->g);
61 Graph_SetMatrixPolicy(gc->g, SYNC_POLICY_NOP);
62
63 while((entry = HashTableNext(it)) != NULL) {
64 PendingUpdateCtx *update = HashTableGetVal(entry);
65
66 // if entity has been deleted, perform no updates
67 if(GraphEntity_IsDeleted(update->ge)) continue;
68
69 AttributeSet_PersistValues(update->attributes);
70
71 // update the attributes on the graph entity
72 UpdateEntityProperties(gc, update->ge, update->attributes,
73 type == ENTITY_NODE ? GETYPE_NODE : GETYPE_EDGE, true);
74 update->attributes = NULL;
75
76 if(type == ENTITY_NODE) {
77 UpdateNodeLabels(gc, (Node*)update->ge, update->add_labels,
78 update->remove_labels, array_len(update->add_labels),
79 array_len(update->remove_labels), true);
80 }
81
82 //----------------------------------------------------------------------
83 // enforce constraints
84 //----------------------------------------------------------------------
85
86 if(constraint_violation == false) {
87 // retrieve labels/rel-type
88 uint label_count = 1;
89 if (type == ENTITY_NODE) {
90 label_count = Graph_LabelTypeCount(gc->g);
91 }
92 LabelID labels[label_count];
93 if (type == ENTITY_NODE) {
94 label_count = Graph_GetNodeLabels(gc->g, (Node*)update->ge, labels,
95 label_count);
96 } else {
97 labels[0] = Edge_GetRelationID((Edge*)update->ge);
98 }
99

Callers 2

MergeConsumeFunction · 0.85
UpdateConsumeFunction · 0.85

Calls 15

HashTableElemCountFunction · 0.85
HashTableGetIteratorFunction · 0.85
Graph_GetMatrixPolicyFunction · 0.85
Graph_SetMatrixPolicyFunction · 0.85
HashTableNextFunction · 0.85
HashTableGetValFunction · 0.85
GraphEntity_IsDeletedFunction · 0.85
UpdateEntityPropertiesFunction · 0.85
UpdateNodeLabelsFunction · 0.85
array_lenFunction · 0.85
Graph_LabelTypeCountFunction · 0.85

Tested by

no test coverage detected