//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void lockAllNodesAndConsumeRelationships(long nodeId, final org.neo4j.internal.kernel.api.Transaction transaction, org.neo4j.internal.kernel.api.NodeCursor nodes) throws org.neo4j.internal.kernel.api.exceptions.KernelException //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: internal virtual void LockAllNodesAndConsumeRelationships(long nodeId, Transaction transaction, NodeCursor nodes) { bool retry; do { retry = false; _firstRelId = NO_SUCH_RELATIONSHIP; // lock all the nodes involved by following the node id ordering CollectAndSortNodeIds(nodeId, transaction, nodes); LockAllNodes(_sortedNodeIds); // perform the action on each relationship, we will retry if the the relationship iterator contains // new relationships [email protected] read = transaction.DataRead(); read.SingleNode(nodeId, nodes); //if the node is not there, someone else probably deleted it, just ignore if (nodes.Next()) { using (RelationshipSelectionCursor rels = RelationshipSelections.allCursor(transaction.Cursors(), nodes, null)) { bool first = true; while (rels.Next() && !retry) { retry = PerformAction(rels.RelationshipReference(), first); first = false; } } } } while (retry); }
private void CollectAndSortNodeIds(long nodeId, Transaction transaction, NodeCursor nodes) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet nodeIdSet = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(); MutableLongSet nodeIdSet = new LongHashSet(); nodeIdSet.add(nodeId); [email protected] read = transaction.DataRead(); read.SingleNode(nodeId, nodes); if (!nodes.Next()) { this._sortedNodeIds = _empty; return; } using (RelationshipSelectionCursor rels = RelationshipSelections.allCursor(transaction.Cursors(), nodes, null)) { while (rels.Next()) { if (_firstRelId == NO_SUCH_RELATIONSHIP) { _firstRelId = rels.RelationshipReference(); } nodeIdSet.add(rels.SourceNodeReference()); nodeIdSet.add(rels.TargetNodeReference()); } } this._sortedNodeIds = nodeIdSet.toSortedArray(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void singleNode(org.neo4j.internal.kernel.api.Read read, org.neo4j.internal.kernel.api.NodeCursor nodeCursor, long node) throws org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException private static void SingleNode(Read read, NodeCursor nodeCursor, long node) { read.SingleNode(node, nodeCursor); if (!nodeCursor.Next()) { throw new EntityNotFoundException(EntityType.NODE, node); } }
private static int CalculateTotalDegreeIfDense(Read read, long node, NodeCursor nodeCursor, Direction direction, int[] relTypes, CursorFactory cursors) { read.SingleNode(node, nodeCursor); if (!nodeCursor.Next()) { return(0); } if (!nodeCursor.Dense) { return(NOT_DENSE_DEGREE); } return(CalculateTotalDegree(nodeCursor, direction, relTypes, cursors)); }
public static RelationshipSelectionCursor ConnectingRelationships(Read read, CursorFactory cursors, NodeCursor nodeCursor, long fromNode, Direction direction, long toNode, int[] relTypes) { //Check from int fromDegree = CalculateTotalDegreeIfDense(read, fromNode, nodeCursor, direction, relTypes, cursors); if (fromDegree == 0) { return(Org.Neo4j.@internal.Kernel.Api.helpers.RelationshipSelectionCursor_EMPTY); } bool fromNodeIsDense = fromDegree != NOT_DENSE_DEGREE; //Check to read.SingleNode(toNode, nodeCursor); if (!nodeCursor.Next()) { return(Org.Neo4j.@internal.Kernel.Api.helpers.RelationshipSelectionCursor_EMPTY); } bool toNodeIsDense = nodeCursor.Dense; //Both are dense, start with the one with the lesser degree if (fromNodeIsDense && toNodeIsDense) { //Note that we have already position the cursor at toNode int toDegree = CalculateTotalDegree(nodeCursor, direction, relTypes, cursors); long startNode; long endNode; Direction relDirection; if (fromDegree < toDegree) { startNode = fromNode; endNode = toNode; relDirection = direction; } else { startNode = toNode; endNode = fromNode; relDirection = direction.reverse(); } return(ConnectingRelationshipsIterator(CompiledCursorUtils.NodeGetRelationships(read, cursors, nodeCursor, startNode, relDirection, relTypes), endNode)); } else if (fromNodeIsDense) { return(ConnectingRelationshipsIterator(CompiledCursorUtils.NodeGetRelationships(read, cursors, nodeCursor, toNode, direction.reverse(), relTypes), fromNode)); } else { //either only toNode is dense or none of them, just go with what we got return(ConnectingRelationshipsIterator(CompiledCursorUtils.NodeGetRelationships(read, cursors, nodeCursor, fromNode, direction, relTypes), toNode)); } }
internal static int NodeGetDegreeIfDense(Read read, long node, NodeCursor nodeCursor, CursorFactory cursors, Direction direction, int type) { read.SingleNode(node, nodeCursor); if (!nodeCursor.Next()) { return(0); } if (!nodeCursor.Dense) { return(NOT_DENSE_DEGREE); } return(NodeGetDegree(nodeCursor, cursors, direction, type)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void txReturnsCorrectIdWhenReadOnly() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TxReturnsCorrectIdWhenReadOnly() { ExecuteDummyTxs(Db, 42); [email protected] tx = NewTransaction(); using (NodeCursor node = tx.Cursors().allocateNodeCursor()) { tx.DataRead().singleNode(1, node); node.Next(); } tx.Success(); assertEquals(KernelTransaction.READ_ONLY, tx.CloseTransaction()); assertFalse(tx.Open); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void validateNodePropertyExistenceConstraint(org.neo4j.internal.kernel.api.NodeLabelIndexCursor allNodes, org.neo4j.internal.kernel.api.NodeCursor nodeCursor, org.neo4j.internal.kernel.api.PropertyCursor propertyCursor, org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor descriptor) throws org.neo4j.internal.kernel.api.exceptions.schema.CreateConstraintFailureException public override void ValidateNodePropertyExistenceConstraint(NodeLabelIndexCursor allNodes, NodeCursor nodeCursor, PropertyCursor propertyCursor, LabelSchemaDescriptor descriptor) { while (allNodes.Next()) { allNodes.Node(nodeCursor); while (nodeCursor.Next()) { foreach (int propertyKey in descriptor.PropertyIds) { nodeCursor.Properties(propertyCursor); if (!HasProperty(propertyCursor, propertyKey)) { throw CreateConstraintFailure(new NodePropertyExistenceException(descriptor, VERIFICATION, nodeCursor.NodeReference())); } } } } }
public static RelationshipSelectionCursor NodeGetRelationships(Read read, CursorFactory cursors, NodeCursor node, long nodeId, Direction direction, int[] types) { read.SingleNode(nodeId, node); if (!node.Next()) { return(Org.Neo4j.@internal.Kernel.Api.helpers.RelationshipSelectionCursor_EMPTY); } switch (direction.innerEnumValue) { case Direction.InnerEnum.OUTGOING: return(RelationshipSelections.outgoingCursor(cursors, node, types)); case Direction.InnerEnum.INCOMING: return(RelationshipSelections.incomingCursor(cursors, node, types)); case Direction.InnerEnum.BOTH: return(RelationshipSelections.allCursor(cursors, node, types)); default: throw new System.InvalidOperationException("Unknown direction " + direction); } }