Search in sources :

Example 11 with RelationshipStore

use of org.neo4j.kernel.impl.store.RelationshipStore in project neo4j by neo4j.

the class StoreIteratorRelationshipCursorTest method getRelationshipStore.

private RelationshipStore getRelationshipStore(RelationshipRecord relationshipRecord, RecordCursor recordCursor) {
    RelationshipStore relationshipStore = mock(RelationshipStore.class);
    when(recordCursor.acquire(anyLong(), any())).thenReturn(recordCursor);
    when(relationshipStore.newRecord()).thenReturn(relationshipRecord);
    when(relationshipStore.newRecordCursor(relationshipRecord)).thenReturn(recordCursor);
    return relationshipStore;
}
Also used : RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore)

Example 12 with RelationshipStore

use of org.neo4j.kernel.impl.store.RelationshipStore in project neo4j by neo4j.

the class StoreIteratorRelationshipCursorTest method retrieveUnusedRelationship.

@Test
public void retrieveUnusedRelationship() {
    final RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
    RecordCursor recordCursor = mock(RecordCursor.class);
    RelationshipStore relationshipStore = getRelationshipStore(relationshipRecord, recordCursor);
    when(recordCursor.next(RELATIONSHIP_ID, relationshipRecord, RecordLoad.CHECK)).thenAnswer(new RelationshipAnswer(relationshipRecord, false));
    try (StoreIteratorRelationshipCursor cursor = createRelationshipCursor(relationshipRecord, relationshipStore)) {
        cursor.init(PrimitiveLongCollections.iterator(RELATIONSHIP_ID));
        assertTrue(cursor.next());
        assertEquals(RELATIONSHIP_ID, cursor.get().id());
    }
}
Also used : RecordCursor(org.neo4j.kernel.impl.store.RecordCursor) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) Test(org.junit.Test)

Example 13 with RelationshipStore

use of org.neo4j.kernel.impl.store.RelationshipStore in project neo4j by neo4j.

the class StoreIteratorRelationshipCursorTest method retrieveUsedRelationship.

@Test
public void retrieveUsedRelationship() throws Exception {
    final RelationshipRecord relationshipRecord = new RelationshipRecord(-1);
    RecordCursor recordCursor = mock(RecordCursor.class);
    RelationshipStore relationshipStore = getRelationshipStore(relationshipRecord, recordCursor);
    when(recordCursor.next(RELATIONSHIP_ID, relationshipRecord, RecordLoad.CHECK)).thenAnswer(new RelationshipAnswer(relationshipRecord, true));
    try (StoreIteratorRelationshipCursor cursor = createRelationshipCursor(relationshipRecord, relationshipStore)) {
        cursor.init(PrimitiveLongCollections.iterator(RELATIONSHIP_ID));
        assertTrue(cursor.next());
        assertEquals(RELATIONSHIP_ID, cursor.get().id());
    }
}
Also used : RecordCursor(org.neo4j.kernel.impl.store.RecordCursor) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) Test(org.junit.Test)

Example 14 with RelationshipStore

use of org.neo4j.kernel.impl.store.RelationshipStore in project neo4j by neo4j.

the class StoreNodeRelationshipCursorTest method createRelationshipChain.

private void createRelationshipChain(int recordsInChain) {
    RelationshipStore relationshipStore = neoStores.getRelationshipStore();
    for (int i = 1; i < recordsInChain; i++) {
        relationshipStore.updateRecord(createRelationship(i, i + 1));
    }
    relationshipStore.updateRecord(createRelationship(recordsInChain, NO_NEXT_RELATIONSHIP.intValue()));
    if (dense) {
        RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore();
        for (int i = 1; i < recordsInChain; i++) {
            relationshipGroupStore.updateRecord(createRelationshipGroup(i, i));
        }
        relationshipGroupStore.updateRecord(createRelationshipGroup(recordsInChain, NO_NEXT_RELATIONSHIP.intValue()));
    }
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore)

Example 15 with RelationshipStore

use of org.neo4j.kernel.impl.store.RelationshipStore in project neo4j by neo4j.

the class StoreNodeRelationshipCursorTest method unUseRecord.

private void unUseRecord(long recordId) {
    RelationshipStore relationshipStore = neoStores.getRelationshipStore();
    RelationshipRecord relationshipRecord = relationshipStore.getRecord(recordId, new RelationshipRecord(-1), RecordLoad.FORCE);
    relationshipRecord.setInUse(false);
    relationshipStore.updateRecord(relationshipRecord);
}
Also used : RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord)

Aggregations

RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)16 Test (org.junit.Test)6 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)6 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 NodeStore (org.neo4j.kernel.impl.store.NodeStore)3 RecordCursor (org.neo4j.kernel.impl.store.RecordCursor)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 Node (org.neo4j.graphdb.Node)2 Transaction (org.neo4j.graphdb.Transaction)2 CountsComputer (org.neo4j.kernel.impl.store.CountsComputer)2 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)2 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)2 File (java.io.File)1 IOException (java.io.IOException)1 PrimitiveLongIterator (org.neo4j.collection.primitive.PrimitiveLongIterator)1 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 DependencyResolver (org.neo4j.graphdb.DependencyResolver)1 Relationship (org.neo4j.graphdb.Relationship)1