@Override public boolean visitRelationshipTypeTokenCommand( Command.RelationshipTypeTokenCommand command ) { updateStore( neoStores.getRelationshipTypeTokenStore(), command ); return false; }
@Override public boolean visitRelationshipTypeTokenCommand( RelationshipTypeTokenCommand command ) { trackToken( neoStores.getRelationshipTypeTokenStore(), command ); return false; }
@Override public int reserveRelationshipTypeTokenId() { return toIntExact( neoStores.getRelationshipTypeTokenStore().nextId() ); }
public CacheInvalidationTransactionApplier( NeoStores neoStores, CacheAccessBackDoor cacheAccess ) { this.cacheAccess = cacheAccess; this.relationshipTypeTokenStore = neoStores.getRelationshipTypeTokenStore(); this.labelTokenStore = neoStores.getLabelTokenStore(); this.propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore(); }
/** * Creates a new RelationshipType record with the given id that has the * given name. * * @param name The name of the relationship type. * @param id The id of the new relationship type record. */ void createRelationshipTypeToken( String name, long id ) { TokenCreator<RelationshipTypeTokenRecord> creator = new TokenCreator<>( neoStores.getRelationshipTypeTokenStore() ); creator.createToken( name, id, recordChangeSet.getRelationshipTypeTokenChanges() ); }
@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 DirectRecordAccessSet( NeoStores neoStores ) { this( neoStores.getNodeStore(), neoStores.getPropertyStore(), neoStores.getRelationshipStore(), neoStores.getRelationshipGroupStore(), neoStores.getPropertyKeyTokenStore(), neoStores.getRelationshipTypeTokenStore(), neoStores.getLabelTokenStore(), neoStores.getSchemaStore() ); }
public Loaders( NeoStores neoStores ) { this( neoStores.getNodeStore(), neoStores.getPropertyStore(), neoStores.getRelationshipStore(), neoStores.getRelationshipGroupStore(), neoStores.getPropertyKeyTokenStore(), neoStores.getRelationshipTypeTokenStore(), neoStores.getLabelTokenStore(), neoStores.getSchemaStore() ); }
CountsComputer( NeoStores stores, PageCache pageCache, DatabaseLayout databaseLayout ) { this( stores.getMetaDataStore().getLastCommittedTransactionId(), stores.getNodeStore(), stores.getRelationshipStore(), (int) stores.getLabelTokenStore().getHighId(), (int) stores.getRelationshipTypeTokenStore().getHighId(), NumberArrayFactory.auto( pageCache, databaseLayout.databaseDirectory(), true, NumberArrayFactory.NO_MONITOR ) ); }
private void shiftHighId( GraphDatabaseAPI db ) { RecordStorageEngine storageEngine = db.getDependencyResolver().resolveDependency( RecordStorageEngine.class ); NeoStores neoStores = storageEngine.testAccessNeoStores(); neoStores.getRelationshipTypeTokenStore().setHighId( Short.MAX_VALUE - RELATIONSHIP_COUNT / 2 ); }
private long nextId( Class<?> clazz ) { NeoStores neoStores = ds.getDependencyResolver() .resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); if ( clazz.equals( PropertyKeyTokenRecord.class ) ) { return neoStores.getPropertyKeyTokenStore().nextId(); } if ( clazz.equals( RelationshipType.class ) ) { return neoStores.getRelationshipTypeTokenStore().nextId(); } if ( clazz.equals( Node.class ) ) { return neoStores.getNodeStore().nextId(); } if ( clazz.equals( Relationship.class ) ) { return neoStores.getRelationshipStore().nextId(); } throw new IllegalArgumentException( clazz.getName() ); }
private void instantiateStores() { neoStores = newStoreFactory( databaseLayout ).openAllNeoStores( true ); propertyKeyRepository = new BatchingPropertyKeyTokenRepository( neoStores.getPropertyKeyTokenStore() ); labelRepository = new BatchingLabelTokenRepository( neoStores.getLabelTokenStore() ); relationshipTypeRepository = new BatchingRelationshipTypeTokenRepository( neoStores.getRelationshipTypeTokenStore() ); temporaryNeoStores = instantiateTempStores(); instantiateKernelExtensions(); // Delete the id generators because makeStoreOk isn't atomic in the sense that there's a possibility of an unlucky timing such // that if the process is killed at the right time some store may end up with a .id file that looks to be CLEAN and has highId=0, // i.e. effectively making the store look empty on the next start. Normal recovery of a db is sort of protected by this recovery // recognizing that the db needs recovery when it looks at the tx log and also calling deleteIdGenerators. In the import case // there are no tx logs at all, and therefore we do this manually right here. neoStores.deleteIdGenerators(); temporaryNeoStores.deleteIdGenerators(); neoStores.makeStoreOk(); temporaryNeoStores.makeStoreOk(); }
@Override public void start() throws Throwable { neoStores.makeStoreOk(); tokenHolders.propertyKeyTokens().setInitialTokens( neoStores.getPropertyKeyTokenStore().getTokens() ); tokenHolders.relationshipTypeTokens().setInitialTokens( neoStores.getRelationshipTypeTokenStore().getTokens() ); tokenHolders.labelTokens().setInitialTokens( neoStores.getLabelTokenStore().getTokens() ); neoStores.startCountStore(); // TODO: move this to counts store lifecycle loadSchemaCache(); indexingService.start(); labelScanStore.start(); idController.start(); }
private void rebuildCountsFromScratch( DatabaseLayout sourceStructure, DatabaseLayout migrationStructure, long lastTxId, ProgressReporter progressMonitor, String expectedStoreVersion, PageCache pageCache, LogProvider logProvider ) { RecordFormats recordFormats = selectForVersion( expectedStoreVersion ); IdGeneratorFactory idGeneratorFactory = new ReadOnlyIdGeneratorFactory( fileSystem ); StoreFactory storeFactory = new StoreFactory( sourceStructure, config, idGeneratorFactory, pageCache, fileSystem, recordFormats, logProvider, EmptyVersionContextSupplier.EMPTY ); try ( NeoStores neoStores = storeFactory .openNeoStores( StoreType.NODE, StoreType.RELATIONSHIP, StoreType.LABEL_TOKEN, StoreType.RELATIONSHIP_TYPE_TOKEN ) ) { neoStores.verifyStoreOk(); NodeStore nodeStore = neoStores.getNodeStore(); RelationshipStore relationshipStore = neoStores.getRelationshipStore(); try ( Lifespan life = new Lifespan() ) { int highLabelId = (int) neoStores.getLabelTokenStore().getHighId(); int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId(); CountsComputer initializer = new CountsComputer( lastTxId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId, NumberArrayFactory.auto( pageCache, migrationStructure.databaseDirectory(), true, NumberArrayFactory.NO_MONITOR ), progressMonitor ); life.add( new CountsTracker( logProvider, fileSystem, pageCache, config, migrationStructure, EmptyVersionContextSupplier.EMPTY ).setInitializer( initializer ) ); } } } }
/** * This method exists since {@link #wrapStore(RecordStore)} might depend on the existence of a variable * that gets set in a subclass' constructor <strong>after</strong> this constructor of {@link StoreAccess} * has been executed. I.e. a correct creation of a {@link StoreAccess} instance must be the creation of the * object plus a call to {@link #initialize()}. * * @return this */ public StoreAccess initialize() { this.schemaStore = wrapStore( neoStores.getSchemaStore() ); this.nodeStore = wrapStore( neoStores.getNodeStore() ); this.relStore = wrapStore( neoStores.getRelationshipStore() ); this.propStore = wrapStore( neoStores.getPropertyStore() ); this.stringStore = wrapStore( neoStores.getPropertyStore().getStringStore() ); this.arrayStore = wrapStore( neoStores.getPropertyStore().getArrayStore() ); this.relationshipTypeTokenStore = wrapStore( neoStores.getRelationshipTypeTokenStore() ); this.labelTokenStore = wrapStore( neoStores.getLabelTokenStore() ); this.nodeDynamicLabelStore = wrapStore( wrapNodeDynamicLabelStore( neoStores.getNodeStore().getDynamicLabelStore() ) ); this.propertyKeyTokenStore = wrapStore( neoStores.getPropertyStore().getPropertyKeyTokenStore() ); this.relationshipTypeNameStore = wrapStore( neoStores.getRelationshipTypeTokenStore().getNameStore() ); this.labelNameStore = wrapStore( neoStores.getLabelTokenStore().getNameStore() ); this.propertyKeyNameStore = wrapStore( neoStores.getPropertyStore().getPropertyKeyTokenStore().getNameStore() ); this.relGroupStore = wrapStore( neoStores.getRelationshipGroupStore() ); return this; }
private void initializeStores( DatabaseLayout databaseLayout, Map<String,String> additionalConfig ) throws IOException { Dependencies dependencies = new Dependencies(); dependencies.satisfyDependency( Config.defaults( additionalConfig ) ); ds = dsRule.getDataSource( databaseLayout, fs.get(), pageCache, dependencies ); ds.start(); NeoStores neoStores = ds.getDependencyResolver() .resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); pStore = neoStores.getPropertyStore(); rtStore = neoStores.getRelationshipTypeTokenStore(); relStore = neoStores.getRelationshipStore(); nodeStore = neoStores.getNodeStore(); storageReader = ds.getDependencyResolver().resolveDependency( StorageEngine.class ).newReader(); }
int typeA = (int) neoStores.getRelationshipTypeTokenStore().nextId(); tx.createRelationshipTypeToken( "A", typeA ); createRelationships( neoStores, tx, nodeId, typeA, INCOMING, 20 );
private void rebuildCounts( long lastCommittedTransactionId, ProgressReporter progressReporter ) { cleanupCountsForRebuilding(); IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory( fs ); StoreFactory storeFactory = new StoreFactory( testDir.databaseLayout(), CONFIG, idGenFactory, pageCache, fs, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); try ( Lifespan life = new Lifespan(); NeoStores neoStores = storeFactory.openAllNeoStores() ) { NodeStore nodeStore = neoStores.getNodeStore(); RelationshipStore relationshipStore = neoStores.getRelationshipStore(); int highLabelId = (int) neoStores.getLabelTokenStore().getHighId(); int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId(); CountsComputer countsComputer = new CountsComputer( lastCommittedTransactionId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId, NumberArrayFactory.AUTO_WITHOUT_PAGECACHE, progressReporter ); CountsTracker countsTracker = createCountsTracker(); life.add( countsTracker.setInitializer( countsComputer ) ); } }
neoStores.getRelationshipTypeTokenStore().setHighId( 16 );
assertEquals( "DynamicNodeLabelStore", 5 + 1, neoStores.getNodeStore().getDynamicLabelStore().getHighId() ); assertEquals( "RelationshipStore", 45 + 1, neoStores.getRelationshipStore().getHighId() ); assertEquals( "RelationshipTypeStore", 5 + 1, neoStores.getRelationshipTypeTokenStore().getHighId() ); assertEquals( "RelationshipType NameStore", 1 + 1, neoStores.getRelationshipTypeTokenStore().getNameStore().getHighId() ); assertEquals( "PropertyKeyStore", 5 + 1, neoStores.getPropertyKeyTokenStore().getHighId() ); assertEquals( "PropertyKey NameStore", 1 + 1,