@Override void set( RelationshipRecord rel, long id, boolean isFirst ) { rel.setFirstNextRel( id ); }
public static Consumer<RelationshipRecord> sNext( long id ) { return n -> n.setFirstNextRel( id ); }
private RelationshipRecord withNext( RelationshipRecord relationship, long next ) { relationship.setFirstNextRel( next ); relationship.setSecondNextRel( next ); return relationship; }
@Override protected void linkStart( RelationshipRecord record ) { long firstNextRel = cache.getAndPutRelationship( record.getFirstNode(), record.getType(), Direction.OUTGOING, record.getId(), true ); record.setFirstNextRel( firstNextRel ); }
@Override protected void linkLoop( RelationshipRecord record ) { long firstNextRel = cache.getAndPutRelationship( record.getFirstNode(), record.getType(), BOTH, record.getId(), true ); record.setFirstNextRel( firstNextRel ); record.setSecondNextRel( firstNextRel ); } }
private void setCorrectNextRel( NodeRecord node, RelationshipRecord rel, long nextRel ) { if ( node.getId() == rel.getFirstNode() ) { rel.setFirstNextRel( nextRel ); } if ( node.getId() == rel.getSecondNode() ) { rel.setSecondNextRel( nextRel ); } }
@Override RelationshipRecord populateRelationshipFromCache( long nodeId, RelationshipRecord rel, CacheAccess.Client cacheAccess ) { if ( cacheAccess.getFromCache( nodeId, SLOT_SOURCE_OR_TARGET ) == SOURCE ) { rel.setFirstNextRel( cacheAccess.getFromCache( nodeId, SLOT_REFERENCE ) ); } else { rel.setSecondNextRel( cacheAccess.getFromCache( nodeId, SLOT_REFERENCE ) ); } rel.setInUse( cacheAccess.getBooleanFromCache( nodeId, SLOT_IN_USE ) ); return rel; }
@Override RelationshipRecord populateRelationshipFromCache( long nodeId, RelationshipRecord rel, CacheAccess.Client cacheAccess ) { if ( cacheAccess.getFromCache( nodeId, SLOT_SOURCE_OR_TARGET ) == SOURCE ) { rel.setFirstNextRel( cacheAccess.getFromCache( nodeId, SLOT_REFERENCE ) ); } else { rel.setSecondNextRel( cacheAccess.getFromCache( nodeId, SLOT_REFERENCE ) ); } rel.setInUse( cacheAccess.getBooleanFromCache( nodeId, SLOT_IN_USE ) ); return rel; }
@Test void shouldReportSourceNextReferencingOtherNodes() { // given RelationshipRecord relationship = inUse( new RelationshipRecord( 42, 1, 2, 4 ) ); add( inUse( new RelationshipTypeTokenRecord( 4 ) ) ); add( inUse( new NodeRecord( 1, false, 42, NONE ) ) ); add( inUse( new NodeRecord( 2, false, 42, NONE ) ) ); RelationshipRecord sNext = add( inUse( new RelationshipRecord( 51, 8, 9, 0 ) ) ); relationship.setFirstNextRel( sNext.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).sourceNextReferencesOtherNodes( sNext ); verifyNoMoreInteractions( report ); }
@Test void shouldReportSourceNextNotReferencingBack() { // given RelationshipRecord relationship = inUse( new RelationshipRecord( 42, 1, 2, 4 ) ); add( inUse( new RelationshipTypeTokenRecord( 4 ) ) ); add( inUse( new NodeRecord( 1, false, 42, NONE ) ) ); add( inUse( new NodeRecord( 2, false, 42, NONE ) ) ); RelationshipRecord sNext = add( inUse( new RelationshipRecord( 51, 3, 1, 0 ) ) ); relationship.setFirstNextRel( sNext.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).sourceNextDoesNotReferenceBack( sNext ); verifyNoMoreInteractions( report ); }
@Test void shouldReportSourceNextReferencingOtherNodesWhenReferencingTargetNode() { // given RelationshipRecord relationship = inUse( new RelationshipRecord( 42, 1, 2, 4 ) ); add( inUse( new RelationshipTypeTokenRecord( 4 ) ) ); add( inUse( new NodeRecord( 1, false, 42, NONE ) ) ); add( inUse( new NodeRecord( 2, false, 42, NONE ) ) ); RelationshipRecord sNext = add( inUse( new RelationshipRecord( 51, 2, 0, 0 ) ) ); relationship.setFirstNextRel( sNext.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).sourceNextReferencesOtherNodes( sNext ); verifyNoMoreInteractions( report ); }
record.setInUse( true ); record.setFirstPrevRel( channel.getLong() ); record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() );
private Sabotage sabotage( RelationshipStore store, long id ) { RelationshipRecord before = store.getRecord( id, store.newRecord(), RecordLoad.NORMAL ); RelationshipRecord after = before.clone(); long otherReference; if ( !after.isFirstInFirstChain() ) { after.setFirstPrevRel( otherReference = after.getFirstPrevRel() + 1 ); } else { after.setFirstNextRel( otherReference = after.getFirstNextRel() + 1 ); } store.prepareForCommit( after ); store.updateRecord( after ); RelationshipRecord other = store.getRecord( otherReference, store.newRecord(), RecordLoad.FORCE ); return new Sabotage( before, after, other ); } }
@Test void shouldReportSourceNodeWithoutChainForRelationshipInTheMiddleOfChain() { // given checkSingleDirection(); initialize( RELATIONSHIPS, NODES ); RelationshipRecord relationship = inUse( new RelationshipRecord( 42, 1, 2, 4 ) ); add( inUse( new RelationshipTypeTokenRecord( 4 ) ) ); NodeRecord source = add( inUse( new NodeRecord( 1, false, NONE, NONE ) ) ); add( inUse( new NodeRecord( 2, false, 42, NONE ) ) ); RelationshipRecord sPrev = add( inUse( new RelationshipRecord( 51, 1, 0, 0 ) ) ); relationship.setFirstPrevRel( sPrev.getId() ); relationship.setFirstInFirstChain( false ); sPrev.setFirstNextRel( relationship.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).sourceNodeHasNoRelationships( source ); verifyNoMoreInteractions( report ); }
record.setInUse( true ); record.setFirstPrevRel( channel.getLong() ); record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() );
record.setRequiresSecondaryUnit( requiresSecondaryUnit ); record.setFirstPrevRel( channel.getLong() ); record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() );
record.setRequiresSecondaryUnit( requiresSecondaryUnit ); record.setFirstPrevRel( channel.getLong() ); record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() );
rel.setFirstNextRel( firstNode.getNextRel() );
RelationshipRecord tPrev = add( inUse( new RelationshipRecord( 53, 3, 2, 4 ) ) ); relationship.setFirstNextRel( sNext.getId() ); sNext.setFirstPrevRel( relationship.getId() ); sNext.setFirstInFirstChain( false );
protected RelationshipRecord withNext( RelationshipRecord relationship, long next ) { relationship.setFirstNextRel( next ); relationship.setSecondNextRel( next ); return relationship; }