Search in sources :

Example 71 with Statement

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();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Statement(org.neo4j.kernel.api.Statement)

Example 72 with Statement

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);
}
Also used : SchemaWriteOperations(org.neo4j.kernel.api.SchemaWriteOperations) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement) Test(org.junit.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 73 with Statement

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();
}
Also used : Statement(org.neo4j.kernel.api.Statement) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 74 with Statement

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();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Statement(org.neo4j.kernel.api.Statement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)

Example 75 with Statement

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));
        }
    }
}
Also used : TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Statement(org.neo4j.kernel.api.Statement) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)

Aggregations

Statement (org.neo4j.kernel.api.Statement)158 Test (org.junit.Test)76 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)56 Transaction (org.neo4j.graphdb.Transaction)44 ReadOperations (org.neo4j.kernel.api.ReadOperations)40 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)30 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)23 NotFoundException (org.neo4j.graphdb.NotFoundException)21 Node (org.neo4j.graphdb.Node)20 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)19 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)13 KeyReadOperations (org.neo4j.kernel.impl.api.operations.KeyReadOperations)11 ArrayList (java.util.ArrayList)10 DependencyResolver (org.neo4j.graphdb.DependencyResolver)10 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)10 Label (org.neo4j.graphdb.Label)9 KernelAPI (org.neo4j.kernel.api.KernelAPI)9 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)9 InvalidTransactionTypeKernelException (org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException)8 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)8