@Override public boolean visitLabelTokenCommand( Command.LabelTokenCommand command ) { updateStore( neoStores.getLabelTokenStore(), command ); return false; }
@Override public boolean visitLabelTokenCommand( LabelTokenCommand command ) { trackToken( neoStores.getLabelTokenStore(), command ); return false; }
@Override public int reserveLabelTokenId() { return toIntExact( neoStores.getLabelTokenStore().nextId() ); }
@Override protected LabelTokenStore getStore( NeoStores neoStores ) { return neoStores.getLabelTokenStore(); }
public CacheInvalidationTransactionApplier( NeoStores neoStores, CacheAccessBackDoor cacheAccess ) { this.cacheAccess = cacheAccess; this.relationshipTypeTokenStore = neoStores.getRelationshipTypeTokenStore(); this.labelTokenStore = neoStores.getLabelTokenStore(); this.propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore(); }
/** * Creates a property index entry out of the given id and string. * * @param name The key of the property index, as a string. * @param id The property index record id. */ void createLabelToken( String name, long id ) { TokenCreator<LabelTokenRecord> creator = new TokenCreator<>( neoStores.getLabelTokenStore() ); creator.createToken( name, id, recordChangeSet.getLabelTokenChanges() ); }
@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() ); }
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 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 TransactionRecordState nodeWithDynamicLabelRecord( NeoStores store, AtomicLong nodeId, AtomicLong dynamicLabelRecordId ) { TransactionRecordState recordState = newTransactionRecordState( store ); nodeId.set( store.getNodeStore().nextId() ); int[] labelIds = new int[20]; for ( int i = 0; i < labelIds.length; i++ ) { int labelId = (int) store.getLabelTokenStore().nextId(); recordState.createLabelToken( "Label" + i, labelId ); labelIds[i] = labelId; } recordState.nodeCreate( nodeId.get() ); for ( int labelId : labelIds ) { recordState.addLabelToNode( labelId, nodeId.get() ); } // Extract the dynamic label record id (which is also a verification that we allocated one) NodeRecord node = Iterables.single( recordChangeSet.getNodeRecords().changes() ).forReadingData(); dynamicLabelRecordId.set( Iterables.single( node.getDynamicLabelRecords() ).getId() ); return recordState; }
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(); }
RecordStorageEngine.class ).testAccessNeoStores(); Function<String, Integer> labelTranslationTable = translationTable( neoStores.getLabelTokenStore(), StatementConstants.ANY_LABEL ); for ( Pair<Integer,Long> count : allNodeCounts( labelTranslationTable, expectedNodeCounts ) )
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 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 ) ); } }
tokenHolders.labelTokens().setInitialTokens( neoStores.getLabelTokenStore().getTokens() ); tokenHolders.relationshipTypeTokens().setInitialTokens( neoStores.getRelationshipTypeTokenStore().getTokens() );
assertEquals( "PropertyKey NameStore", 1 + 1, neoStores.getPropertyKeyTokenStore().getNameStore().getHighId() ); assertEquals( "LabelStore", 5 + 1, neoStores.getLabelTokenStore().getHighId() ); assertEquals( "Label NameStore", 1 + 1, neoStores.getLabelTokenStore().getNameStore().getHighId() ); assertEquals( "PropertyStore", 20 + 1, neoStores.getPropertyStore().getHighId() ); assertEquals( "PropertyStore DynamicStringStore", 7 + 1, neoStores.getPropertyStore().getStringStore().getHighId() );