コード例 #1
0
 public override void VisitGraphPropertyChanges(IEnumerator <StorageProperty> added, IEnumerator <StorageProperty> changed, IntIterable removed)
 {
     removed.each(_recordState.graphRemoveProperty);
     while (changed.MoveNext())
     {
         StorageProperty prop = changed.Current;
         _recordState.graphChangeProperty(prop.PropertyKeyId(), prop.Value());
     }
     while (added.MoveNext())
     {
         StorageProperty prop = added.Current;
         _recordState.graphAddProperty(prop.PropertyKeyId(), prop.Value());
     }
 }
コード例 #2
0
 public override void VisitNodePropertyChanges(long id, IEnumerator <StorageProperty> added, IEnumerator <StorageProperty> changed, IntIterable removed)
 {
     removed.each(propId => _recordState.nodeRemoveProperty(id, propId));
     while (changed.MoveNext())
     {
         StorageProperty prop = changed.Current;
         _recordState.nodeChangeProperty(id, prop.PropertyKeyId(), prop.Value());
     }
     while (added.MoveNext())
     {
         StorageProperty prop = added.Current;
         _recordState.nodeAddProperty(id, prop.PropertyKeyId(), prop.Value());
     }
 }
コード例 #3
0
        private void TakeSnapshot()
        {
            try
            {
                using (StorageNodeCursor node = _store.allocateNodeCursor(), StoragePropertyCursor properties = _store.allocatePropertyCursor(), StorageRelationshipScanCursor relationship = _store.allocateRelationshipScanCursor())
                {
                    TokenRead tokenRead = _transaction.tokenRead();
                    _state.addedAndRemovedNodes().Removed.each(nodeId =>
                    {
                        node.Single(nodeId);
                        if (node.Next())
                        {
                            properties.Init(node.PropertiesReference());
                            while (properties.Next())
                            {
                                try
                                {
                                    _removedNodeProperties.Add(new NodePropertyEntryView(this, nodeId, tokenRead.PropertyKeyName(properties.PropertyKey()), null, properties.PropertyValue()));
                                }
                                catch (PropertyKeyIdNotFoundKernelException e)
                                {
                                    throw new System.InvalidOperationException("Nonexisting properties was modified for node " + nodeId, e);
                                }
                            }

                            foreach (long labelId in node.Labels())
                            {
                                try
                                {
                                    _removedLabels.Add(new LabelEntryView(this, nodeId, tokenRead.NodeLabelName(toIntExact(labelId))));
                                }
                                catch (LabelNotFoundKernelException e)
                                {
                                    throw new System.InvalidOperationException("Nonexisting label was modified for node " + nodeId, e);
                                }
                            }
                        }
                    });
                    _state.addedAndRemovedRelationships().Removed.each(relId =>
                    {
                        Relationship relationshipProxy = relationship(relId);
                        relationship.Single(relId);
                        if (relationship.Next())
                        {
                            properties.Init(relationship.PropertiesReference());
                            while (properties.Next())
                            {
                                try
                                {
                                    _removedRelationshipProperties.Add(new RelationshipPropertyEntryView(relationshipProxy, tokenRead.PropertyKeyName(properties.PropertyKey()), null, properties.PropertyValue()));
                                }
                                catch (PropertyKeyIdNotFoundKernelException e)
                                {
                                    throw new System.InvalidOperationException("Nonexisting node properties was modified for relationship " + relId, e);
                                }
                            }
                        }
                    });
                    foreach (NodeState nodeState in _state.modifiedNodes())
                    {
                        IEnumerator <StorageProperty> added = nodeState.AddedAndChangedProperties();
                        long nodeId = nodeState.Id;
                        while (added.MoveNext())
                        {
                            StorageProperty property = added.Current;
                            _assignedNodeProperties.Add(new NodePropertyEntryView(this, nodeId, tokenRead.PropertyKeyName(property.PropertyKeyId()), property.Value(), CommittedValue(nodeState, property.PropertyKeyId(), node, properties)));
                        }
                        nodeState.RemovedProperties().each(id =>
                        {
                            try
                            {
                                NodePropertyEntryView entryView = new NodePropertyEntryView(this, nodeId, tokenRead.PropertyKeyName(id), null, CommittedValue(nodeState, id, node, properties));
                                _removedNodeProperties.Add(entryView);
                            }
                            catch (PropertyKeyIdNotFoundKernelException e)
                            {
                                throw new System.InvalidOperationException("Nonexisting node properties was modified for node " + nodeId, e);
                            }
                        });

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.LongDiffSets labels = nodeState.labelDiffSets();
                        LongDiffSets labels = nodeState.LabelDiffSets();
                        AddLabelEntriesTo(nodeId, labels.Added, _assignedLabels);
                        AddLabelEntriesTo(nodeId, labels.Removed, _removedLabels);
                    }
                    foreach (RelationshipState relState in _state.modifiedRelationships())
                    {
                        Relationship relationshipProxy      = relationship(relState.Id);
                        IEnumerator <StorageProperty> added = relState.AddedAndChangedProperties();
                        while (added.MoveNext())
                        {
                            StorageProperty property = added.Current;
                            _assignedRelationshipProperties.Add(new RelationshipPropertyEntryView(relationshipProxy, tokenRead.PropertyKeyName(property.PropertyKeyId()), property.Value(), CommittedValue(relState, property.PropertyKeyId(), relationship, properties)));
                        }
                        relState.RemovedProperties().each(id =>
                        {
                            try
                            {
                                RelationshipPropertyEntryView entryView = new RelationshipPropertyEntryView(relationshipProxy, tokenRead.PropertyKeyName(id), null, CommittedValue(relState, id, relationship, properties));
                                _removedRelationshipProperties.Add(entryView);
                            }
                            catch (PropertyKeyIdNotFoundKernelException e)
                            {
                                throw new System.InvalidOperationException("Nonexisting properties was modified for relationship " + relState.Id, e);
                            }
                        });
                    }
                }
            }
            catch (PropertyKeyIdNotFoundKernelException e)
            {
                throw new System.InvalidOperationException("An entity that does not exist was modified.", e);
            }
        }