@Deprecated public RelationshipRecord( long id, boolean inUse, long firstNode, long secondNode, int type, long firstPrevRel, long firstNextRel, long secondPrevRel, long secondNextRel, boolean firstInFirstChain, boolean firstInSecondChain ) { this( id, firstNode, secondNode, type ); setInUse( inUse ); this.firstPrevRel = firstPrevRel; this.firstNextRel = firstNextRel; this.secondPrevRel = secondPrevRel; this.secondNextRel = secondNextRel; this.firstInFirstChain = firstInFirstChain; this.firstInSecondChain = firstInSecondChain; }
private long nodeId( Object id, Group group ) { long nodeId = idMapper.get( id, group ); if ( nodeId == ID_NOT_FOUND ) { relationshipRecord.setInUse( false ); return ID_NOT_FOUND; } return nodeId; }
public void update( RelationshipRecord before, RelationshipRecord after ) { after.setInUse( true ); add( before, after ); }
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 RelationshipRecord populateRelationshipFromCache( long nodeId, RelationshipRecord rel, CacheAccess.Client cacheAccess ) { if ( cacheAccess.getFromCache( nodeId, SLOT_SOURCE_OR_TARGET ) == SOURCE ) { rel.setFirstPrevRel( cacheAccess.getFromCache( nodeId, SLOT_REFERENCE ) ); } else { rel.setSecondPrevRel( 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; }
public void delete( RelationshipRecord record ) { record.setInUse( false ); add( record, new RelationshipRecord( record.getId() ) ); }
@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 ); } } );
@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.setFirstPrevRel( cacheAccess.getFromCache( nodeId, SLOT_REFERENCE ) ); } else { rel.setSecondPrevRel( cacheAccess.getFromCache( nodeId, SLOT_REFERENCE ) ); } rel.setInUse( cacheAccess.getBooleanFromCache( nodeId, SLOT_IN_USE ) ); return rel; }
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; } }
/** * Deletes a relationship by its id, returning its properties which are now * removed. It is assumed that the nodes it connects have already been * deleted in this * transaction. * * @param id The id of the relationship to delete. */ void relDelete( long id, RecordAccessSet recordChanges, ResourceLocker locks ) { RelationshipRecord record = recordChanges.getRelRecords().getOrLoad( id, null ).forChangingLinkage(); propertyChainDeleter.deletePropertyChain( record, recordChanges.getPropertyRecords() ); disconnectRelationship( record, recordChanges, locks ); updateNodesForDeletedRelationship( record, recordChanges, locks ); record.setInUse( false ); }
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 ); }
protected RelationshipImporter( BatchingNeoStores stores, IdMapper idMapper, DataStatistics typeDistribution, Monitor monitor, Collector badCollector, boolean validateRelationshipData, boolean doubleRecordUnits ) { super( stores, monitor ); this.doubleRecordUnits = doubleRecordUnits; this.relationshipTypeTokenRepository = stores.getRelationshipTypeRepository(); this.idMapper = idMapper; this.badCollector = badCollector; this.validateRelationshipData = validateRelationshipData; this.relationshipStore = stores.getRelationshipStore(); this.relationshipRecord = relationshipStore.newRecord(); this.relationshipIds = new BatchingIdGetter( relationshipStore ); this.typeCounts = typeDistribution.newClient(); this.prepareIdSequence = PrepareIdSequence.of( doubleRecordUnits ).apply( stores.getRelationshipStore() ); relationshipRecord.setInUse( true ); }
@Test public void shouldApplyRelationshipCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final RelationshipRecord before = new RelationshipRecord( 12 ); final RelationshipRecord record = new RelationshipRecord( 12, 3, 4, 5 ); record.setInUse( true ); final Command command = new Command.RelationshipCommand( before, record ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipStore, times( 1 ) ).setHighestPossibleIdInUse( record.getId() ); verify( relationshipStore, times( 1 ) ).updateRecord( record ); }
@Test public void shouldApplyRelationshipCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final RelationshipRecord before = new RelationshipRecord( 12 ); final RelationshipRecord record = new RelationshipRecord( 12, 3, 4, 5 ); record.setInUse( true ); final Command command = new Command.RelationshipCommand( before, record ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipStore, times( 1 ) ).updateRecord( record ); }
@Test public void shouldApplyRelationshipCommandToTheStoreAndInvalidateTheCache() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final RelationshipRecord before = new RelationshipRecord( 12 ); final RelationshipRecord record = new RelationshipRecord( 12, 3, 4, 5 ); record.setInUse( false ); final Command command = new Command.RelationshipCommand( before, record ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipStore, times( 1 ) ).updateRecord( record ); }
private void markRandomRelsInChainNotInUse( long relId ) { if ( relId != NO_NEXT_RELATIONSHIP.intValue() ) { RelationshipRecord record = getRelRecord( relId ); boolean shouldBeMarked = random.nextBoolean(); if ( shouldBeMarked ) { record.setInUse( false ); update( record ); } markRandomRelsInChainNotInUse( record.getFirstNextRel() ); boolean isLoopRelationship = record.getFirstNextRel() == record.getSecondNextRel(); if ( !isLoopRelationship ) { markRandomRelsInChainNotInUse( record.getSecondNextRel() ); } } }
/** * Creates a relationship with the given id, from the nodes identified by id * and of type typeId * * @param id The id of the relationship to create. * @param type The id of the relationship type this relationship will * have. * @param firstNodeId The id of the start node. * @param secondNodeId The id of the end node. */ public void relationshipCreate( long id, int type, long firstNodeId, long secondNodeId, RecordAccessSet recordChangeSet, ResourceLocker locks ) { // TODO could be unnecessary to mark as changed here already, dense nodes may not need to change NodeRecord firstNode = recordChangeSet.getNodeRecords().getOrLoad( firstNodeId, null ).forChangingLinkage(); NodeRecord secondNode = recordChangeSet.getNodeRecords().getOrLoad( secondNodeId, null ).forChangingLinkage(); convertNodeToDenseIfNecessary( firstNode, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks ); convertNodeToDenseIfNecessary( secondNode, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks ); RelationshipRecord record = recordChangeSet.getRelRecords().create( id, null ).forChangingLinkage(); record.setLinks( firstNodeId, secondNodeId, type ); record.setInUse( true ); record.setCreated(); connectRelationship( firstNode, secondNode, record, recordChangeSet.getRelRecords(), recordChangeSet.getRelGroupRecords(), locks ); }