Search in sources :

Example 6 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 7 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 8 with NodeStore

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

the class ReadRecordsStepTest method reservedIdIsSkipped.

@Test
public void reservedIdIsSkipped() {
    long highId = 5;
    int batchSize = (int) highId;
    org.neo4j.unsafe.impl.batchimport.Configuration config = withBatchSize(DEFAULT, batchSize);
    NodeStore store = StoreWithReservedId.newNodeStoreMock(highId);
    when(store.getHighId()).thenReturn(highId);
    when(store.getRecordsPerPage()).thenReturn(10);
    ReadRecordsStep<NodeRecord> step = new ReadRecordsStep<>(mock(StageControl.class), config, store, allIn(store, config));
    step.start(0);
    Object batch = step.nextBatchOrNull(0, batchSize);
    assertNotNull(batch);
    NodeRecord[] records = (NodeRecord[]) batch;
    boolean hasRecordWithReservedId = Stream.of(records).anyMatch(recordWithReservedId());
    assertFalse("Batch contains record with reserved id " + Arrays.toString(records), hasRecordWithReservedId);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) Test(org.junit.Test)

Example 9 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 10 with NodeStore

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

the class NodeRecordCheckTest method shouldProperlyReportOutOfOrderLabelsThatAreFarAway.

@Test
public void shouldProperlyReportOutOfOrderLabelsThatAreFarAway() 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[] { 1, 18, 13, 14, 15, 16, 12 }, null, null);
    LabelTokenRecord label1 = inUse(new LabelTokenRecord(1));
    LabelTokenRecord label12 = inUse(new LabelTokenRecord(12));
    LabelTokenRecord label13 = inUse(new LabelTokenRecord(13));
    LabelTokenRecord label14 = inUse(new LabelTokenRecord(14));
    LabelTokenRecord label15 = inUse(new LabelTokenRecord(15));
    LabelTokenRecord label16 = inUse(new LabelTokenRecord(16));
    LabelTokenRecord label18 = inUse(new LabelTokenRecord(18));
    add(label1);
    add(label12);
    add(label13);
    add(label14);
    add(label15);
    add(label16);
    add(label18);
    add(node);
    // when
    ConsistencyReport.NodeConsistencyReport report = check(node);
    // then
    verify(report).labelsOutOfOrder(18, 13);
    verify(report).labelsOutOfOrder(16, 12);
}
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)

Aggregations

NodeStore (org.neo4j.kernel.impl.store.NodeStore)19 Test (org.junit.Test)10 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)10 NeoStores (org.neo4j.kernel.impl.store.NeoStores)9 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)4 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)2 IndexEntryUpdate (org.neo4j.kernel.api.index.IndexEntryUpdate)2 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)2 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)2 CountsComputer (org.neo4j.kernel.impl.store.CountsComputer)2 DynamicArrayStore (org.neo4j.kernel.impl.store.DynamicArrayStore)2 DynamicRecordAllocator (org.neo4j.kernel.impl.store.DynamicRecordAllocator)2 DynamicStringStore (org.neo4j.kernel.impl.store.DynamicStringStore)2 InlineNodeLabels (org.neo4j.kernel.impl.store.InlineNodeLabels)2 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)2