Search in sources :

Example 1 with NodeStore

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

the class StoreProcessorTaskTest method singlePassShouldOnlyProcessTheStoreOnce.

@Test
public void singlePassShouldOnlyProcessTheStoreOnce() throws Exception {
    // given
    StoreProcessor singlePassProcessor = mock(StoreProcessor.class);
    when(singlePassProcessor.getStage()).thenReturn(Stage.SEQUENTIAL_FORWARD);
    NodeStore store = mock(NodeStore.class);
    when(store.getStorageFileName()).thenReturn(new File("node-store"));
    StoreProcessorTask<NodeRecord> task = new StoreProcessorTask<>("nodes", Statistics.NONE, 1, store, null, "nodes", ProgressMonitorFactory.NONE.multipleParts("check"), CacheAccess.EMPTY, singlePassProcessor, QueueDistribution.ROUND_ROBIN);
    // when
    task.run();
    // then
    verify(singlePassProcessor).applyFiltered(same(store), any(ProgressListener.class));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) ProgressListener(org.neo4j.helpers.progress.ProgressListener) File(java.io.File) Test(org.junit.Test)

Example 2 with NodeStore

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

the class NodeIdReuseStressIT method highestNodeId.

private static long highestNodeId(GraphDatabaseService db) {
    DependencyResolver resolver = dependencyResolver(db);
    NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
    NodeStore nodeStore = neoStores.getNodeStore();
    return nodeStore.getHighestPossibleIdInUse();
}
Also used : NodeStore(org.neo4j.kernel.impl.store.NodeStore) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 3 with NodeStore

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

the class NodeRecordCheckTest method shouldReportOutOfOrderLabels.

@Test
public void shouldReportOutOfOrderLabels() throws Exception {
    // given
    final NodeRecord node = inUse(new NodeRecord(42, false, NONE, NONE));
    // We need to do this override so we can put the labels unsorted, since InlineNodeLabels always sorts on insert
    new InlineNodeLabels(node) {

        @Override
        public Collection<DynamicRecord> put(long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator) {
            return putSorted(node, labelIds, nodeStore, allocator);
        }
    }.put(new long[] { 3, 1, 2 }, null, null);
    LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
    LabelTokenRecord label2 = inUse(new LabelTokenRecord(2));
    LabelTokenRecord label3 = inUse(new LabelTokenRecord(3));
    add(label1);
    add(label2);
    add(label3);
    add(node);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).labelsOutOfOrder(3, 1);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) InlineNodeLabels(org.neo4j.kernel.impl.store.InlineNodeLabels) DynamicRecordAllocator(org.neo4j.kernel.impl.store.DynamicRecordAllocator) NodeStore(org.neo4j.kernel.impl.store.NodeStore) Collection(java.util.Collection) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 4 with NodeStore

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

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

NodeStore (org.neo4j.kernel.impl.store.NodeStore)42 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)28 NeoStores (org.neo4j.kernel.impl.store.NeoStores)12 Test (org.junit.jupiter.api.Test)10 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)10 Test (org.junit.Test)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)8 ArrayList (java.util.ArrayList)7 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)6 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)6 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)6 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)5 ValueSource (org.junit.jupiter.params.provider.ValueSource)4 CountsComputer (org.neo4j.kernel.impl.store.CountsComputer)4 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)4 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)4 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)4 Value (org.neo4j.values.storable.Value)4 BatchingNeoStores (org.neo4j.internal.batchimport.store.BatchingNeoStores)3