Search in sources :

Example 1 with TraceEvent

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);
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) ArrayList(java.util.ArrayList) NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor) TraceEvent(org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent) Test(org.junit.jupiter.api.Test)

Example 2 with TraceEvent

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));
        }
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipTypeIndexCursor(org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor) TraceEvent(org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with TraceEvent

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);
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) RelationshipTypeIndexCursor(org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor) ArrayList(java.util.ArrayList) TraceEvent(org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent) Test(org.junit.jupiter.api.Test)

Example 4 with TraceEvent

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);
}
Also used : ArrayList(java.util.ArrayList) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) TraceEvent(org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 TraceEvent (org.neo4j.kernel.impl.newapi.TestKernelReadTracer.TraceEvent)4 ArrayList (java.util.ArrayList)3 RelationshipTypeIndexCursor (org.neo4j.internal.kernel.api.RelationshipTypeIndexCursor)2 TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)1 NodeLabelIndexCursor (org.neo4j.internal.kernel.api.NodeLabelIndexCursor)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1