Exemple #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static String[] getPropertyKeys(org.neo4j.internal.kernel.api.TokenRead tokenRead, int...properties) throws org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException
        public static string[] GetPropertyKeys(TokenRead tokenRead, params int[] properties)
        {
            string[] propertyKeys = new string[properties.Length];
            for (int i = 0; i < properties.Length; i++)
            {
                propertyKeys[i] = tokenRead.PropertyKeyName(properties[i]);
            }
            return(propertyKeys);
        }
        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);
            }
        }