use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method launchCustomIndexPopulation.
private void launchCustomIndexPopulation(Map<String, Integer> labelNameIdMap, int propertyId, List<NodeUpdates> updates) throws Exception {
NeoStores neoStores = getNeoStores();
LabelScanStore labelScanStore = getLabelScanStore();
ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
try (Transaction transaction = embeddedDatabase.beginTx()) {
Statement statement = transactionStatementContextBridge.get();
DynamicIndexStoreView storeView = new DynamicIndexStoreViewWrapper(labelScanStore, LockService.NO_LOCK_SERVICE, neoStores, updates);
SchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap(getSchemaIndexProvider());
JobScheduler scheduler = getJobScheduler();
StatementTokenNameLookup tokenNameLookup = new StatementTokenNameLookup(statement.readOperations());
indexService = IndexingServiceFactory.createIndexingService(Config.empty(), scheduler, providerMap, storeView, tokenNameLookup, getIndexRules(neoStores), NullLogProvider.getInstance(), IndexingService.NO_MONITOR, () -> {
});
indexService.start();
IndexRule[] rules = createIndexRules(labelNameIdMap, propertyId);
indexService.createIndexes(rules);
transaction.success();
}
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method getLabelIdsByName.
private Map<String, Integer> getLabelIdsByName(String... names) {
ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
ReadOperations readOperations = transactionStatementContextBridge.get().readOperations();
Map<String, Integer> labelNameIdMap = new HashMap<>();
for (String name : names) {
labelNameIdMap.put(name, readOperations.labelGetForName(name));
}
return labelNameIdMap;
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method getPropertyIdByName.
private int getPropertyIdByName(String name) {
ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
ReadOperations readOperations = transactionStatementContextBridge.get().readOperations();
return readOperations.propertyKeyGetForName(name);
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class ExecutionResultTest method activeTransaction.
private TopLevelTransaction activeTransaction() {
ThreadToStatementContextBridge bridge = db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
KernelTransaction kernelTransaction = bridge.getTopLevelTransactionBoundToThisThread(false);
return kernelTransaction == null ? null : new TopLevelTransaction(kernelTransaction, null);
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class IndexRecoveryIT method createSomeBananas.
private Set<IndexEntryUpdate> createSomeBananas(Label label) {
Set<IndexEntryUpdate> updates = new HashSet<>();
try (Transaction tx = db.beginTx()) {
ThreadToStatementContextBridge ctxSupplier = db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
try (Statement statement = ctxSupplier.get()) {
int labelId = statement.readOperations().labelGetForName(label.name());
int propertyKeyId = statement.readOperations().propertyKeyGetForName(key);
LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyId);
for (int number : new int[] { 4, 10 }) {
Node node = db.createNode(label);
node.setProperty(key, number);
updates.add(IndexEntryUpdate.add(node.getId(), schemaDescriptor, number));
}
}
tx.success();
return updates;
}
}
Aggregations