commits delayed updates
| 40 | |
| 41 | // commits delayed updates |
| 42 | void 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 |
no test coverage detected