Search in sources :

Example 21 with CursorFactory

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

the class FulltextIndexTransactionState method updateSearcher.

private void updateSearcher(QueryContext context, CursorContext cursorContext, MemoryTracker memoryTracker) throws Exception {
    Read read = context.getRead();
    CursorFactory cursors = context.cursors();
    ReadableTransactionState state = context.getTransactionStateOrNull();
    // Clear this, so we don't filter out entities who have had their changes reversed since last time.
    modifiedEntityIdsInThisTransaction.clear();
    writer.resetWriterState();
    try (NodeCursor nodeCursor = visitingNodes ? cursors.allocateFullAccessNodeCursor(cursorContext) : null;
        RelationshipScanCursor relationshipCursor = visitingNodes ? null : cursors.allocateRelationshipScanCursor(cursorContext);
        PropertyCursor propertyCursor = cursors.allocateFullAccessPropertyCursor(cursorContext, memoryTracker)) {
        state.accept(txStateVisitor.init(read, nodeCursor, relationshipCursor, propertyCursor));
    }
    currentSearcher = writer.getNearRealTimeSearcher();
    toCloseLater.add(currentSearcher);
    lastUpdateRevision = state.getDataRevision();
}
Also used : Read(org.neo4j.internal.kernel.api.Read) CursorFactory(org.neo4j.internal.kernel.api.CursorFactory) RelationshipScanCursor(org.neo4j.internal.kernel.api.RelationshipScanCursor) ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) PropertyCursor(org.neo4j.internal.kernel.api.PropertyCursor)

Example 22 with CursorFactory

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

the class CachingExpandIntoTest method shouldComputeDegreeWithoutType.

@Test
void shouldComputeDegreeWithoutType() throws Exception {
    // GIVEN
    long node;
    try (KernelTransaction tx = transaction()) {
        Write write = tx.dataWrite();
        node = nodeWithDegree(tx, 42);
        relate(tx, node, "R1", write.nodeCreate());
        relate(tx, node, "R2", write.nodeCreate());
        relate(tx, write.nodeCreate(), "R3", node);
        relate(tx, node, "R4", node);
        tx.commit();
    }
    try (KernelTransaction tx = transaction()) {
        Read read = tx.dataRead();
        CursorFactory cursors = tx.cursors();
        try (NodeCursor nodes = cursors.allocateNodeCursor(tx.cursorContext())) {
            CachingExpandInto expand = new CachingExpandInto(tx.dataRead(), OUTGOING, MEMORY_TRACKER);
            read.singleNode(node, nodes);
            assertThat(nodes.next()).isEqualTo(true);
            assertThat(nodes.supportsFastDegreeLookup()).isEqualTo(true);
            Degrees degrees = nodes.degrees(ALL_RELATIONSHIPS);
            assertThat(degrees.outgoingDegree()).isEqualTo(45);
            assertThat(degrees.incomingDegree()).isEqualTo(2);
            assertThat(degrees.totalDegree()).isEqualTo(46);
        }
    }
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Write(org.neo4j.internal.kernel.api.Write) Read(org.neo4j.internal.kernel.api.Read) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) CursorFactory(org.neo4j.internal.kernel.api.CursorFactory) Degrees(org.neo4j.storageengine.api.Degrees) NodeCursor(org.neo4j.internal.kernel.api.NodeCursor) Test(org.junit.jupiter.api.Test)

Aggregations

CursorFactory (org.neo4j.internal.kernel.api.CursorFactory)22 Test (org.junit.jupiter.api.Test)21 ExecutorService (java.util.concurrent.ExecutorService)19 LongList (org.eclipse.collections.api.list.primitive.LongList)19 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)13 MutableLongList (org.eclipse.collections.api.list.primitive.MutableLongList)11 Read (org.neo4j.internal.kernel.api.Read)11 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)10 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)10 ArrayList (java.util.ArrayList)9 Future (java.util.concurrent.Future)9 Write (org.neo4j.internal.kernel.api.Write)9 RelationshipScanCursor (org.neo4j.internal.kernel.api.RelationshipScanCursor)8 NodeLabelIndexCursor (org.neo4j.internal.kernel.api.NodeLabelIndexCursor)5 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)3 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)3 LongSet (org.eclipse.collections.api.set.primitive.LongSet)2 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)2 Degrees (org.neo4j.storageengine.api.Degrees)2 PropertyCursor (org.neo4j.internal.kernel.api.PropertyCursor)1