use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class NeoStoreIndexStoreViewTest method getOrCreateIds.
private void getOrCreateIds() throws KernelException {
try (Transaction tx = graphDb.beginTx()) {
ThreadToStatementContextBridge bridge = graphDb.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
try (Statement statement = bridge.get()) {
labelId = statement.tokenWriteOperations().labelGetOrCreateForName("Person");
propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("name");
}
tx.success();
}
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class GraphDatabaseShellServer method registerTopLevelTransactionInProgress.
public void registerTopLevelTransactionInProgress(Serializable clientId) throws ShellException {
if (!clients.containsKey(clientId)) {
ThreadToStatementContextBridge threadToStatementContextBridge = getThreadToStatementContextBridge();
KernelTransaction tx = threadToStatementContextBridge.getTopLevelTransactionBoundToThisThread(false);
clients.put(clientId, tx);
}
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class GraphDatabaseShellServer method bindTransaction.
public void bindTransaction(Serializable clientId) throws ShellException {
KernelTransaction tx = clients.get(clientId);
if (tx != null) {
try {
ThreadToStatementContextBridge threadToStatementContextBridge = getThreadToStatementContextBridge();
threadToStatementContextBridge.bindTransactionToCurrentThread(tx);
} catch (Exception e) {
throw wrapException(e);
}
}
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class StoreUpgradeIntegrationTest method checkLabelCounts.
private static void checkLabelCounts(GraphDatabaseAPI db) {
try (Transaction ignored = db.beginTx()) {
HashMap<Label, Long> counts = new HashMap<>();
for (Node node : db.getAllNodes()) {
for (Label label : node.getLabels()) {
Long count = counts.get(label);
if (count != null) {
counts.put(label, count + 1);
} else {
counts.put(label, 1L);
}
}
}
ThreadToStatementContextBridge bridge = db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
Statement statement = bridge.get();
for (Map.Entry<Label, Long> entry : counts.entrySet()) {
assertEquals(entry.getValue().longValue(), statement.readOperations().countsForNode(statement.readOperations().labelGetForName(entry.getKey().name())));
}
}
}
use of org.neo4j.kernel.impl.core.ThreadToStatementContextBridge in project neo4j by neo4j.
the class StoreUpgradeIntegrationTest method getAllIndexes.
private static Iterator<NewIndexDescriptor> getAllIndexes(GraphDatabaseAPI db) {
try (Transaction ignored = db.beginTx()) {
ThreadToStatementContextBridge bridge = db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
Statement statement = bridge.get();
return Iterators.concat(statement.readOperations().indexesGetAll(), statement.readOperations().uniqueIndexesGetAll());
}
}
Aggregations