Search in sources :

Example 11 with NodeLabelIndexCursor

use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.

the class NodeTransactionStateTestBase method shouldNotFindDeletedNodeInLabelScan.

@Test
void shouldNotFindDeletedNodeInLabelScan() throws Exception {
    // Given
    Node node = createNode("label");
    try (KernelTransaction tx = beginTransaction();
        NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(tx.cursorContext())) {
        // when
        tx.dataWrite().nodeDelete(node.node);
        tx.dataRead().nodeLabelScan(getTokenReadSession(tx, EntityType.NODE), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(node.labels[0]));
        // then
        assertFalse(cursor.next());
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor) Test(org.junit.jupiter.api.Test)

Example 12 with NodeLabelIndexCursor

use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.

the class ManagedTestCursors method allocateFullAccessNodeLabelIndexCursor.

@Override
public NodeLabelIndexCursor allocateFullAccessNodeLabelIndexCursor(CursorContext cursorContext) {
    NodeLabelIndexCursor n = cursors.allocateFullAccessNodeLabelIndexCursor(cursorContext);
    allCursors.add(n);
    return n;
}
Also used : NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor)

Example 13 with NodeLabelIndexCursor

use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.

the class ManagedTestCursors method allocateNodeLabelIndexCursor.

@Override
public NodeLabelIndexCursor allocateNodeLabelIndexCursor(CursorContext cursorContext) {
    NodeLabelIndexCursor n = cursors.allocateNodeLabelIndexCursor(cursorContext);
    allCursors.add(n);
    return n;
}
Also used : NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor)

Example 14 with NodeLabelIndexCursor

use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.

the class KernelReadTracerTxStateTest method shouldTraceLabelScan.

@Test
void shouldTraceLabelScan() throws KernelException {
    // given
    TestKernelReadTracer tracer = new TestKernelReadTracer();
    try (KernelTransaction tx = beginTransaction();
        NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(NULL)) {
        int barId = tx.tokenWrite().labelGetOrCreateForName("Bar");
        long n = tx.dataWrite().nodeCreate();
        tx.dataWrite().nodeAddLabel(n, barId);
        // when
        cursor.setTracer(tracer);
        tx.dataRead().nodeLabelScan(getTokenReadSession(tx, EntityType.NODE), cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(barId));
        tracer.assertEvents(OnLabelScan(barId));
        assertTrue(cursor.next());
        tracer.assertEvents(OnNode(cursor.nodeReference()));
        assertFalse(cursor.next());
        tracer.assertEvents();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor) Test(org.junit.jupiter.api.Test)

Example 15 with NodeLabelIndexCursor

use of org.neo4j.internal.kernel.api.NodeLabelIndexCursor in project neo4j by neo4j.

the class DefaultPooledCursorsTestBase method shouldReuseFullAccessNodeLabelIndexCursor.

@Test
void shouldReuseFullAccessNodeLabelIndexCursor() throws Exception {
    try (KernelTransaction tx = beginTransaction()) {
        NodeLabelIndexCursor c1 = tx.cursors().allocateFullAccessNodeLabelIndexCursor(NULL);
        tx.dataRead().nodeLabelScan(getTokenReadSession(tx, EntityType.NODE), c1, IndexQueryConstraints.unconstrained(), new TokenPredicate(1));
        c1.close();
        NodeLabelIndexCursor c2 = tx.cursors().allocateFullAccessNodeLabelIndexCursor(NULL);
        assertThat(c1).isSameAs(c2);
        c2.close();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor) Test(org.junit.jupiter.api.Test)

Aggregations

NodeLabelIndexCursor (org.neo4j.internal.kernel.api.NodeLabelIndexCursor)25 Test (org.junit.jupiter.api.Test)23 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)19 TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)11 ExecutorService (java.util.concurrent.ExecutorService)8 LongList (org.eclipse.collections.api.list.primitive.LongList)8 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)8 CursorFactory (org.neo4j.internal.kernel.api.CursorFactory)8 ArrayList (java.util.ArrayList)7 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)7 Future (java.util.concurrent.Future)6 Read (org.neo4j.internal.kernel.api.Read)4 Write (org.neo4j.internal.kernel.api.Write)4 List (java.util.List)3 ExecutionException (java.util.concurrent.ExecutionException)3 Executors (java.util.concurrent.Executors)3 TimeUnit (java.util.concurrent.TimeUnit)3 Supplier (java.util.function.Supplier)3 ToLongFunction (java.util.function.ToLongFunction)3 Collectors (java.util.stream.Collectors)3