use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ServerExecutionEngineTest method shouldCloseResourcesInCancel.
@Test
void shouldCloseResourcesInCancel() throws Exception {
// GIVEN
TransactionalContextFactory contextFactory = Neo4jTransactionalContextFactory.create(() -> queryService, transactionFactory);
// We need two node vars to have one non-pooled cursor
String query = "MATCH (n), (m) WHERE true RETURN n, m, n.name, m.name";
try (InternalTransaction tx = db.beginTransaction(KernelTransaction.Type.EXPLICIT, AUTH_DISABLED)) {
tx.createNode();
tx.createNode();
TransactionalContext context = contextFactory.newContext(tx, query, MapValue.EMPTY);
QueryExecution execution = executionEngine.executeQuery(query, MapValue.EMPTY, context, false, DO_NOTHING_SUBSCRIBER);
execution.request(1);
// This should close all cursors
execution.cancel();
tx.commit();
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ReadTracingIT method noPageCacheTracingAvailableOnRelationshipIndexSeek.
@Test
void noPageCacheTracingAvailableOnRelationshipIndexSeek() throws KernelException {
createRelationshipIndex();
try (Transaction tx = database.beginTx()) {
var source = tx.createNode(label);
var target = tx.createNode(label);
var relationship = source.createRelationshipTo(target, type);
relationship.setProperty(property, testPropertyValue);
tx.commit();
}
try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
var kernelTransaction = transaction.kernelTransaction();
var dataRead = kernelTransaction.dataRead();
var indexDescriptor = kernelTransaction.schemaRead().indexGetForName(indexName);
IndexReadSession indexReadSession = kernelTransaction.dataRead().indexReadSession(indexDescriptor);
var cursorContext = kernelTransaction.cursorContext();
assertZeroCursor(cursorContext);
try (var cursor = kernelTransaction.cursors().allocateRelationshipValueIndexCursor(kernelTransaction.cursorContext(), kernelTransaction.memoryTracker())) {
dataRead.relationshipIndexSeek(indexReadSession, cursor, unconstrained(), fulltextSearch(testPropertyValue));
consumeCursor(cursor);
}
assertZeroCursor(cursorContext);
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ReadTracingIT method tracePageCacheAccessOnNodeWithoutTxStateCount.
@Test
void tracePageCacheAccessOnNodeWithoutTxStateCount() {
try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
var kernelTransaction = transaction.kernelTransaction();
var cursorContext = kernelTransaction.cursorContext();
var dataRead = kernelTransaction.dataRead();
assertZeroCursor(cursorContext);
dataRead.countsForNodeWithoutTxState(0);
assertOneCursor(cursorContext);
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ReadTracingIT method tracePageCacheAccessOnRelationshipCount.
@Test
void tracePageCacheAccessOnRelationshipCount() {
try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
var kernelTransaction = transaction.kernelTransaction();
var cursorContext = kernelTransaction.cursorContext();
var dataRead = kernelTransaction.dataRead();
assertZeroCursor(cursorContext);
dataRead.countsForRelationship(ANY_LABEL, ANY_RELATIONSHIP_TYPE, ANY_LABEL);
assertOneCursor(cursorContext);
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ReadTracingIT method tracePageCacheAccessOnNodeIndexSeek.
@Test
void tracePageCacheAccessOnNodeIndexSeek() throws KernelException {
createNodeConstraint();
createMatchingNode();
try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
var kernelTransaction = transaction.kernelTransaction();
var dataRead = kernelTransaction.dataRead();
var indexDescriptor = kernelTransaction.schemaRead().indexGetForName(indexName);
var cursorContext = kernelTransaction.cursorContext();
int propertyId = kernelTransaction.tokenRead().propertyKey(property);
assertZeroCursor(cursorContext);
var indexSession = dataRead.indexReadSession(indexDescriptor);
try (var cursor = kernelTransaction.cursors().allocateNodeValueIndexCursor(kernelTransaction.cursorContext(), kernelTransaction.memoryTracker())) {
dataRead.nodeIndexSeek(indexSession, cursor, unconstrained(), stringContains(propertyId, stringValue(testPropertyValue)));
consumeCursor(cursor);
}
assertOneCursor(cursorContext);
assertThat(cursorContext.getCursorTracer().faults()).isZero();
}
}
Aggregations