@Override void set( RelationshipRecord rel, long id, boolean isFirst ) { rel.setSecondPrevRel( id ); rel.setFirstInSecondChain( isFirst ); }
public static Consumer<RelationshipRecord> tPrev( long id ) { return n -> { n.setFirstInSecondChain( false ); n.setSecondPrevRel( id ); }; }
public static Consumer<RelationshipRecord> tCount( long count ) { return n -> { n.setFirstInSecondChain( true ); n.setSecondPrevRel( count ); }; }
protected static RelationshipRecord firstInChains( RelationshipRecord relationship, int count ) { relationship.setFirstInFirstChain( true ); relationship.setFirstPrevRel( count ); relationship.setFirstInSecondChain( true ); relationship.setSecondPrevRel( count ); return relationship; }
private RelationshipRecord withPrev( RelationshipRecord relationship, long prev ) { relationship.setFirstInFirstChain( false ); relationship.setFirstInSecondChain( false ); relationship.setFirstPrevRel( prev ); relationship.setSecondPrevRel( prev ); return relationship; }
@Override protected void linkEnd( RelationshipRecord record ) { int typeId = record.getType(); long secondPrevRel = cache.getAndPutRelationship( record.getSecondNode(), typeId, Direction.INCOMING, record.getId(), false ); if ( secondPrevRel == ID_NOT_FOUND ) { // First one record.setFirstInSecondChain( true ); secondPrevRel = cache.getCount( record.getSecondNode(), typeId, Direction.INCOMING ); } record.setSecondPrevRel( secondPrevRel ); }
@Override protected void linkLoop( RelationshipRecord record ) { int typeId = record.getType(); long prevRel = cache.getAndPutRelationship( record.getFirstNode(), typeId, Direction.BOTH, record.getId(), false ); if ( prevRel == ID_NOT_FOUND ) { // First one record.setFirstInFirstChain( true ); record.setFirstInSecondChain( true ); prevRel = cache.getCount( record.getFirstNode(), typeId, Direction.BOTH ); } record.setFirstPrevRel( prevRel ); record.setSecondPrevRel( prevRel ); } }
@Test void shouldReportLoopRelationshipNotFirstInTargetAndSourceChains() { // given NodeRecord node = inUse( new NodeRecord( 42, false, 7, NONE ) ); RelationshipRecord relationship = add( inUse( new RelationshipRecord( 7, 42, 42, 0 ) ) ); relationship.setFirstPrevRel( 8 ); relationship.setFirstInFirstChain( false ); relationship.setSecondPrevRel( 8 ); relationship.setFirstInSecondChain( false ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verify( report ).relationshipNotFirstInSourceChain( relationship ); verify( report ).relationshipNotFirstInTargetChain( relationship ); verifyNoMoreInteractions( report ); }
@Test void shouldReportRelationshipNotFirstInSourceChain() { // given NodeRecord node = inUse( new NodeRecord( 42, false, 7, NONE ) ); RelationshipRecord relationship = add( inUse( new RelationshipRecord( 7, 42, 0, 0 ) ) ); relationship.setFirstPrevRel( 6 ); relationship.setFirstInFirstChain( false ); relationship.setSecondPrevRel( 8 ); relationship.setFirstInSecondChain( false ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verify( report ).relationshipNotFirstInSourceChain( relationship ); verifyNoMoreInteractions( report ); }
@Test void shouldReportRelationshipNotFirstInTargetChain() { // given NodeRecord node = inUse( new NodeRecord( 42, false, 7, NONE ) ); RelationshipRecord relationship = add( inUse( new RelationshipRecord( 7, 0, 42, 0 ) ) ); relationship.setFirstPrevRel( 6 ); relationship.setFirstInFirstChain( false ); relationship.setSecondPrevRel( 8 ); relationship.setFirstInSecondChain( false ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verify( report ).relationshipNotFirstInTargetChain( relationship ); verifyNoMoreInteractions( report ); }
firstRel.setFirstInSecondChain( false ); changed = true; rel.setFirstInSecondChain( true );
private void decrementTotalRelationshipCount( long nodeId, RelationshipRecord rel, long firstRelId, RecordAccess<RelationshipRecord, Void> relRecords, ResourceLocker locks ) { if ( firstRelId == Record.NO_PREV_RELATIONSHIP.intValue() ) { return; } boolean firstInChain = relIsFirstInChain( nodeId, rel ); if ( !firstInChain ) { locks.acquireExclusive( LockTracer.NONE, ResourceTypes.RELATIONSHIP, firstRelId ); } RelationshipRecord firstRel = relRecords.getOrLoad( firstRelId, null ).forChangingLinkage(); if ( nodeId == firstRel.getFirstNode() ) { firstRel.setFirstPrevRel( firstInChain ? relCount( nodeId, rel ) - 1 : relCount( nodeId, firstRel ) - 1 ); firstRel.setFirstInFirstChain( true ); } if ( nodeId == firstRel.getSecondNode() ) { firstRel.setSecondPrevRel( firstInChain ? relCount( nodeId, rel ) - 1 : relCount( nodeId, firstRel ) - 1 ); firstRel.setFirstInSecondChain( true ); } }
@Test void shouldReportTargetPrevReferencingOtherNodesWhenReferencingSourceNode() { // 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, 0, NONE ) ) ); RelationshipRecord tPrev = add( inUse( new RelationshipRecord( 51, 1, 0, 0 ) ) ); relationship.setSecondPrevRel( tPrev.getId() ); relationship.setFirstInSecondChain( false ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).targetPrevReferencesOtherNodes( tPrev ); verifyNoMoreInteractions( report ); }
@Test void shouldReportTargetPrevReferencingOtherNodes() { // 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, 0, NONE ) ) ); RelationshipRecord tPrev = add( inUse( new RelationshipRecord( 51, 8, 9, 0 ) ) ); relationship.setSecondPrevRel( tPrev.getId() ); relationship.setFirstInSecondChain( false ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).targetPrevReferencesOtherNodes( tPrev ); verifyNoMoreInteractions( report ); }
@Test void shouldReportTargetPrevNotReferencingBack() { // 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, 0, NONE ) ) ); RelationshipRecord tPrev = add( inUse( new RelationshipRecord( 51, 2, 3, 0 ) ) ); relationship.setSecondPrevRel( tPrev.getId() ); relationship.setFirstInSecondChain( false ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).targetPrevDoesNotReferenceBack( tPrev ); verifyNoMoreInteractions( report ); }
@Test void shouldReportTargetNodeWithoutChainForRelationshipInTheMiddleOfChain() { // given checkSingleDirection(); initialize( RELATIONSHIPS, NODES ); RelationshipRecord relationship = inUse( new RelationshipRecord( 42, 1, 2, 4 ) ); add( inUse( new RelationshipTypeTokenRecord( 4 ) ) ); add( inUse( new NodeRecord( 1, false, 42, NONE ) ) ); NodeRecord target = add( inUse( new NodeRecord( 2, false, NONE, NONE ) ) ); RelationshipRecord tPrev = add( inUse( new RelationshipRecord( 51, 0, 2, 0 ) ) ); relationship.setSecondPrevRel( tPrev.getId() ); relationship.setFirstInSecondChain( false ); tPrev.setSecondNextRel( relationship.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).targetNodeHasNoRelationships( target ); verifyNoMoreInteractions( report ); }
byte extraByte = channel.get(); record.setFirstInFirstChain( (extraByte & 0x1) > 0 ); record.setFirstInSecondChain( (extraByte & 0x2) > 0 );
byte extraByte = channel.get(); record.setFirstInFirstChain( (extraByte & 0x1) > 0 ); record.setFirstInSecondChain( (extraByte & 0x2) > 0 ); if ( hasSecondaryUnit )
byte extraByte = channel.get(); record.setFirstInFirstChain( (extraByte & 0x1) > 0 ); record.setFirstInSecondChain( (extraByte & 0x2) > 0 ); if ( hasSecondaryUnit )
tNext.setFirstInFirstChain( false ); relationship.setSecondPrevRel( tPrev.getId() ); relationship.setFirstInSecondChain( false ); tPrev.setSecondNextRel( relationship.getId() );