Search in sources :

Example 16 with NeoStores

use of org.neo4j.kernel.impl.store.NeoStores 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 17 with NeoStores

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

the class BatchInserterImplTest method testHonorsPassedInParams.

@Test
public void testHonorsPassedInParams() throws Exception {
    BatchInserter inserter = BatchInserters.inserter(testDirectory.graphDbDir(), fileSystemRule.get(), stringMap(GraphDatabaseSettings.pagecache_memory.name(), "280K"));
    NeoStores neoStores = ReflectionUtil.getPrivateField(inserter, "neoStores", NeoStores.class);
    PageCache pageCache = ReflectionUtil.getPrivateField(neoStores, "pageCache", PageCache.class);
    inserter.shutdown();
    int mappedMemoryTotalSize = pageCache.maxCachedPages() * pageCache.pageSize();
    assertThat("memory mapped config is active", mappedMemoryTotalSize, is(280 * 1024));
}
Also used : BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) NeoStores(org.neo4j.kernel.impl.store.NeoStores) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 18 with NeoStores

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

the class BatchInsertTest method mustSplitUpRelationshipChainsWhenCreatingDenseNodes.

@Test
public void mustSplitUpRelationshipChainsWhenCreatingDenseNodes() throws Exception {
    BatchInserter inserter = globalInserter;
    long node1 = inserter.createNode(null);
    long node2 = inserter.createNode(null);
    for (int i = 0; i < 1000; i++) {
        for (MyRelTypes relType : MyRelTypes.values()) {
            inserter.createRelationship(node1, node2, relType, null);
        }
    }
    NeoStores neoStores = getFlushedNeoStores(inserter);
    NodeRecord record = getRecord(neoStores.getNodeStore(), node1);
    assertTrue("Node " + record + " should have been dense", record.isDense());
}
Also used : BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) MyRelTypes(org.neo4j.kernel.impl.MyRelTypes) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Test(org.junit.Test)

Example 19 with NeoStores

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

the class StoreMigrator method createStore.

private void createStore(File migrationDir, RecordFormats newFormat) {
    StoreFactory storeFactory = new StoreFactory(new File(migrationDir.getPath()), pageCache, fileSystem, newFormat, NullLogProvider.getInstance());
    try (NeoStores neoStores = storeFactory.openAllNeoStores(true)) {
        neoStores.getMetaDataStore();
        neoStores.getLabelTokenStore();
        neoStores.getNodeStore();
        neoStores.getPropertyStore();
        neoStores.getRelationshipGroupStore();
        neoStores.getRelationshipStore();
        neoStores.getSchemaStore();
    }
}
Also used : NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) PagedFile(org.neo4j.io.pagecache.PagedFile) StoreFile(org.neo4j.kernel.impl.storemigration.StoreFile) File(java.io.File)

Example 20 with NeoStores

use of org.neo4j.kernel.impl.store.NeoStores 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

NeoStores (org.neo4j.kernel.impl.store.NeoStores)77 Test (org.junit.Test)48 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)17 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)14 NodeStore (org.neo4j.kernel.impl.store.NodeStore)12 File (java.io.File)11 Transaction (org.neo4j.graphdb.Transaction)11 ArrayList (java.util.ArrayList)9 PageCache (org.neo4j.io.pagecache.PageCache)9 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)9 Node (org.neo4j.graphdb.Node)8 NodeUpdates (org.neo4j.kernel.api.index.NodeUpdates)8 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)8 DependencyResolver (org.neo4j.graphdb.DependencyResolver)7 RelationshipGroupCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)7 BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)6 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)6 NeoStoreBatchTransactionApplier (org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier)6 CacheAccessBackDoor (org.neo4j.kernel.impl.core.CacheAccessBackDoor)5 NodeCommand (org.neo4j.kernel.impl.transaction.command.Command.NodeCommand)5