//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldComputeDegreeWithoutType() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldComputeDegreeWithoutType() { // GIVEN long node; using (Transaction tx = Transaction()) { Write write = tx.DataWrite(); node = write.NodeCreate(); write.RelationshipCreate(node, tx.TokenWrite().relationshipTypeGetOrCreateForName("R1"), write.NodeCreate()); write.RelationshipCreate(node, tx.TokenWrite().relationshipTypeGetOrCreateForName("R2"), write.NodeCreate()); write.RelationshipCreate(write.NodeCreate(), tx.TokenWrite().relationshipTypeGetOrCreateForName("R3"), node); write.RelationshipCreate(node, tx.TokenWrite().relationshipTypeGetOrCreateForName("R4"), node); tx.Success(); } using (Transaction tx = Transaction()) { Read read = tx.DataRead(); CursorFactory cursors = tx.Cursors(); using (NodeCursor nodes = cursors.AllocateNodeCursor()) { assertThat(CompiledExpandUtils.NodeGetDegreeIfDense(read, node, nodes, cursors, OUTGOING), equalTo(3)); assertThat(CompiledExpandUtils.NodeGetDegreeIfDense(read, node, nodes, cursors, INCOMING), equalTo(2)); assertThat(CompiledExpandUtils.NodeGetDegreeIfDense(read, node, nodes, cursors, BOTH), equalTo(4)); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldComputeDegreeWithType() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldComputeDegreeWithType() { // GIVEN long node; int @in, @out, loop; using (Transaction tx = Transaction()) { Write write = tx.DataWrite(); node = write.NodeCreate(); TokenWrite tokenWrite = tx.TokenWrite(); @out = tokenWrite.RelationshipTypeGetOrCreateForName("OUT"); @in = tokenWrite.RelationshipTypeGetOrCreateForName("IN"); loop = tokenWrite.RelationshipTypeGetOrCreateForName("LOOP"); write.RelationshipCreate(node, @out, write.NodeCreate()); write.RelationshipCreate(node, @out, write.NodeCreate()); write.RelationshipCreate(write.NodeCreate(), @in, node); write.RelationshipCreate(node, loop, node); tx.Success(); } using (Transaction tx = Transaction()) { Read read = tx.DataRead(); CursorFactory cursors = tx.Cursors(); using (NodeCursor nodes = cursors.AllocateNodeCursor()) { assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, OUTGOING, @out), equalTo(2)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, OUTGOING, @in), equalTo(0)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, OUTGOING, loop), equalTo(1)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, INCOMING, @out), equalTo(0)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, INCOMING, @in), equalTo(1)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, INCOMING, loop), equalTo(1)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, BOTH, @out), equalTo(2)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, BOTH, @in), equalTo(1)); assertThat(nodeGetDegreeIfDense(read, node, nodes, cursors, BOTH, loop), equalTo(1)); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Ignore public void shouldNotFindNodeWithJustOneUpdatedLabelInInConjunctionLabelScan() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotFindNodeWithJustOneUpdatedLabelInInConjunctionLabelScan() { // Given Node node = CreateNode(); using ([email protected] tx = beginTransaction(), NodeLabelIndexCursor cursor = tx.Cursors().allocateNodeLabelIndexCursor()) { // when int label1 = tx.TokenWrite().labelGetOrCreateForName("labe1"); int label2 = tx.TokenWrite().labelGetOrCreateForName("label2"); tx.DataWrite().nodeAddLabel(node.NodeConflict, label2); tx.DataRead().nodeLabelIntersectionScan(cursor, label1, label2); // then assertFalse(cursor.Next()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Ignore public void shouldFindUpdatedNodeInInConjunctionLabelScan() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFindUpdatedNodeInInConjunctionLabelScan() { // Given Node node = CreateNode("label1"); using ([email protected] tx = beginTransaction(), NodeLabelIndexCursor cursor = tx.Cursors().allocateNodeLabelIndexCursor()) { // when int label2 = tx.TokenWrite().labelGetOrCreateForName("label2"); tx.DataWrite().nodeAddLabel(node.NodeConflict, label2); tx.DataRead().nodeLabelIntersectionScan(cursor, node.LabelsConflict[0], label2); // then assertTrue(cursor.Next()); assertEquals(node.NodeConflict, cursor.NodeReference()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Ignore public void shouldNotFindNodeWithRemovedLabelInConjunctionLabelScan() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotFindNodeWithRemovedLabelInConjunctionLabelScan() { // Given Node node = CreateNode("label1", "label2"); using ([email protected] tx = beginTransaction(), NodeLabelIndexCursor cursor = tx.Cursors().allocateNodeLabelIndexCursor()) { // when tx.DataWrite().nodeRemoveLabel(node.NodeConflict, node.LabelsConflict[1]); tx.DataRead().nodeLabelIntersectionScan(cursor, node.LabelsConflict); // then assertFalse(cursor.Next()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFindSwappedNodeInLabelScan() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFindSwappedNodeInLabelScan() { // Given Node node1 = CreateNode("label"); Node node2 = CreateNode(); using ([email protected] tx = beginTransaction(), NodeLabelIndexCursor cursor = tx.Cursors().allocateNodeLabelIndexCursor()) { // when tx.DataWrite().nodeRemoveLabel(node1.NodeConflict, node1.LabelsConflict[0]); tx.DataWrite().nodeAddLabel(node2.NodeConflict, node1.LabelsConflict[0]); tx.DataRead().nodeLabelScan(node1.LabelsConflict[0], cursor); // then assertTrue(cursor.Next()); assertEquals(node2.NodeConflict, cursor.NodeReference()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotFindDeletedNodeInLabelScan() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotFindDeletedNodeInLabelScan() { // Given Node node = CreateNode("label"); using ([email protected] tx = beginTransaction(), NodeLabelIndexCursor cursor = tx.Cursors().allocateNodeLabelIndexCursor()) { // when tx.DataWrite().nodeDelete(node.NodeConflict); tx.DataRead().nodeLabelScan(node.LabelsConflict[0], cursor); // then assertFalse(cursor.Next()); } }
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: 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); }