Search in sources :

Example 1 with NodeLabelPropertyIterator

use of org.neo4j.kernel.impl.coreapi.internal.NodeLabelPropertyIterator in project neo4j by neo4j.

the class TransactionImpl method getNodesByLabelAndPropertyWithoutPropertyIndex.

private ResourceIterator<Node> getNodesByLabelAndPropertyWithoutPropertyIndex(KernelTransaction ktx, int labelId, PropertyIndexQuery... queries) {
    var index = findUsableMatchingIndex(ktx, SchemaDescriptor.forAnyEntityTokens(EntityType.NODE));
    if (index != IndexDescriptor.NO_INDEX) {
        try {
            var session = ktx.dataRead().tokenReadSession(index);
            var cursor = ktx.cursors().allocateNodeLabelIndexCursor(ktx.cursorContext());
            ktx.dataRead().nodeLabelScan(session, cursor, unconstrained(), new TokenPredicate(labelId));
            var nodeCursor = ktx.cursors().allocateNodeCursor(ktx.cursorContext());
            var propertyCursor = ktx.cursors().allocatePropertyCursor(ktx.cursorContext(), ktx.memoryTracker());
            return new NodeLabelPropertyIterator(ktx.dataRead(), cursor, nodeCursor, propertyCursor, c -> newNodeEntity(c.nodeReference()), coreApiResourceTracker, queries);
        } catch (KernelException e) {
        // ignore, fallback to all node scan
        }
    }
    return getNodesByLabelAndPropertyViaAllNodesScan(ktx, labelId, queries);
}
Also used : TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) NodeLabelPropertyIterator(org.neo4j.kernel.impl.coreapi.internal.NodeLabelPropertyIterator) InvalidTransactionTypeKernelException(org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) SchemaKernelException(org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException) KernelException(org.neo4j.exceptions.KernelException)

Aggregations

KernelException (org.neo4j.exceptions.KernelException)1 TokenPredicate (org.neo4j.internal.kernel.api.TokenPredicate)1 InvalidTransactionTypeKernelException (org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException)1 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)1 SchemaKernelException (org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException)1 NodeLabelPropertyIterator (org.neo4j.kernel.impl.coreapi.internal.NodeLabelPropertyIterator)1 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)1