Search in sources :

Example 1 with BatchingNeoStores

use of org.neo4j.internal.batchimport.store.BatchingNeoStores in project neo4j by neo4j.

the class ImportLogicTest method closeImporterWithoutDiagnosticState.

@Test
void closeImporterWithoutDiagnosticState() throws IOException {
    ExecutionMonitor monitor = mock(ExecutionMonitor.class);
    IndexImporterFactory factory = mock(IndexImporterFactory.class);
    try (BatchingNeoStores stores = batchingNeoStoresWithExternalPageCache(fileSystem, pageCache, NULL, databaseLayout, defaultFormat(), DEFAULT, getInstance(), AdditionalInitialIds.EMPTY, defaults(), INSTANCE)) {
        // noinspection EmptyTryBlock
        try (ImportLogic logic = new ImportLogic(databaseLayout, stores, DEFAULT, defaults(), getInstance(), monitor, defaultFormat(), Collector.EMPTY, NO_MONITOR, NULL, factory, EmptyMemoryTracker.INSTANCE)) {
            // nothing to run in this import
            logic.success();
        }
    }
    verify(monitor).done(eq(true), anyLong(), contains("Data statistics is not available."));
}
Also used : BatchingNeoStores(org.neo4j.internal.batchimport.store.BatchingNeoStores) ExecutionMonitor(org.neo4j.internal.batchimport.staging.ExecutionMonitor) Test(org.junit.jupiter.api.Test)

Example 2 with BatchingNeoStores

use of org.neo4j.internal.batchimport.store.BatchingNeoStores in project neo4j by neo4j.

the class NodeImporterTest method shouldHandleLargeAmountsOfLabels.

@Test
void shouldHandleLargeAmountsOfLabels() throws IOException {
    // given
    IdMapper idMapper = mock(IdMapper.class);
    JobScheduler scheduler = new ThreadPoolJobScheduler();
    try (Lifespan life = new Lifespan(scheduler);
        BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache(fs, pageCache, NULL, layout, Standard.LATEST_RECORD_FORMATS, Configuration.DEFAULT, NullLogService.getInstance(), AdditionalInitialIds.EMPTY, Config.defaults(), INSTANCE)) {
        stores.createNew();
        // when
        int numberOfLabels = 50;
        long nodeId = 0;
        try (NodeImporter importer = new NodeImporter(stores, idMapper, new DataImporter.Monitor(), NULL, INSTANCE)) {
            importer.id(nodeId);
            String[] labels = new String[numberOfLabels];
            for (int i = 0; i < labels.length; i++) {
                labels[i] = "Label" + i;
            }
            importer.labels(labels);
            importer.endOfEntity();
        }
        // then
        NodeStore nodeStore = stores.getNodeStore();
        NodeRecord record = nodeStore.getRecord(nodeId, nodeStore.newRecord(), RecordLoad.NORMAL, CursorContext.NULL);
        long[] labels = NodeLabelsField.parseLabelsField(record).get(nodeStore, CursorContext.NULL);
        assertEquals(numberOfLabels, labels.length);
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) BatchingNeoStores(org.neo4j.internal.batchimport.store.BatchingNeoStores) IdMapper(org.neo4j.internal.batchimport.cache.idmapping.IdMapper) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) Test(org.junit.jupiter.api.Test)

Example 3 with BatchingNeoStores

use of org.neo4j.internal.batchimport.store.BatchingNeoStores in project neo4j by neo4j.

the class HumanUnderstandableExecutionMonitor method initialize.

@Override
public void initialize(DependencyResolver dependencyResolver) {
    this.dependencyResolver = dependencyResolver;
    Input.Estimates estimates = dependencyResolver.resolveDependency(Input.Estimates.class);
    BatchingNeoStores neoStores = dependencyResolver.resolveDependency(BatchingNeoStores.class);
    IdMapper idMapper = dependencyResolver.resolveDependency(IdMapper.class);
    pageCacheArrayFactoryMonitor = dependencyResolver.resolveDependency(PageCacheArrayFactoryMonitor.class);
    long biggestCacheMemory = estimatedCacheSize(neoStores, NodeRelationshipCache.memoryEstimation(estimates.numberOfNodes()), idMapper.memoryEstimation(estimates.numberOfNodes()));
    System.out.println();
    printStageHeader("Import starting", ESTIMATED_NUMBER_OF_NODES, count(estimates.numberOfNodes()), ESTIMATED_NUMBER_OF_NODE_PROPERTIES, count(estimates.numberOfNodeProperties()), ESTIMATED_NUMBER_OF_RELATIONSHIPS, count(estimates.numberOfRelationships()), ESTIMATED_NUMBER_OF_RELATIONSHIP_PROPERTIES, count(estimates.numberOfRelationshipProperties()), ESTIMATED_DISK_SPACE_USAGE, bytesToString(nodesDiskUsage(estimates, neoStores) + relationshipsDiskUsage(estimates, neoStores) + estimates.sizeOfNodeProperties() + estimates.sizeOfRelationshipProperties()), ESTIMATED_REQUIRED_MEMORY_USAGE, bytesToString(biggestCacheMemory));
    System.out.println();
}
Also used : Input(org.neo4j.internal.batchimport.input.Input) BatchingNeoStores(org.neo4j.internal.batchimport.store.BatchingNeoStores) PageCacheArrayFactoryMonitor(org.neo4j.internal.batchimport.cache.PageCacheArrayFactoryMonitor) IdMapper(org.neo4j.internal.batchimport.cache.idmapping.IdMapper)

Example 4 with BatchingNeoStores

use of org.neo4j.internal.batchimport.store.BatchingNeoStores in project neo4j by neo4j.

the class ImportLogicTest method shouldUseDataStatisticsCountsForPrintingFinalStats.

@Test
void shouldUseDataStatisticsCountsForPrintingFinalStats() throws IOException {
    // given
    ExecutionMonitor monitor = mock(ExecutionMonitor.class);
    IndexImporterFactory factory = mock(IndexImporterFactory.class);
    try (BatchingNeoStores stores = batchingNeoStoresWithExternalPageCache(fileSystem, pageCache, NULL, databaseLayout, defaultFormat(), DEFAULT, getInstance(), AdditionalInitialIds.EMPTY, defaults(), INSTANCE)) {
        // when
        DataStatistics.RelationshipTypeCount[] relationshipTypeCounts = new DataStatistics.RelationshipTypeCount[] { new DataStatistics.RelationshipTypeCount(0, 33), new DataStatistics.RelationshipTypeCount(1, 66) };
        DataStatistics dataStatistics = new DataStatistics(100123, 100456, relationshipTypeCounts);
        try (ImportLogic logic = new ImportLogic(databaseLayout, stores, DEFAULT, defaults(), getInstance(), monitor, defaultFormat(), Collector.EMPTY, NO_MONITOR, NULL, factory, EmptyMemoryTracker.INSTANCE)) {
            logic.putState(dataStatistics);
            logic.success();
        }
        // then
        verify(monitor).done(eq(true), anyLong(), contains(dataStatistics.toString()));
    }
}
Also used : BatchingNeoStores(org.neo4j.internal.batchimport.store.BatchingNeoStores) ExecutionMonitor(org.neo4j.internal.batchimport.staging.ExecutionMonitor) Test(org.junit.jupiter.api.Test)

Example 5 with BatchingNeoStores

use of org.neo4j.internal.batchimport.store.BatchingNeoStores in project neo4j by neo4j.

the class NodeImporterTest method tracePageCacheAccessOnNodeImport.

@Test
void tracePageCacheAccessOnNodeImport() throws IOException {
    JobScheduler scheduler = new ThreadPoolJobScheduler();
    try (Lifespan life = new Lifespan(scheduler);
        BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache(fs, pageCache, NULL, layout, Standard.LATEST_RECORD_FORMATS, Configuration.DEFAULT, NullLogService.getInstance(), AdditionalInitialIds.EMPTY, Config.defaults(), INSTANCE)) {
        stores.createNew();
        int numberOfLabels = 50;
        long nodeId = 0;
        var cacheTracer = new DefaultPageCacheTracer();
        try (NodeImporter importer = new NodeImporter(stores, IdMappers.actual(), new DataImporter.Monitor(), cacheTracer, INSTANCE)) {
            importer.id(nodeId);
            String[] labels = new String[numberOfLabels];
            for (int i = 0; i < labels.length; i++) {
                labels[i] = "Label" + i;
            }
            importer.labels(labels);
            importer.property("a", randomAscii(10));
            importer.property("b", randomAscii(100));
            importer.property("c", randomAscii(1000));
            importer.endOfEntity();
        }
        NodeStore nodeStore = stores.getNodeStore();
        NodeRecord record = nodeStore.getRecord(nodeId, nodeStore.newRecord(), RecordLoad.NORMAL, CursorContext.NULL);
        long[] labels = NodeLabelsField.parseLabelsField(record).get(nodeStore, CursorContext.NULL);
        assertEquals(numberOfLabels, labels.length);
        assertThat(cacheTracer.faults()).isEqualTo(2);
        assertThat(cacheTracer.pins()).isEqualTo(13);
        assertThat(cacheTracer.unpins()).isEqualTo(13);
        assertThat(cacheTracer.hits()).isEqualTo(11);
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) BatchingNeoStores(org.neo4j.internal.batchimport.store.BatchingNeoStores) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Aggregations

BatchingNeoStores (org.neo4j.internal.batchimport.store.BatchingNeoStores)7 Test (org.junit.jupiter.api.Test)5 NodeStore (org.neo4j.kernel.impl.store.NodeStore)3 PageCacheArrayFactoryMonitor (org.neo4j.internal.batchimport.cache.PageCacheArrayFactoryMonitor)2 IdMapper (org.neo4j.internal.batchimport.cache.idmapping.IdMapper)2 ExecutionMonitor (org.neo4j.internal.batchimport.staging.ExecutionMonitor)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)2 JobScheduler (org.neo4j.scheduler.JobScheduler)2 ThreadPoolJobScheduler (org.neo4j.test.scheduler.ThreadPoolJobScheduler)2 Dependencies (org.neo4j.collection.Dependencies)1 DataStatistics (org.neo4j.internal.batchimport.DataStatistics)1 Input (org.neo4j.internal.batchimport.input.Input)1 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)1 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)1