Search in sources :

Example 1 with RelationshipStore

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

the class StoreNodeRelationshipCursorTest method createNodeRelationships.

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

Example 2 with RelationshipStore

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

the class StoreSingleRelationshipCursorTest method retrieveUnusedRelationship.

@Test
public void retrieveUnusedRelationship() {
    RelationshipStore relationshipStore = neoStores.getRelationshipStore();
    relationshipStore.setHighId(10);
    createRelationshipRecord(relationshipStore, false);
    try (StoreSingleRelationshipCursor cursor = createRelationshipCursor()) {
        cursor.init(RELATIONSHIP_ID);
        assertFalse(cursor.next());
    }
}
Also used : RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) Test(org.junit.Test)

Example 3 with RelationshipStore

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

the class StoreSingleRelationshipCursorTest method retrieveUsedRelationship.

@Test
public void retrieveUsedRelationship() throws Exception {
    RelationshipStore relationshipStore = neoStores.getRelationshipStore();
    createRelationshipRecord(relationshipStore, true);
    try (StoreSingleRelationshipCursor cursor = createRelationshipCursor()) {
        cursor.init(RELATIONSHIP_ID);
        assertTrue(cursor.next());
        assertEquals(RELATIONSHIP_ID, cursor.get().id());
    }
}
Also used : RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) Test(org.junit.Test)

Example 4 with RelationshipStore

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

the class MockedNeoStores method basicMockedNeoStores.

@SuppressWarnings({ "unchecked", "rawtypes" })
public static NeoStores basicMockedNeoStores() {
    NeoStores neoStores = mock(NeoStores.class);
    // Cursor, absolutely mocked and cannot be used at all as it is
    RecordCursor cursor = mockedRecordCursor();
    // NodeStore - DynamicLabelStore
    NodeStore nodeStore = mock(NodeStore.class);
    when(nodeStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    // NodeStore - DynamicLabelStore
    DynamicArrayStore dynamicLabelStore = mock(DynamicArrayStore.class);
    when(dynamicLabelStore.newRecordCursor(any())).thenReturn(cursor);
    when(nodeStore.getDynamicLabelStore()).thenReturn(dynamicLabelStore);
    // RelationshipStore
    RelationshipStore relationshipStore = mock(RelationshipStore.class);
    when(relationshipStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getRelationshipStore()).thenReturn(relationshipStore);
    // RelationshipGroupStore
    RelationshipGroupStore relationshipGroupStore = mock(RelationshipGroupStore.class);
    when(relationshipGroupStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getRelationshipGroupStore()).thenReturn(relationshipGroupStore);
    // PropertyStore
    PropertyStore propertyStore = mock(PropertyStore.class);
    when(propertyStore.newRecordCursor(any())).thenReturn(cursor);
    when(neoStores.getPropertyStore()).thenReturn(propertyStore);
    // PropertyStore -- DynamicStringStore
    DynamicStringStore propertyStringStore = mock(DynamicStringStore.class);
    when(propertyStringStore.newRecordCursor(any())).thenReturn(cursor);
    when(propertyStore.getStringStore()).thenReturn(propertyStringStore);
    // PropertyStore -- DynamicArrayStore
    DynamicArrayStore propertyArrayStore = mock(DynamicArrayStore.class);
    when(propertyArrayStore.newRecordCursor(any())).thenReturn(cursor);
    when(propertyStore.getArrayStore()).thenReturn(propertyArrayStore);
    return neoStores;
}
Also used : RecordCursor(org.neo4j.kernel.impl.store.RecordCursor) NodeStore(org.neo4j.kernel.impl.store.NodeStore) DynamicStringStore(org.neo4j.kernel.impl.store.DynamicStringStore) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) DynamicArrayStore(org.neo4j.kernel.impl.store.DynamicArrayStore) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore)

Example 5 with RelationshipStore

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

the class StoreMigrator method rebuildCountsFromScratch.

private void rebuildCountsFromScratch(File storeDir, long lastTxId, PageCache pageCache) {
    final File storeFileBase = new File(storeDir, MetaDataStore.DEFAULT_NAME + StoreFactory.COUNTS_STORE);
    StoreFactory storeFactory = new StoreFactory(storeDir, pageCache, fileSystem, NullLogProvider.getInstance());
    try (NeoStores neoStores = storeFactory.openAllNeoStores()) {
        NodeStore nodeStore = neoStores.getNodeStore();
        RelationshipStore relationshipStore = neoStores.getRelationshipStore();
        try (Lifespan life = new Lifespan()) {
            int highLabelId = (int) neoStores.getLabelTokenStore().getHighId();
            int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId();
            CountsComputer initializer = new CountsComputer(lastTxId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId);
            life.add(new CountsTracker(logService.getInternalLogProvider(), fileSystem, pageCache, config, storeFileBase).setInitializer(initializer));
        }
    }
}
Also used : NodeStore(org.neo4j.kernel.impl.store.NodeStore) CountsComputer(org.neo4j.kernel.impl.store.CountsComputer) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) PagedFile(org.neo4j.io.pagecache.PagedFile) StoreFile(org.neo4j.kernel.impl.storemigration.StoreFile) File(java.io.File) Lifespan(org.neo4j.kernel.lifecycle.Lifespan)

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