Search in sources :

Example 11 with RelationshipValueIndexCursor

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

the class ManagedTestCursors method allocateRelationshipValueIndexCursor.

@Override
public RelationshipValueIndexCursor allocateRelationshipValueIndexCursor(CursorContext cursorContext, MemoryTracker memoryTracker) {
    RelationshipValueIndexCursor n = cursors.allocateRelationshipValueIndexCursor(cursorContext, memoryTracker);
    allCursors.add(n);
    return n;
}
Also used : RelationshipValueIndexCursor(org.neo4j.internal.kernel.api.RelationshipValueIndexCursor)

Example 12 with RelationshipValueIndexCursor

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

the class FulltextIndexProviderTest method verifyRelationshipData.

private void verifyRelationshipData(long secondRelId) throws Exception {
    try (Transaction tx = db.beginTx()) {
        KernelTransaction ktx = LuceneFulltextTestSupport.kernelTransaction(tx);
        IndexDescriptor index = ktx.schemaRead().indexGetForName("fulltext");
        IndexReadSession indexReadSession = ktx.dataRead().indexReadSession(index);
        try (RelationshipValueIndexCursor cursor = ktx.cursors().allocateRelationshipValueIndexCursor(ktx.cursorContext(), ktx.memoryTracker())) {
            ktx.dataRead().relationshipIndexSeek(indexReadSession, cursor, unconstrained(), fulltextSearch("valuuu"));
            assertTrue(cursor.next());
            assertEquals(0L, cursor.relationshipReference());
            assertFalse(cursor.next());
            ktx.dataRead().relationshipIndexSeek(indexReadSession, cursor, unconstrained(), fulltextSearch("villa"));
            assertTrue(cursor.next());
            assertEquals(secondRelId, cursor.relationshipReference());
            assertFalse(cursor.next());
            ktx.dataRead().relationshipIndexSeek(indexReadSession, cursor, unconstrained(), fulltextSearch("value3"));
            assertTrue(cursor.next());
            assertEquals(0L, cursor.relationshipReference());
            assertTrue(cursor.next());
            assertEquals(secondRelId, cursor.relationshipReference());
            assertFalse(cursor.next());
        }
        tx.commit();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipValueIndexCursor(org.neo4j.internal.kernel.api.RelationshipValueIndexCursor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession)

Example 13 with RelationshipValueIndexCursor

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

the class RelationshipTypeIndexIT method countRelationshipsInFulltextIndex.

private int countRelationshipsInFulltextIndex(String indexName) throws KernelException {
    int relationshipsInIndex;
    try (Transaction transaction = db.beginTx()) {
        KernelTransaction ktx = ((InternalTransaction) transaction).kernelTransaction();
        IndexDescriptor index = ktx.schemaRead().indexGetForName(indexName);
        IndexReadSession indexReadSession = ktx.dataRead().indexReadSession(index);
        relationshipsInIndex = 0;
        try (RelationshipValueIndexCursor cursor = ktx.cursors().allocateRelationshipValueIndexCursor(ktx.cursorContext(), ktx.memoryTracker())) {
            ktx.dataRead().relationshipIndexSeek(indexReadSession, cursor, unconstrained(), fulltextSearch("*"));
            while (cursor.next()) {
                relationshipsInIndex++;
            }
        }
    }
    return relationshipsInIndex;
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) RelationshipValueIndexCursor(org.neo4j.internal.kernel.api.RelationshipValueIndexCursor) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexReadSession(org.neo4j.internal.kernel.api.IndexReadSession)

Aggregations

RelationshipValueIndexCursor (org.neo4j.internal.kernel.api.RelationshipValueIndexCursor)13 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)12 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)9 Test (org.junit.jupiter.api.Test)5 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)5 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)3 Transaction (org.neo4j.graphdb.Transaction)2 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)2 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)2 Consumer (java.util.function.Consumer)1 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)1 EntityType (org.neo4j.common.EntityType)1 KernelException (org.neo4j.exceptions.KernelException)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1 RelationshipType (org.neo4j.graphdb.RelationshipType)1 IndexQueryConstraints (org.neo4j.internal.kernel.api.IndexQueryConstraints)1 NodeValueIndexCursor (org.neo4j.internal.kernel.api.NodeValueIndexCursor)1 Read (org.neo4j.internal.kernel.api.Read)1