@Override void set( RelationshipRecord rel, long id, boolean isFirst ) { rel.setSecondNextRel( id ); }
public static Consumer<RelationshipRecord> tNext( long id ) { return n -> n.setSecondNextRel( id ); }
private RelationshipRecord withNext( RelationshipRecord relationship, long next ) { relationship.setFirstNextRel( next ); relationship.setSecondNextRel( next ); return relationship; }
@Override protected void linkEnd( RelationshipRecord record ) { long secondNextRel = cache.getAndPutRelationship( record.getSecondNode(), record.getType(), Direction.INCOMING, record.getId(), true ); record.setSecondNextRel( secondNextRel ); }
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 protected void linkLoop( RelationshipRecord record ) { long firstNextRel = cache.getAndPutRelationship( record.getFirstNode(), record.getType(), BOTH, record.getId(), true ); record.setFirstNextRel( firstNextRel ); record.setSecondNextRel( firstNextRel ); } }
@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 shouldReportTargetNextReferencingOtherNodes() { // 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 tNext = add( inUse( new RelationshipRecord( 51, 8, 9, 0 ) ) ); relationship.setSecondNextRel( tNext.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).targetNextReferencesOtherNodes( tNext ); verifyNoMoreInteractions( report ); }
@Test void shouldReportTargetNextReferencingOtherNodesWhenReferencingSourceNode() { // 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 tNext = add( inUse( new RelationshipRecord( 51, 1, 0, 0 ) ) ); relationship.setSecondNextRel( tNext.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).targetNextReferencesOtherNodes( tNext ); verifyNoMoreInteractions( report ); }
@Test void shouldReportTargetNextNotReferencingBack() { // 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 tNext = add( inUse( new RelationshipRecord( 51, 3, 2, 0 ) ) ); relationship.setSecondNextRel( tNext.getId() ); // when RelationshipConsistencyReport report = check( relationship ); // then verify( report ).targetNextDoesNotReferenceBack( tNext ); 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 ); }
record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() ); record.setNextProp( channel.getLong() ); byte extraByte = channel.get();
record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() ); record.setNextProp( channel.getLong() ); byte extraByte = channel.get();
rel.setSecondNextRel( secondNode.getNextRel() );
record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() ); record.setNextProp( channel.getLong() ); byte extraByte = channel.get();
record.setFirstNextRel( channel.getLong() ); record.setSecondPrevRel( channel.getLong() ); record.setSecondNextRel( channel.getLong() ); record.setNextProp( channel.getLong() ); byte extraByte = channel.get();
sNext.setFirstPrevRel( relationship.getId() ); sNext.setFirstInFirstChain( false ); relationship.setSecondNextRel( tNext.getId() ); tNext.setFirstPrevRel( relationship.getId() ); tNext.setFirstInFirstChain( false ); relationship.setSecondPrevRel( tPrev.getId() ); relationship.setFirstInSecondChain( false ); tPrev.setSecondNextRel( relationship.getId() );
@Override void set( RelationshipRecord rel, long id, boolean isFirst ) { rel.setSecondNextRel( id ); }
@Override protected void linkEnd( RelationshipRecord record ) { long secondNextRel = cache.getAndPutRelationship( record.getSecondNode(), record.getType(), Direction.INCOMING, record.getId(), true ); record.setSecondNextRel( secondNextRel ); }