@Override public RelationshipRecord newRecord() { return new RelationshipRecord( -1 ); }
@Override public RelationshipRecord newUnused( long key, Void additionalData ) { return andMarkAsCreated( new RelationshipRecord( key ) ); }
@Override protected void transactionData( TransactionDataBuilder tx, IdGenerator next ) { RelationshipRecord relationship = new RelationshipRecord( id.get() ); tx.delete( relationship ); } } );
@Override protected RelationshipRecord createNullRecord( long id ) { RelationshipRecord record = new RelationshipRecord( id, false, 0, 0, 0, 0, 0, 0, 0, false, false ); record.setNextProp( 0 ); return record; }
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { tx.create( new RelationshipRecord( next.relationship(), 1, 2, C ) ); } } );
public static RelationshipCommand createRelationship( long id, long startNode, long endNode, int type ) { RelationshipRecord before = new RelationshipRecord( id ); before.setInUse( false ); RelationshipRecord after = new RelationshipRecord( id, startNode, endNode, type ); after.setInUse( true ); after.setCreated(); return new RelationshipCommand( before, after ); }
@Override public RelationshipRecord clone() { RelationshipRecord record = new RelationshipRecord( getId() ).initialize( inUse(), nextProp, firstNode, secondNode, type, firstPrevRel, firstNextRel, secondPrevRel, secondNextRel, firstInFirstChain, firstInSecondChain ); record.setSecondaryUnitId( getSecondaryUnitId() ); return record; }
@Test void shouldNotReportAnythingForRelationshipNotInUse() { // given RelationshipRecord relationship = notInUse( new RelationshipRecord( 42, 0, 0, 0 ) ); // when RelationshipConsistencyReport report = check( relationship ); // then verifyNoMoreInteractions( report ); }
private static RelationshipRecord relationship( long id, long startNodeId, long endNodeId ) { RelationshipRecord record = new RelationshipRecord( id ); record.setInUse( true ); record.setFirstNode( startNodeId ); record.setSecondNode( endNodeId ); return record; } }
@Override protected void transactionData( TransactionDataBuilder tx, IdGenerator next ) { id.set( next.relationship() ); RelationshipRecord relationship = new RelationshipRecord( id.get() ); relationship.setFirstNode( -1 ); relationship.setSecondNode( -1 ); relationship.setInUse( true ); tx.create( relationship ); } } );
public void create( RelationshipRecord record ) { record.setCreated(); update( new RelationshipRecord( record.getId() ), record ); }
private RelationshipRecord record( long startNode, int type, long endNode ) { RelationshipRecord record = new RelationshipRecord( 0 ); record.setInUse( true ); record.setFirstNode( startNode ); record.setSecondNode( endNode ); record.setType( type ); return record; } }
private void unUseRecord( long recordId ) { RelationshipStore relationshipStore = neoStores.getRelationshipStore(); RelationshipRecord relationshipRecord = relationshipStore.getRecord( recordId, new RelationshipRecord( -1 ), RecordLoad.FORCE ); relationshipRecord.setInUse( false ); relationshipStore.updateRecord( relationshipRecord ); }
@Test void shouldReportRelationshipForOtherNodes() { // given NodeRecord node = inUse( new NodeRecord( 42, false, 7, NONE ) ); RelationshipRecord relationship = add( inUse( new RelationshipRecord( 7, 1, 2, 0 ) ) ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verify( report ).relationshipForOtherNode( relationship ); verifyNoMoreInteractions( report ); }
private RelationshipRecord createRelationship( long id, long nextRelationship ) { return new RelationshipRecord( id, true, getFirstNode(), getSecondNode(), TYPE, NO_NEXT_RELATIONSHIP.intValue(), nextRelationship, NO_NEXT_RELATIONSHIP.intValue(), nextRelationship, false, false ); }
private static RelationshipRecord relationship( long id, long startNodeId, long endNodeId ) { return new RelationshipRecord( id ).initialize( true, Record.NO_NEXT_PROPERTY.longValue(), startNodeId, endNodeId, 0, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), false, false ); } }
private RelationshipRecord getRelationship( long relId, boolean inUse, int type ) { return new RelationshipRecord( relId ).initialize( inUse, NO_NEXT_PROPERTY.longValue(), 0, 0, type, NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), NO_NEXT_RELATIONSHIP.longValue(), true, false ); } }
@Test void shouldNotReportAnythingForNodeWithConsistentReferences() { // given NodeRecord node = inUse( new NodeRecord( 42, false, 7, 11 ) ); add( inUse( new RelationshipRecord( 7, 42, 0, 0 ) ) ); add( inUse( new PropertyRecord( 11 ) ) ); // when ConsistencyReport.NodeConsistencyReport report = check( node ); // then verifyNoMoreInteractions( report ); }
private static void breakTheChain( RecordStore<RelationshipRecord> relationshipStore ) { RelationshipRecord record = relationshipStore.getRecord( 10, relationshipStore.newRecord(), NORMAL ); long relationshipTowardsEndOfChain = record.getFirstNode(); while ( record.inUse() && !record.isFirstInFirstChain() ) { record = relationshipStore.getRecord( relationshipTowardsEndOfChain, relationshipStore.newRecord(), FORCE ); relationshipTowardsEndOfChain = record.getFirstPrevRel(); } relationshipStore.updateRecord( new RelationshipRecord( relationshipTowardsEndOfChain, 0, 0, 0 ) ); }
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { long node1 = next.node(); long node2 = next.node(); long rel = next.relationship(); tx.create( inUse( new RelationshipRecord( rel, node1, node2, 0 ) ) ); tx.create( inUse( new NodeRecord( node1, false, rel + 1, -1 ) ) ); tx.create( inUse( new NodeRecord( node2, false, rel + 2, -1 ) ) ); } } );