Search in sources :

Example 26 with KernelStatement

use of org.neo4j.kernel.impl.api.KernelStatement in project neo4j by neo4j.

the class NeoStoresTest method deleteRelationships.

private void deleteRelationships(long nodeId) throws Exception {
    try (KernelStatement statement = (KernelStatement) tx.acquireStatement();
        Cursor<NodeItem> nodeCursor = statement.getStoreStatement().acquireSingleNodeCursor(nodeId)) {
        assertTrue(nodeCursor.next());
        NodeItem nodeItem = nodeCursor.get();
        statement.getStoreStatement().acquireNodeRelationshipCursor(nodeItem.isDense(), nodeItem.id(), nodeItem.nextRelationshipId(), BOTH, ALWAYS_TRUE_INT).forAll(rel -> relDelete(rel.id()));
    }
}
Also used : NodeItem(org.neo4j.storageengine.api.NodeItem) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement)

Example 27 with KernelStatement

use of org.neo4j.kernel.impl.api.KernelStatement in project neo4j by neo4j.

the class NeoStoresTest method assertHasRelationships.

private void assertHasRelationships(long node) {
    try (KernelStatement statement = (KernelStatement) tx.acquireStatement();
        Cursor<NodeItem> nodeCursor = statement.getStoreStatement().acquireSingleNodeCursor(node)) {
        nodeCursor.next();
        NodeItem nodeItem = nodeCursor.get();
        try (Cursor<RelationshipItem> relationships = statement.getStoreStatement().acquireNodeRelationshipCursor(nodeItem.isDense(), nodeItem.id(), nodeItem.nextRelationshipId(), BOTH, ALWAYS_TRUE_INT)) {
            assertTrue(relationships.next());
        }
    }
}
Also used : NodeItem(org.neo4j.storageengine.api.NodeItem) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) RelationshipItem(org.neo4j.storageengine.api.RelationshipItem)

Example 28 with KernelStatement

use of org.neo4j.kernel.impl.api.KernelStatement in project neo4j by neo4j.

the class TransactionStateChecker method create.

public static TransactionStateChecker create(TransitionalPeriodTransactionMessContainer container) {
    KernelTransaction topLevelTransactionBoundToThisThread = container.getBridge().getTopLevelTransactionBoundToThisThread(true);
    KernelStatement kernelStatement = (KernelStatement) topLevelTransactionBoundToThisThread.acquireStatement();
    return new TransactionStateChecker(nodeId -> kernelStatement.hasTxStateWithChanges() && kernelStatement.txState().nodeIsDeletedInThisTx(nodeId), relId -> kernelStatement.hasTxStateWithChanges() && kernelStatement.txState().relationshipIsDeletedInThisTx(relId));
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement)

Aggregations

KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)28 Test (org.junit.Test)19 StateHandlingStatementOperations (org.neo4j.kernel.impl.api.StateHandlingStatementOperations)14 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)13 StoreReadLayer (org.neo4j.storageengine.api.StoreReadLayer)9 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)9 PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)8 IndexQuery (org.neo4j.kernel.api.schema_new.IndexQuery)8 NodeItem (org.neo4j.storageengine.api.NodeItem)6 UniquenessConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)4 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3 PropertyAccessor (org.neo4j.kernel.api.index.PropertyAccessor)3 ConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor)3 StatementOperationParts (org.neo4j.kernel.impl.api.StatementOperationParts)3 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)3 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)3 ConstraintIndexCreator (org.neo4j.kernel.impl.api.state.ConstraintIndexCreator)3 RelationshipItem (org.neo4j.storageengine.api.RelationshipItem)3 IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)2