use of org.neo4j.storageengine.api.CountsDelta 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.storageengine.api.CountsDelta 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.storageengine.api.CountsDelta in project neo4j by neo4j.
the class TransactionCountingStateVisitorTraceIT method traceStateWithChanges.
private void traceStateWithChanges(Consumer<Transaction> transactionalOperation) throws KernelException {
try (var transaction = database.beginTx()) {
var internalTransaction = (InternalTransaction) transaction;
KernelTransactionImplementation kernelTransaction = (KernelTransactionImplementation) internalTransaction.kernelTransaction();
var cursorContext = kernelTransaction.cursorContext();
transactionalOperation.accept(transaction);
cursorContext.getCursorTracer().reportEvents();
assertZeroCursor(cursorContext);
var transactionState = kernelTransaction.txState();
var counts = new CountsDelta();
try (StorageReader storageReader = kernelTransaction.newStorageReader();
var stateVisitor = new TransactionCountingStateVisitor(EMPTY, storageReader, transactionState, counts, cursorContext)) {
transactionState.accept(stateVisitor);
}
assertTwoCursor(cursorContext);
}
}
Aggregations