use of org.neo4j.token.TokenHolders in project neo4j by neo4j.
the class IndexPopulationJobTest method before.
@BeforeEach
void before() throws Exception {
kernel = db.getDependencyResolver().resolveDependency(Kernel.class);
tokens = db.getDependencyResolver().resolveDependency(TokenNameLookup.class);
tokenHolders = db.getDependencyResolver().resolveDependency(TokenHolders.class);
stateHolder = new DatabaseSchemaState(NullLogProvider.getInstance());
IndexingService indexingService = db.getDependencyResolver().resolveDependency(IndexingService.class);
indexStoreView = db.getDependencyResolver().resolveDependency(IndexStoreViewFactory.class).createTokenIndexStoreView(indexingService::getIndexProxy);
indexStatisticsStore = db.getDependencyResolver().resolveDependency(IndexStatisticsStore.class);
jobScheduler = db.getDependencyResolver().resolveDependency(JobScheduler.class);
try (KernelTransaction tx = kernel.beginTransaction(IMPLICIT, LoginContext.AUTH_DISABLED)) {
labelId = tx.tokenWrite().labelGetOrCreateForName(FIRST.name());
tx.tokenWrite().labelGetOrCreateForName(SECOND.name());
tx.commit();
}
}
use of org.neo4j.token.TokenHolders in project neo4j by neo4j.
the class DatabaseManagementServiceImpl method createDatabase.
@Override
public void createDatabase(String name, Configuration databaseSpecificSettings) {
String storageEngineName = getStorageEngine(databaseSpecificSettings);
systemDatabaseExecute("CREATE DATABASE `" + name + "`", (database, transaction) -> {
// Inject the configured storage engine as a property on the node representing the created database
// This is somewhat a temporary measure before CREATE DATABASE gets support for specifying the storage engine
// directly into the command syntax.
TransactionState txState = ((KernelTransactionImplementation) transaction.kernelTransaction()).txState();
TokenHolders tokenHolders = database.getDependencyResolver().resolveDependency(TokenHolders.class);
long nodeId = findNodeForCreatedDatabaseInTransactionState(txState, tokenHolders, name);
int storageEngineNamePropertyKeyTokenId = tokenHolders.propertyKeyTokens().getOrCreateId(DATABASE_STORAGE_ENGINE_PROPERTY);
txState.nodeDoAddProperty(nodeId, storageEngineNamePropertyKeyTokenId, Values.stringValue(storageEngineName));
});
}
use of org.neo4j.token.TokenHolders in project neo4j by neo4j.
the class StoreTokens method readOnlyTokenHolders.
/**
* Create read-only token holders initialised with the tokens from the given {@link NeoStores}.
* <p>
* Note that this call will ignore tokens that cannot be loaded due to inconsistencies, rather than throwing an exception.
* The reason for this is that the read-only token holders are primarily used by tools, such as the consistency checker.
*
* @param neoStores The {@link NeoStores} from which to load the initial tokens.
* @return TokenHolders that can be used for reading tokens, but cannot create new ones.
*/
public static TokenHolders readOnlyTokenHolders(NeoStores neoStores, CursorContext cursorContext) {
TokenHolder propertyKeyTokens = createReadOnlyTokenHolder(TokenHolder.TYPE_PROPERTY_KEY);
TokenHolder labelTokens = createReadOnlyTokenHolder(TokenHolder.TYPE_LABEL);
TokenHolder relationshipTypeTokens = createReadOnlyTokenHolder(TokenHolder.TYPE_RELATIONSHIP_TYPE);
TokenHolders tokenHolders = new TokenHolders(propertyKeyTokens, labelTokens, relationshipTypeTokens);
tokenHolders.setInitialTokens(allReadableTokens(neoStores), cursorContext);
return tokenHolders;
}
use of org.neo4j.token.TokenHolders in project neo4j by neo4j.
the class KernelTokenTest method setUp.
@BeforeEach
void setUp() {
ktx = mock(KernelTransactionImplementation.class);
transactionState = mock(TransactionState.class);
when(ktx.txState()).thenReturn(transactionState);
commandCreationContext = mock(CommandCreationContext.class);
storageReader = mock(StorageReader.class);
propertyKeyTokens = mock(TokenHolder.class);
labelTokens = mock(TokenHolder.class);
relationshipTypeTokens = mock(TokenHolder.class);
tokenHolders = new TokenHolders(propertyKeyTokens, labelTokens, relationshipTypeTokens);
kernelToken = new KernelToken(storageReader, commandCreationContext, ktx, tokenHolders);
}
use of org.neo4j.token.TokenHolders in project neo4j by neo4j.
the class RecordStorageEngineFactory method tokenHoldersForSchemaStore.
private static TokenHolders tokenHoldersForSchemaStore(NeoStores stores, TokenCreator propertyKeyTokenCreator, CursorContext cursorContext) {
TokenHolder propertyKeyTokens = new DelegatingTokenHolder(propertyKeyTokenCreator, TokenHolder.TYPE_PROPERTY_KEY);
TokenHolders dstTokenHolders = new TokenHolders(propertyKeyTokens, StoreTokens.createReadOnlyTokenHolder(TokenHolder.TYPE_LABEL), StoreTokens.createReadOnlyTokenHolder(TokenHolder.TYPE_RELATIONSHIP_TYPE));
dstTokenHolders.propertyKeyTokens().setInitialTokens(stores.getPropertyKeyTokenStore().getTokens(cursorContext));
return dstTokenHolders;
}
Aggregations