Search in sources :

Example 1 with StageControl

use of org.neo4j.internal.batchimport.staging.StageControl in project neo4j by neo4j.

the class ProcessRelationshipCountsDataStepTest method instantiateStep.

private static ProcessRelationshipCountsDataStep instantiateStep(int highLabelId, int highRelationshipTypeId, long labelCacheSize, int maxProcessors, long maxMemory) {
    StageControl control = new SimpleStageControl();
    NodeLabelsCache cache = nodeLabelsCache(labelCacheSize);
    Configuration config = mock(Configuration.class);
    when(config.maxNumberOfProcessors()).thenReturn(maxProcessors);
    when(config.maxMemoryUsage()).thenReturn(maxMemory);
    return new ProcessRelationshipCountsDataStep(control, cache, config, highLabelId, highRelationshipTypeId, mock(CountsAccessor.Updater.class), NumberArrayFactories.OFF_HEAP, ProgressReporter.SILENT, PageCacheTracer.NULL, INSTANCE);
}
Also used : SimpleStageControl(org.neo4j.internal.batchimport.staging.SimpleStageControl) SimpleStageControl(org.neo4j.internal.batchimport.staging.SimpleStageControl) StageControl(org.neo4j.internal.batchimport.staging.StageControl) NodeLabelsCache(org.neo4j.internal.batchimport.cache.NodeLabelsCache)

Example 2 with StageControl

use of org.neo4j.internal.batchimport.staging.StageControl in project neo4j by neo4j.

the class UpdateRecordsStepTest method ioThroughputStatDoesNotOverflow.

@Test
void ioThroughputStatDoesNotOverflow() {
    // store with huge record size to force overflow and not create huge batch of records
    RecordStore<NodeRecord> store = mock(RecordStore.class);
    when(store.getRecordSize()).thenReturn(Integer.MAX_VALUE / 2);
    Configuration configuration = mock(Configuration.class);
    StageControl stageControl = mock(StageControl.class);
    UpdateRecordsStep<NodeRecord> step = new UpdateRecordsStep<>(stageControl, configuration, store, new StorePrepareIdSequence(), PageCacheTracer.NULL);
    NodeRecord record = new NodeRecord(1);
    record.setInUse(true);
    NodeRecord[] batch = new NodeRecord[11];
    Arrays.fill(batch, record);
    step.process(batch, mock(BatchSender.class), NULL);
    Stat stat = step.stat(Keys.io_throughput);
    assertThat(stat.asLong()).isGreaterThan(0L);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) BatchSender(org.neo4j.internal.batchimport.staging.BatchSender) StageControl(org.neo4j.internal.batchimport.staging.StageControl) Stat(org.neo4j.internal.batchimport.stats.Stat) StorePrepareIdSequence(org.neo4j.internal.batchimport.store.StorePrepareIdSequence) Test(org.junit.jupiter.api.Test)

Example 3 with StageControl

use of org.neo4j.internal.batchimport.staging.StageControl in project neo4j by neo4j.

the class UpdateRecordsStepTest method recordWithReservedIdIsSkipped.

@Test
void recordWithReservedIdIsSkipped() {
    RecordStore<NodeRecord> store = mock(NodeStore.class);
    StageControl stageControl = mock(StageControl.class);
    UpdateRecordsStep<NodeRecord> step = new UpdateRecordsStep<>(stageControl, Configuration.DEFAULT, store, new StorePrepareIdSequence(), PageCacheTracer.NULL);
    NodeRecord node1 = new NodeRecord(1);
    node1.setInUse(true);
    NodeRecord node2 = new NodeRecord(2);
    node2.setInUse(true);
    NodeRecord nodeWithReservedId = new NodeRecord(INTEGER_MINUS_ONE);
    NodeRecord[] batch = { node1, node2, nodeWithReservedId };
    step.process(batch, mock(BatchSender.class), NULL);
    verify(store).prepareForCommit(eq(node1), any(IdSequence.class), any(CursorContext.class));
    verify(store).updateRecord(eq(node1), any(), any(), any());
    verify(store).prepareForCommit(eq(node2), any(IdSequence.class), any(CursorContext.class));
    verify(store).updateRecord(eq(node2), any(), any(), any());
    verify(store, never()).prepareForCommit(eq(nodeWithReservedId), any(IdSequence.class), any(CursorContext.class));
    verify(store, never()).updateRecord(eq(nodeWithReservedId), any());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) BatchSender(org.neo4j.internal.batchimport.staging.BatchSender) StageControl(org.neo4j.internal.batchimport.staging.StageControl) StorePrepareIdSequence(org.neo4j.internal.batchimport.store.StorePrepareIdSequence) StorePrepareIdSequence(org.neo4j.internal.batchimport.store.StorePrepareIdSequence) IdSequence(org.neo4j.internal.id.IdSequence) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Test(org.junit.jupiter.api.Test)

Aggregations

StageControl (org.neo4j.internal.batchimport.staging.StageControl)3 Test (org.junit.jupiter.api.Test)2 BatchSender (org.neo4j.internal.batchimport.staging.BatchSender)2 StorePrepareIdSequence (org.neo4j.internal.batchimport.store.StorePrepareIdSequence)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 NodeLabelsCache (org.neo4j.internal.batchimport.cache.NodeLabelsCache)1 SimpleStageControl (org.neo4j.internal.batchimport.staging.SimpleStageControl)1 Stat (org.neo4j.internal.batchimport.stats.Stat)1 IdSequence (org.neo4j.internal.id.IdSequence)1 CursorContext (org.neo4j.io.pagecache.context.CursorContext)1