Skip to content

Commit

Permalink
Acquire SingleRelationshiCursor in the StorageLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed May 8, 2017
1 parent 86c01b1 commit 2caa415
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Expand Up @@ -178,7 +178,7 @@ public Cursor<RelationshipItem> relationshipCursorById( KernelStatement statemen
private Cursor<RelationshipItem> relationshipCursor( KernelStatement statement, long relationshipId )
{
ReadableTransactionState state = statement.hasTxStateWithChanges() ? statement.txState() : null;
return statement.getStoreStatement().acquireSingleRelationshipCursor( relationshipId, state );
return storeLayer.relationshipCursor( statement.getStoreStatement(), relationshipId, state );
}

@Override
Expand Down
Expand Up @@ -409,6 +409,13 @@ public Cursor<NodeItem> nodeCursor( StorageStatement statement, long nodeId, Rea
return statement.acquireSingleNodeCursor( nodeId, state );
}

@Override
public Cursor<RelationshipItem> relationshipCursor( StorageStatement statement, long relationshipId,
ReadableTransactionState state )
{
return statement.acquireSingleRelationshipCursor( relationshipId, state );
}

@Override
public Cursor<RelationshipItem> nodeGetRelationships( StorageStatement statement, NodeItem nodeItem,
Direction direction, ReadableTransactionState state )
Expand Down
Expand Up @@ -272,6 +272,9 @@ <EXCEPTION extends Exception> void relationshipVisit( long relationshipId,

Cursor<NodeItem> nodeCursor( StorageStatement storeStatement, long nodeId, ReadableTransactionState state );

Cursor<RelationshipItem> relationshipCursor( StorageStatement storeStatement, long relationshipId,
ReadableTransactionState state );

Cursor<RelationshipItem> nodeGetRelationships( StorageStatement statement, NodeItem nodeItem, Direction direction,
ReadableTransactionState state );

Expand Down
Expand Up @@ -90,7 +90,7 @@ public void shouldSignalNodeRemovedToAutoIndex() throws Exception
public void shouldSignalRelationshipRemovedToAutoIndex() throws Exception
{
// Given
when( storeStmt.acquireSingleRelationshipCursor( 1337, null ) )
when( storeLayer.relationshipCursor( any( StorageStatement.class ), eq( 1337L ), eq( null ) ) )
.thenReturn( cursor( mock( RelationshipItem.class ) ) );

// When
Expand Down Expand Up @@ -129,7 +129,8 @@ public void shouldSignalRelationshipPropertyAddedToAutoIndex() throws Exception
DefinedProperty property = property( propertyKeyId, "Hello!" );

RelationshipItem relationship = mock( RelationshipItem.class );
when( storeStmt.acquireSingleRelationshipCursor( 1337, null ) ).thenReturn( cursor( relationship ) );
when( storeLayer.relationshipCursor( any( StorageStatement.class ), eq( 1337L ), eq( null ) ) )
.thenReturn( cursor( relationship ) );
when( storeLayer.relationshipGetProperty( storeStmt, relationship, propertyKeyId, null ) )
.thenReturn( empty() );

Expand Down Expand Up @@ -177,15 +178,16 @@ public void shouldSignalRelationshipPropertyChangedToAutoIndex() throws Exceptio
when(existingProperty.value()).thenReturn( "Goodbye!" );

RelationshipItem relationship = mock( RelationshipItem.class );
when( storeStmt.acquireSingleRelationshipCursor( 1337, null ) ).thenReturn( cursor( relationship ) );
when( storeLayer.relationshipCursor( any( StorageStatement.class ), eq( 1337L ), eq( null ) ) )
.thenReturn( cursor( relationship ) );
when( storeLayer.relationshipGetProperty( storeStmt, relationship, propertyKeyId, null ) )
.thenReturn( cursor( existingProperty ) );

// When
context.relationshipSetProperty( stmt, 1337, property );

// Then
verify( relOps ).propertyChanged( eq(writeOps), eq(1337L), any(Property.class), eq(property) );
verify( relOps ).propertyChanged( eq( writeOps ), eq( 1337L ), any( Property.class ), eq( property ) );
}

@Test
Expand Down Expand Up @@ -222,7 +224,8 @@ public void shouldSignalRelationshipPropertyRemovedToAutoIndex() throws Exceptio
when(existingProperty.value()).thenReturn( "Goodbye!" );

RelationshipItem relationship = mock( RelationshipItem.class );
when( storeStmt.acquireSingleRelationshipCursor( 1337, null ) ).thenReturn( cursor( relationship ) );
when( storeLayer.relationshipCursor( any( StorageStatement.class ), eq( 1337L ), eq( null ) ) )
.thenReturn( cursor( relationship ) );
when( storeLayer.relationshipGetProperty( storeStmt, relationship, propertyKeyId, null ) )
.thenReturn( cursor( existingProperty ) );

Expand Down

0 comments on commit 2caa415

Please sign in to comment.