private void createRelationshipRecord( long id, int type, RelationshipStore relationshipStore, boolean used ) { relationshipStore.updateRecord( new RelationshipRecord( id ).initialize( used, -1, 1, 2, type, -1, -1, -1, -1, true, true ) ); }
private void update( RelationshipRecord record ) { resolveNeoStores().getRelationshipStore().updateRecord( 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 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 ); }
private void createNodeRelationships() { RelationshipStore relationshipStore = neoStores.getRelationshipStore(); if ( dense ) { RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore(); relationshipGroupStore.updateRecord( createRelationshipGroup( 1, 1 ) ); relationshipGroupStore.updateRecord( createRelationshipGroup( 2, 2 ) ); relationshipGroupStore.updateRecord( createRelationshipGroup( 3, 3 ) ); } relationshipStore.updateRecord( createRelationship( 1, NO_NEXT_RELATIONSHIP.intValue() ) ); relationshipStore.updateRecord( createRelationship( 2, NO_NEXT_RELATIONSHIP.intValue() ) ); relationshipStore.updateRecord( createRelationship( 3, NO_NEXT_RELATIONSHIP.intValue() ) ); }
@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 createRelationshipChain( int recordsInChain ) { RelationshipStore relationshipStore = neoStores.getRelationshipStore(); for ( int i = 1; i < recordsInChain; i++ ) { relationshipStore.updateRecord( createRelationship( i, i + 1 ) ); } relationshipStore.updateRecord( createRelationship( recordsInChain, NO_NEXT_RELATIONSHIP.intValue() ) ); if ( dense ) { RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore(); for ( int i = 1; i < recordsInChain; i++ ) { relationshipGroupStore.updateRecord( createRelationshipGroup( i, i ) ); } relationshipGroupStore .updateRecord( createRelationshipGroup( recordsInChain, NO_NEXT_RELATIONSHIP.intValue() ) ); } }
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 public void shouldContainFedRelationshipUpdate() throws Exception { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( nodeStore, relationshipStore, indexingService, propertyPhysicalToLogicalConverter ); long relId = 0; RelationshipRecord inUse = getRelationship( relId, true, ENTITY_TOKEN ); Value propertyValue = Values.of( "hej" ); long propertyId = createRelationshipProperty( inUse, propertyValue, 1 ); RelationshipRecord notInUse = getRelationship( relId, false, ENTITY_TOKEN ); relationshipStore.updateRecord( inUse ); Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand( inUse, notInUse ); PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setRelId( relId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); StoreIndexDescriptor indexDescriptor = forSchema( multiToken( ENTITY_TOKENS, RELATIONSHIP, 1, 4, 6 ), EMPTY.getProviderDescriptor() ).withId( 0 ); indexingService.createIndexes( indexDescriptor ); indexingService.getIndexProxy( indexDescriptor.schema() ).awaitStoreScanCompleted(); onlineIndexUpdates.feed( LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, singletonList( propertyCommand ) ), LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, relationshipCommand ) ); assertTrue( onlineIndexUpdates.hasUpdates() ); Iterator<IndexEntryUpdate<SchemaDescriptor>> iterator = onlineIndexUpdates.iterator(); assertEquals( iterator.next(), IndexEntryUpdate.remove( relId, indexDescriptor, propertyValue, null, null ) ); assertFalse( iterator.hasNext() ); }
relationshipRecord.setSecondPrevRel( Record.NO_NEXT_RELATIONSHIP.intValue() ); relationshipStore.prepareForCommit( relationshipRecord, prepareIdSequence.apply( relationshipRecord.getId() ) ); relationshipStore.updateRecord( relationshipRecord ); relationshipCount++; typeCounts.increment( relationshipRecord.getType() );
long propId = record.getNextProp(); record.setNextProp( AbstractBaseRecord.NO_ID ); stores.getRelationshipStore().updateRecord( record ); PropertyRecord propRecord = stores.getPropertyStore().getRecord( propId, stores.getPropertyStore().newRecord(), RecordLoad.NORMAL ); propRecord.setInUse( false );
long propertyId = createRelationshipProperty( inUse, relationshipPropertyValue, 1 ); RelationshipRecord notInUse = getRelationship( relId, false, ENTITY_TOKEN ); relationshipStore.updateRecord( inUse );
@Test public void shouldDeleteIdGeneratorsWhenOpeningExistingStore() throws IOException { // given long expectedHighId; try ( BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache( storage.fileSystem(), storage.pageCache(), PageCacheTracer.NULL, storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults() ) ) { stores.createNew(); RelationshipStore relationshipStore = stores.getRelationshipStore(); RelationshipRecord record = relationshipStore.newRecord(); long no = NULL_REFERENCE.longValue(); record.initialize( true, no, 1, 2, 0, no, no, no, no, true, true ); record.setId( relationshipStore.nextId() ); expectedHighId = relationshipStore.getHighId(); relationshipStore.updateRecord( record ); // fiddle with the highId relationshipStore.setHighId( record.getId() + 999 ); } // when try ( BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache( storage.fileSystem(), storage.pageCache(), PageCacheTracer.NULL, storage.directory().absolutePath(), LATEST_RECORD_FORMATS, DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults() ) ) { stores.pruneAndOpenExistingStore( Predicates.alwaysTrue(), Predicates.alwaysTrue() ); // then assertEquals( expectedHighId, stores.getRelationshipStore().getHighId() ); } }
RelationshipRecord record = relationshipStore.getRecord( 4, relationshipRecord, RecordLoad.FORCE ); record.setInUse( false ); relationshipStore.updateRecord( relationshipRecord );
long propertyId2 = createRelationshipProperty( inUse, propertyValue2, 4 ); RelationshipRecord notInUse = getRelationship( relId, false, ENTITY_TOKEN ); relationshipStore.updateRecord( inUse );
relationshipRecord.setSecondPrevRel( Record.NO_NEXT_RELATIONSHIP.intValue() ); relationshipStore.prepareForCommit( relationshipRecord, prepareIdSequence.apply( relationshipRecord.getId() ) ); relationshipStore.updateRecord( relationshipRecord ); relationshipCount++; typeCounts.increment( relationshipRecord.getType() );