use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class IndexStatisticsTest method dropIndex.
private void dropIndex(NewIndexDescriptor index) throws KernelException {
try (Transaction tx = db.beginTx()) {
Statement statement = bridge.get();
statement.schemaWriteOperations().indexDrop(index);
tx.success();
}
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class IndexIT method committedAndTransactionalIndexRulesShouldBeMerged.
@Test
public void committedAndTransactionalIndexRulesShouldBeMerged() throws Exception {
// GIVEN
SchemaWriteOperations schemaWriteOperations = schemaWriteOperationsInNewTransaction();
NewIndexDescriptor existingRule = schemaWriteOperations.indexCreate(SchemaBoundary.map(descriptor));
commit();
// WHEN
Statement statement = statementInNewTransaction(AnonymousContext.AUTH_DISABLED);
NewIndexDescriptor addedRule = statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(labelId, 10));
Set<NewIndexDescriptor> indexRulesInTx = asSet(statement.readOperations().indexesGetForLabel(labelId));
commit();
// THEN
assertEquals(asSet(existingRule, addedRule), indexRulesInTx);
}
use of org.neo4j.kernel.api.Statement in project neo4j by neo4j.
the class StorageLayerTest method readOps.
protected ReadOperations readOps() {
DependencyResolver dependencyResolver = db.getDependencyResolver();
Statement statement = dependencyResolver.resolveDependency(ThreadToStatementContextBridge.class).get();
return statement.readOperations();
}
use of org.neo4j.kernel.api.Statement 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.api.Statement in project neo4j by neo4j.
the class StoreUpgradeIntegrationTest method checkProvidedParameters.
private static void checkProvidedParameters(Store store, GraphDatabaseAPI db) {
try (Transaction ignored = db.beginTx()) {
// count nodes
long nodeCount = count(db.getAllNodes());
assertThat(nodeCount, is(store.expectedNodeCount));
// count indexes
long indexCount = count(db.schema().getIndexes());
assertThat(indexCount, is(store.indexes()));
// check last committed tx
TransactionIdStore txIdStore = db.getDependencyResolver().resolveDependency(TransactionIdStore.class);
long lastCommittedTxId = txIdStore.getLastCommittedTransactionId();
try (Statement statement = db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class).getKernelTransactionBoundToThisThread(true).acquireStatement()) {
long countsTxId = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores().getCounts().txId();
assertEquals(lastCommittedTxId, countsTxId);
assertThat(lastCommittedTxId, is(store.lastTxId));
}
}
}
Aggregations