Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tx-state awareness to RelationshipScanCursor
This implementation duplicates code from NodeCursor, but this logic was hard to share in a non-complicated way because of the requirement to inherit their respective *Record class.
- Loading branch information
Showing
11 changed files
with
259 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...api/src/test/java/org/neo4j/internal/kernel/api/RelationshipTransactionStateTestBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
/* | |||
* Copyright (c) 2002-2018 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.internal.kernel.api; | |||
|
|||
import org.junit.Test; | |||
|
|||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
|
|||
@SuppressWarnings( "Duplicates" ) | |||
public abstract class RelationshipTransactionStateTestBase<G extends KernelAPIWriteTestSupport> extends KernelAPIWriteTestBase<G> | |||
{ | |||
@Test | |||
public void shouldSeeSingleRelationshipInTransaction() throws Exception | |||
{ | |||
int label; | |||
long n1, n2; | |||
try ( Transaction tx = session.beginTransaction() ) | |||
{ | |||
n1 = tx.dataWrite().nodeCreate(); | |||
n2 = tx.dataWrite().nodeCreate(); | |||
long decoyNode = tx.dataWrite().nodeCreate(); | |||
label = tx.tokenWrite().relationshipTypeGetOrCreateForName( "R" ); // to have >1 relationship in the db | |||
tx.dataWrite().relationshipCreate( n2, label, decoyNode ); | |||
tx.success(); | |||
} | |||
|
|||
try ( Transaction tx = session.beginTransaction() ) | |||
{ | |||
label = tx.tokenWrite().relationshipTypeGetOrCreateForName( "R" ); | |||
long r = tx.dataWrite().relationshipCreate( n1, label, n2 ); | |||
try ( RelationshipScanCursor relationship = cursors.allocateRelationshipScanCursor() ) | |||
{ | |||
tx.dataRead().singleRelationship( r, relationship ); | |||
assertTrue( "should find relationship", relationship.next() ); | |||
|
|||
assertEquals( label, relationship.label() ); | |||
assertEquals( n1, relationship.sourceNodeReference() ); | |||
assertEquals( n2, relationship.targetNodeReference() ); | |||
assertEquals( r, relationship.relationshipReference() ); | |||
|
|||
assertFalse( "should only find one relationship", relationship.next() ); | |||
} | |||
tx.success(); | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
community/kernel/src/main/java/org/neo4j/kernel/impl/newapi/HasChanges.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
/* | |||
* Copyright (c) 2002-2018 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.kernel.impl.newapi; | |||
|
|||
enum HasChanges | |||
{ | |||
MAYBE, | |||
YES, | |||
NO | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.