Search in sources :

Example 1 with RelationshipTypePropertyIterator

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

the class TransactionImpl method getRelationshipsByTypeAndPropertyWithoutPropertyIndex.

private ResourceIterator<Relationship> getRelationshipsByTypeAndPropertyWithoutPropertyIndex(KernelTransaction ktx, int typeId, PropertyIndexQuery... queries) {
    var index = findUsableMatchingIndex(ktx, SchemaDescriptor.forAnyEntityTokens(EntityType.RELATIONSHIP));
    if (index != IndexDescriptor.NO_INDEX) {
        try {
            var session = ktx.dataRead().tokenReadSession(index);
            var cursor = ktx.cursors().allocateRelationshipTypeIndexCursor(ktx.cursorContext());
            ktx.dataRead().relationshipTypeScan(session, cursor, unconstrained(), new TokenPredicate(typeId));
            var relationshipScanCursor = ktx.cursors().allocateRelationshipScanCursor(ktx.cursorContext());
            var propertyCursor = ktx.cursors().allocatePropertyCursor(ktx.cursorContext(), ktx.memoryTracker());
            return new RelationshipTypePropertyIterator(ktx.dataRead(), cursor, relationshipScanCursor, propertyCursor, c -> newRelationshipEntity(c.relationshipReference()), coreApiResourceTracker, queries);
        } catch (KernelException e) {
        // ignore, fallback to all node scan
        }
    }
    return getRelationshipsByTypeAndPropertyViaAllRelsScan(ktx, typeId, queries);
}
Also used : RelationshipTypePropertyIterator(org.neo4j.kernel.impl.coreapi.internal.RelationshipTypePropertyIterator) TokenPredicate(org.neo4j.internal.kernel.api.TokenPredicate) 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 RelationshipTypePropertyIterator (org.neo4j.kernel.impl.coreapi.internal.RelationshipTypePropertyIterator)1 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)1