Search in sources :

Example 1 with TokenReadSession

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

the class NodeScanIT method trackPageCacheAccessOnNodeLabelScan.

@Test
void trackPageCacheAccessOnNodeLabelScan() throws KernelException {
    var testLabel = Label.label("testLabel");
    try (KernelTransaction tx = kernel.beginTransaction(IMPLICIT, read())) {
        var cursorContext = tx.cursorContext();
        assertThat(cursorContext.getCursorTracer().pins()).isZero();
        var label = tx.tokenRead().nodeLabel(testLabel.name());
        IndexDescriptor index = tx.schemaRead().index(SchemaDescriptor.forAnyEntityTokens(EntityType.NODE)).next();
        TokenReadSession tokenReadSession = tx.dataRead().tokenReadSession(index);
        try (NodeLabelIndexCursor cursor = tx.cursors().allocateNodeLabelIndexCursor(cursorContext)) {
            tx.dataRead().nodeLabelScan(tokenReadSession, cursor, IndexQueryConstraints.unconstrained(), new TokenPredicate(label));
            assertThat(cursorContext.getCursorTracer().pins()).isNotZero();
        }
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TokenReadSession(org.neo4j.internal.kernel.api.TokenReadSession) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) NodeLabelIndexCursor(org.neo4j.internal.kernel.api.NodeLabelIndexCursor) Test(org.junit.jupiter.api.Test)

Example 2 with TokenReadSession

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

the class NodeLabelIndexOrderTest method tokenScan.

@Override
protected void tokenScan(IndexOrder indexOrder, KernelTransaction tx, int label, NodeLabelIndexCursor cursor) throws KernelException {
    IndexDescriptor index = tx.schemaRead().index(SchemaDescriptor.forAnyEntityTokens(EntityType.NODE)).next();
    TokenReadSession tokenReadSession = tx.dataRead().tokenReadSession(index);
    tx.dataRead().nodeLabelScan(tokenReadSession, cursor, IndexQueryConstraints.ordered(indexOrder), new TokenPredicate(label));
}
Also used : TokenReadSession(org.neo4j.internal.kernel.api.TokenReadSession) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 3 with TokenReadSession

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

the class RelationshipTypeIndexOrderTest method tokenScan.

@Override
protected void tokenScan(IndexOrder indexOrder, KernelTransaction tx, int label, RelationshipTypeIndexCursor cursor) throws KernelException {
    IndexDescriptor index = tx.schemaRead().index(SchemaDescriptor.forAnyEntityTokens(EntityType.RELATIONSHIP)).next();
    TokenReadSession tokenReadSession = tx.dataRead().tokenReadSession(index);
    tx.dataRead().relationshipTypeScan(tokenReadSession, cursor, IndexQueryConstraints.ordered(indexOrder), new TokenPredicate(label));
}
Also used : TokenReadSession(org.neo4j.internal.kernel.api.TokenReadSession) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 4 with TokenReadSession

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

the class RelationshipTypeIndexCursorTestBase method relationshipTypeScan.

private void relationshipTypeScan(KernelTransaction tx, int label, RelationshipTypeIndexCursor cursor, IndexOrder indexOrder) throws KernelException {
    IndexDescriptor index = tx.schemaRead().indexGetForName("rti");
    TokenReadSession tokenReadSession = tx.dataRead().tokenReadSession(index);
    tx.dataRead().relationshipTypeScan(tokenReadSession, cursor, IndexQueryConstraints.ordered(indexOrder), new TokenPredicate(label));
}
Also used : TokenReadSession(org.neo4j.internal.kernel.api.TokenReadSession) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Aggregations

TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)4 TokenReadSession (org.neo4j.internal.kernel.api.TokenReadSession)4 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)4 Test (org.junit.jupiter.api.Test)1 NodeLabelIndexCursor (org.neo4j.internal.kernel.api.NodeLabelIndexCursor)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1