use of org.neo4j.kernel.api.txstate.TransactionState in project neo4j by neo4j.
the class KernelToken method propertyKeyCreateForName.
@Override
public int propertyKeyCreateForName(String propertyKeyName, boolean internal) throws KernelException {
ktx.assertOpen();
TransactionState txState = ktx.txState();
int id = reserveTokenId(commandCreationContext::reservePropertyKeyTokenId, tokenHolders.propertyKeyTokens());
txState.propertyKeyDoCreateForName(propertyKeyName, internal, id);
return id;
}
use of org.neo4j.kernel.api.txstate.TransactionState in project neo4j by neo4j.
the class Operations method relationshipCreate.
@Override
public long relationshipCreate(long sourceNode, int relationshipType, long targetNode) throws EntityNotFoundException {
ktx.securityAuthorizationHandler().assertAllowsCreateRelationship(ktx.securityContext(), token::relationshipTypeGetName, relationshipType);
ktx.assertOpen();
sharedSchemaLock(ResourceTypes.RELATIONSHIP_TYPE, relationshipType);
sharedTokenSchemaLock(ResourceTypes.RELATIONSHIP_TYPE);
commandCreationContext.acquireRelationshipCreationLock(ktx.txState(), ktx.lockClient(), ktx.lockTracer(), sourceNode, targetNode);
assertNodeExists(sourceNode);
assertNodeExists(targetNode);
TransactionState txState = ktx.txState();
long id = commandCreationContext.reserveRelationship();
txState.relationshipDoCreate(id, relationshipType, sourceNode, targetNode);
return id;
}
use of org.neo4j.kernel.api.txstate.TransactionState in project neo4j by neo4j.
the class AllStoreHolder method countsForNodeInTxState.
private long countsForNodeInTxState(int labelId) {
long count = 0;
if (ktx.hasTxStateWithChanges()) {
CountsDelta counts = new CountsDelta();
try {
TransactionState txState = ktx.txState();
CursorContext cursorContext = ktx.cursorContext();
try (var countingVisitor = new TransactionCountingStateVisitor(EMPTY, storageReader, txState, counts, cursorContext)) {
txState.accept(countingVisitor);
}
if (counts.hasChanges()) {
count += counts.nodeCount(labelId, cursorContext);
}
} catch (KernelException e) {
throw new IllegalArgumentException("Unexpected error: " + e.getMessage());
}
}
return count;
}
use of org.neo4j.kernel.api.txstate.TransactionState in project neo4j by neo4j.
the class AllStoreHolder method countsForRelationshipInTxState.
private long countsForRelationshipInTxState(int startLabelId, int typeId, int endLabelId) {
long count = 0;
if (ktx.hasTxStateWithChanges()) {
CursorContext cursorContext = ktx.cursorContext();
CountsDelta counts = new CountsDelta();
try {
TransactionState txState = ktx.txState();
try (var countingVisitor = new TransactionCountingStateVisitor(EMPTY, storageReader, txState, counts, cursorContext)) {
txState.accept(countingVisitor);
}
if (counts.hasChanges()) {
count += counts.relationshipCount(startLabelId, typeId, endLabelId, cursorContext);
}
} catch (KernelException e) {
throw new IllegalArgumentException("Unexpected error: " + e.getMessage());
}
}
return count;
}
use of org.neo4j.kernel.api.txstate.TransactionState in project neo4j by neo4j.
the class AllStoreHolder method relationshipExists.
@Override
public boolean relationshipExists(long reference) {
ktx.assertOpen();
if (hasTxStateWithChanges()) {
TransactionState txState = txState();
if (txState.relationshipIsDeletedInThisTx(reference)) {
return false;
} else if (txState.relationshipIsAddedInThisTx(reference)) {
return true;
}
}
AccessMode mode = ktx.securityContext().mode();
CursorContext cursorContext = ktx.cursorContext();
boolean existsInRelStore = storageReader.relationshipExists(reference, cursorContext);
if (mode.allowsTraverseAllRelTypes()) {
return existsInRelStore;
} else if (!existsInRelStore) {
return false;
} else {
// DefaultNodeCursor already contains traversal checks within next()
try (DefaultRelationshipScanCursor rels = cursors.allocateRelationshipScanCursor(cursorContext)) {
ktx.dataRead().singleRelationship(reference, rels);
return rels.next();
}
}
}
Aggregations