use of org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent in project neo4j by neo4j.
the class KernelReadTracerTest method shouldTraceLabelScan.
@Test
void shouldTraceLabelScan() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
int barId = token.labelGetOrCreateForName("Bar");
List<TraceEvent> expectedEvents = new ArrayList<>();
expectedEvents.add(OnLabelScan(barId));
try (NodeLabelIndexCursor cursor = cursors.allocateNodeLabelIndexCursor(NULL)) {
// when
cursor.setTracer(tracer);
read.nodeLabelScan(getTokenReadSession(tx, EntityType.NODE), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(barId));
while (cursor.next()) {
expectedEvents.add(OnNode(cursor.nodeReference()));
}
}
// then
tracer.assertEvents(expectedEvents);
}
use of org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent in project neo4j by neo4j.
the class RelationshipTypeIndexCursorTestBase method shouldTraceRelationshipTypeScanEvents.
@Test
void shouldTraceRelationshipTypeScanEvents() throws KernelException {
long first;
long second;
long third;
try (KernelTransaction tx = beginTransaction()) {
first = createRelationship(tx.dataWrite(), typeOne);
second = createRelationship(tx.dataWrite(), typeTwo);
third = createRelationship(tx.dataWrite(), typeTwo);
tx.commit();
}
try (KernelTransaction tx = beginTransaction()) {
org.neo4j.internal.kernel.api.Read read = tx.dataRead();
try (RelationshipTypeIndexCursor cursor = tx.cursors().allocateRelationshipTypeIndexCursor(NULL)) {
TestKernelReadTracer tracer = new TestKernelReadTracer();
cursor.setTracer(tracer);
// when
relationshipTypeScan(tx, typeOne, cursor, IndexOrder.NONE);
exhaustCursor(cursor);
// then
tracer.assertEvents(new TraceEvent(RelationshipTypeScan, typeOne), new TraceEvent(Relationship, first));
// when
relationshipTypeScan(tx, typeTwo, cursor, IndexOrder.NONE);
exhaustCursor(cursor);
// then
tracer.assertEvents(new TraceEvent(RelationshipTypeScan, typeTwo), new TraceEvent(Relationship, second), new TraceEvent(Relationship, third));
}
}
}
use of org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent in project neo4j by neo4j.
the class KernelReadTracerTest method shouldTraceRelationshipTypeScan.
@Test
void shouldTraceRelationshipTypeScan() throws KernelException {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
int hasId = token.relationshipTypeGetOrCreateForName("HAS");
List<TraceEvent> expectedEvents = new ArrayList<>();
expectedEvents.add(OnRelationshipTypeScan(hasId));
try (RelationshipTypeIndexCursor cursor = cursors.allocateRelationshipTypeIndexCursor(NULL)) {
// when
cursor.setTracer(tracer);
read.relationshipTypeScan(getTokenReadSession(tx, EntityType.RELATIONSHIP), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(hasId));
while (cursor.next()) {
expectedEvents.add(OnRelationship(cursor.relationshipReference()));
}
}
// then
tracer.assertEvents(expectedEvents);
}
use of org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent in project neo4j by neo4j.
the class KernelReadTracerTest method shouldTraceAllNodesScan.
@Test
void shouldTraceAllNodesScan() {
// given
TestKernelReadTracer tracer = new TestKernelReadTracer();
List<TraceEvent> expectedEvents = new ArrayList<>();
expectedEvents.add(ON_ALL_NODES_SCAN);
try (NodeCursor nodes = cursors.allocateNodeCursor(NULL)) {
// when
nodes.setTracer(tracer);
read.allNodesScan(nodes);
while (nodes.next()) {
expectedEvents.add(OnNode(nodes.nodeReference()));
}
}
// then
tracer.assertEvents(expectedEvents);
}
Aggregations