/** * @return temporary relationship group store which will be deleted in {@link #close()}. */ public RecordStore<RelationshipGroupRecord> getTemporaryRelationshipGroupStore() { return temporaryNeoStores.getRelationshipGroupStore(); }
public RelationshipGroupStore getRelationshipGroupStore() { return neoStores.getRelationshipGroupStore(); }
@Override public boolean visitRelationshipGroupCommand( Command.RelationshipGroupCommand command ) { updateStore( neoStores.getRelationshipGroupStore(), command ); return false; }
@Override public boolean visitRelationshipGroupCommand( RelationshipGroupCommand command ) { track( neoStores.getRelationshipGroupStore(), command ); return false; }
private RecordRelationshipTraversalCursor getNodeRelationshipCursor() { return new RecordRelationshipTraversalCursor( neoStores.getRelationshipStore(), neoStores.getRelationshipGroupStore() ); } }
private RelationshipGroupRecord getRelGroupRecord( long id ) { return getRecord( resolveNeoStores().getRelationshipGroupStore(), id ); }
private void update( RelationshipGroupRecord record ) { resolveNeoStores().getRelationshipGroupStore().updateRecord( record ); }
@Before public void setup() { when( neoStores.getMetaDataStore() ).thenReturn( metaDataStore ); when( neoStores.getNodeStore() ).thenReturn( nodeStore ); when( neoStores.getRelationshipStore() ).thenReturn( relationshipStore ); when( neoStores.getPropertyStore() ).thenReturn( propertyStore ); when( neoStores.getRelationshipGroupStore() ).thenReturn( relationshipGroupStore ); when( neoStores.getRelationshipTypeTokenStore() ).thenReturn( relationshipTypeTokenStore ); when( neoStores.getLabelTokenStore() ).thenReturn( labelTokenStore ); when( neoStores.getPropertyKeyTokenStore() ).thenReturn( propertyKeyTokenStore ); when( neoStores.getSchemaStore() ).thenReturn( schemaStore ); when( nodeStore.getDynamicLabelStore() ).thenReturn( dynamicLabelStore ); when( lockService.acquireNodeLock( anyLong(), any() ) ) .thenReturn( LockService.NO_LOCK ); when( lockService.acquireRelationshipLock( anyLong(), any() ) ) .thenReturn( LockService.NO_LOCK ); when( transactionToApply.transactionId() ).thenReturn( transactionId ); }
public Loaders( NeoStores neoStores ) { this( neoStores.getNodeStore(), neoStores.getPropertyStore(), neoStores.getRelationshipStore(), neoStores.getRelationshipGroupStore(), neoStores.getPropertyKeyTokenStore(), neoStores.getRelationshipTypeTokenStore(), neoStores.getLabelTokenStore(), neoStores.getSchemaStore() ); }
public DirectRecordAccessSet( NeoStores neoStores ) { this( neoStores.getNodeStore(), neoStores.getPropertyStore(), neoStores.getRelationshipStore(), neoStores.getRelationshipGroupStore(), neoStores.getPropertyKeyTokenStore(), neoStores.getRelationshipTypeTokenStore(), neoStores.getLabelTokenStore(), neoStores.getSchemaStore() ); }
void updateCorrespondingIdGenerators( NeoStores neoStores ) { neoStores.getNodeStore().setHighestPossibleIdInUse( nodeId ); neoStores.getRelationshipStore().setHighestPossibleIdInUse( relId ); neoStores.getRelationshipGroupStore().setHighestPossibleIdInUse( relGroupId ); } }
private void createStore( DatabaseLayout migrationDirectoryStructure, RecordFormats newFormat ) { IdGeneratorFactory idGeneratorFactory = new ReadOnlyIdGeneratorFactory( fileSystem ); NullLogProvider logProvider = NullLogProvider.getInstance(); StoreFactory storeFactory = new StoreFactory( migrationDirectoryStructure, config, idGeneratorFactory, pageCache, fileSystem, newFormat, logProvider, EmptyVersionContextSupplier.EMPTY ); try ( NeoStores neoStores = storeFactory.openAllNeoStores( true ) ) { neoStores.getMetaDataStore(); neoStores.getLabelTokenStore(); neoStores.getNodeStore(); neoStores.getPropertyStore(); neoStores.getRelationshipGroupStore(); neoStores.getRelationshipStore(); neoStores.getSchemaStore(); } }
private void createAndVerify( Integer customThreshold ) { int expectedThreshold = customThreshold != null ? customThreshold : defaultThreshold; StoreFactory factory = factory( customThreshold ); NeoStores neoStores = factory.openAllNeoStores( true ); assertEquals( expectedThreshold, neoStores.getRelationshipGroupStore().getStoreHeaderInt() ); neoStores.close(); // Next time we open it it should be the same neoStores = factory.openAllNeoStores(); assertEquals( expectedThreshold, neoStores.getRelationshipGroupStore().getStoreHeaderInt() ); neoStores.close(); // Even if we open with a different config setting it should just ignore it factory = factory( 999999 ); neoStores = factory.openAllNeoStores(); assertEquals( expectedThreshold, neoStores.getRelationshipGroupStore().getStoreHeaderInt() ); neoStores.close(); }
@Test public void shouldOnlyChangeLockedRecordsWhenUpgradingToDenseNode() { // GIVEN long nodeId = createNodeWithRelationships( DENSE_NODE_THRESHOLD ); NeoStores neoStores = flipToNeoStores(); Tracker tracker = new Tracker( neoStores ); RelationshipGroupGetter groupGetter = new RelationshipGroupGetter( neoStores.getRelationshipGroupStore() ); RelationshipCreator relationshipCreator = new RelationshipCreator( groupGetter, 5 ); // WHEN relationshipCreator.relationshipCreate( idGeneratorFactory.get( IdType.RELATIONSHIP ).nextId(), 0, nodeId, nodeId, tracker, tracker ); // THEN assertEquals( tracker.relationshipLocksAcquired.size(), tracker.changedRelationships.size() ); assertFalse( tracker.relationshipLocksAcquired.isEmpty() ); }
@Test public void checkingIfRecordIsInUseMustHappenAfterConsistentRead() { AtomicBoolean nextReadIsInconsistent = new AtomicBoolean( false ); PageCache pageCache = pageCacheRule.getPageCache( fs, config().withInconsistentReads( nextReadIsInconsistent ) ); StoreFactory factory = factory( null, pageCache ); try ( NeoStores neoStores = factory.openAllNeoStores( true ) ) { RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore(); RelationshipGroupRecord record = new RelationshipGroupRecord( 1 ).initialize( true, 2, 3, 4, 5, 6, Record.NO_NEXT_RELATIONSHIP.intValue() ); relationshipGroupStore.updateRecord( record ); nextReadIsInconsistent.set( true ); // Now the following should not throw any RecordNotInUse exceptions RelationshipGroupRecord readBack = relationshipGroupStore.getRecord( 1, relationshipGroupStore.newRecord(), NORMAL ); assertThat( readBack.toString(), equalTo( record.toString() ) ); } }
private void assertRelationshipGroupsInOrder( NeoStores neoStores, long nodeId, int... types ) { NodeStore nodeStore = neoStores.getNodeStore(); NodeRecord node = nodeStore.getRecord( nodeId, nodeStore.newRecord(), NORMAL ); assertTrue( "Node should be dense, is " + node, node.isDense() ); long groupId = node.getNextRel(); int cursor = 0; List<RelationshipGroupRecord> seen = new ArrayList<>(); while ( groupId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore(); RelationshipGroupRecord group = relationshipGroupStore.getRecord( groupId, relationshipGroupStore.newRecord(), NORMAL ); seen.add( group ); assertEquals( "Invalid type, seen groups so far " + seen, types[cursor++], group.getType() ); groupId = group.getNext(); } assertEquals( "Not enough relationship group records found in chain for " + node, types.length, cursor ); }
private void prepareForCommit() { for ( Command.NodeCommand command : nodeCommands ) { neoStores.getNodeStore().prepareForCommit( command.getAfter() ); } for ( Command.RelationshipCommand command : relationshipCommands ) { neoStores.getRelationshipStore().prepareForCommit( command.getAfter() ); } for ( Command.RelationshipGroupCommand command : relationshipGroupCommands ) { neoStores.getRelationshipGroupStore().prepareForCommit( command.getAfter() ); } }
private TransactionRecordState newTransactionRecordState( NeoStores neoStores ) { Loaders loaders = new Loaders( neoStores ); recordChangeSet = new RecordChangeSet( loaders ); PropertyTraverser propertyTraverser = new PropertyTraverser(); RelationshipGroupGetter relationshipGroupGetter = new RelationshipGroupGetter( neoStores.getRelationshipGroupStore() ); PropertyDeleter propertyDeleter = new PropertyDeleter( propertyTraverser ); return new TransactionRecordState( neoStores, integrityValidator, recordChangeSet, 0, new NoOpClient(), new RelationshipCreator( relationshipGroupGetter, neoStores.getRelationshipGroupStore().getStoreHeaderInt() ), new RelationshipDeleter( relationshipGroupGetter, propertyDeleter ), new PropertyCreator( neoStores.getPropertyStore(), propertyTraverser ), propertyDeleter ); }
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 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() ) ); }