Search in sources :

Example 16 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class EstimationSanityCheckerTest method shouldWarnAboutCountGettingCloseToCapacity.

@Test
void shouldWarnAboutCountGettingCloseToCapacity() {
    // given
    RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
    ImportLogic.Monitor monitor = mock(ImportLogic.Monitor.class);
    Input.Estimates estimates = Input.knownEstimates(formats.node().getMaxId() - 1000, formats.relationship().getMaxId() - 1000, 0, 0, 0, 0, // we don't care about the rest of the estimates in this checking
    0);
    // when
    new EstimationSanityChecker(formats, monitor).sanityCheck(estimates);
    // then
    verify(monitor).mayExceedNodeIdCapacity(formats.node().getMaxId(), estimates.numberOfNodes());
    verify(monitor).mayExceedRelationshipIdCapacity(formats.relationship().getMaxId(), estimates.numberOfRelationships());
}
Also used : ImportLogic(org.neo4j.internal.batchimport.ImportLogic) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Test(org.junit.jupiter.api.Test)

Example 17 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class EstimationSanityCheckerTest method shouldNotWantIfCountWayLowerThanCapacity.

@Test
void shouldNotWantIfCountWayLowerThanCapacity() {
    // given
    RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
    ImportLogic.Monitor monitor = mock(ImportLogic.Monitor.class);
    Input.Estimates estimates = Input.knownEstimates(1000, 1000, 0, 0, 0, 0, // we don't care about the rest of the estimates in this checking
    0);
    // when
    new EstimationSanityChecker(formats, monitor).sanityCheck(estimates);
    // then
    verifyNoMoreInteractions(monitor);
}
Also used : ImportLogic(org.neo4j.internal.batchimport.ImportLogic) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Test(org.junit.jupiter.api.Test)

Example 18 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class CsvInputEstimateCalculationIT method shouldCalculateCorrectEstimates.

@Test
void shouldCalculateCorrectEstimates() throws Exception {
    // given a couple of input files of various layouts
    Input input = generateData();
    RecordFormats format = LATEST_RECORD_FORMATS;
    Input.Estimates estimates = input.calculateEstimates(new PropertyValueRecordSizeCalculator(format.property().getRecordSize(NO_STORE_HEADER), GraphDatabaseInternalSettings.string_block_size.defaultValue(), 0, GraphDatabaseInternalSettings.array_block_size.defaultValue(), 0));
    // when
    Config config = Config.defaults();
    FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
    try (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
        new ParallelBatchImporter(databaseLayout, fs, PageCacheTracer.NULL, PBI_CONFIG, NullLogService.getInstance(), INVISIBLE, EMPTY, config, format, ImportLogic.NO_MONITOR, jobScheduler, Collector.EMPTY, LogFilesInitializer.NULL, IndexImporterFactory.EMPTY, EmptyMemoryTracker.INSTANCE).doImport(input);
        // then compare estimates with actual disk sizes
        SingleFilePageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory(fs);
        try (PageCache pageCache = new MuninnPageCache(swapperFactory, jobScheduler, MuninnPageCache.config(1000));
            NeoStores stores = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable()).openAllNeoStores()) {
            assertRoughlyEqual(estimates.numberOfNodes(), stores.getNodeStore().getNumberOfIdsInUse());
            assertRoughlyEqual(estimates.numberOfRelationships(), stores.getRelationshipStore().getNumberOfIdsInUse());
            assertRoughlyEqual(estimates.numberOfNodeProperties() + estimates.numberOfRelationshipProperties(), calculateNumberOfProperties(stores));
        }
        long measuredPropertyStorage = propertyStorageSize();
        long estimatedPropertyStorage = estimates.sizeOfNodeProperties() + estimates.sizeOfRelationshipProperties();
        assertThat(estimatedPropertyStorage).as("Estimated property storage size of %s must be within 10%% of the measured size of %s.", bytesToString(estimatedPropertyStorage), bytesToString(measuredPropertyStorage)).isCloseTo(measuredPropertyStorage, withPercentage(10.0));
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) ParallelBatchImporter(org.neo4j.internal.batchimport.ParallelBatchImporter) Input(org.neo4j.internal.batchimport.input.Input) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) NeoStores(org.neo4j.kernel.impl.store.NeoStores) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) PropertyValueRecordSizeCalculator(org.neo4j.kernel.impl.store.PropertyValueRecordSizeCalculator) PageCache(org.neo4j.io.pagecache.PageCache) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) Test(org.junit.jupiter.api.Test)

Example 19 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class PageAlignedTest method shouldNotSeeAlignedAndStandardAsEqualFormats.

@Test
void shouldNotSeeAlignedAndStandardAsEqualFormats() {
    // given
    RecordFormats aligned = PageAligned.LATEST_RECORD_FORMATS;
    RecordFormats standard = Standard.LATEST_RECORD_FORMATS;
    // when/then
    assertNotEquals(aligned, standard, RecordFormats::node);
    assertNotEquals(aligned, standard, RecordFormats::dynamic);
    assertNotEquals(aligned, standard, RecordFormats::labelToken);
    assertNotEquals(aligned, standard, RecordFormats::property);
    assertNotEquals(aligned, standard, RecordFormats::propertyKeyToken);
    assertNotEquals(aligned, standard, RecordFormats::relationship);
    assertNotEquals(aligned, standard, RecordFormats::relationshipGroup);
    assertNotEquals(aligned, standard, RecordFormats::relationshipTypeToken);
    assertNotEquals(aligned, standard, RecordFormats::schema);
// don't check meta data format because it had never even filled one page and it has been made page-aligned by default anyway
}
Also used : RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Test(org.junit.jupiter.api.Test)

Example 20 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class StoreFactoryTest method storeFactory.

private StoreFactory storeFactory(Config config, PageCacheTracer pageCacheTracer, ImmutableSet<OpenOption> openOptions) {
    LogProvider logProvider = NullLogProvider.getInstance();
    RecordFormats recordFormats = selectForStoreOrConfig(config, databaseLayout, fileSystem, pageCache, logProvider, NULL);
    return new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fileSystem, recordFormats, logProvider, pageCacheTracer, writable(), openOptions);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats)

Aggregations

RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)43 Test (org.junit.jupiter.api.Test)13 IOException (java.io.IOException)10 Config (org.neo4j.configuration.Config)8 PageCache (org.neo4j.io.pagecache.PageCache)8 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)7 NullLogProvider (org.neo4j.logging.NullLogProvider)7 Config (org.neo4j.kernel.configuration.Config)6 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)6 File (java.io.File)5 Path (java.nio.file.Path)5 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)5 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 ForcedSecondaryUnitRecordFormats (org.neo4j.kernel.impl.store.format.ForcedSecondaryUnitRecordFormats)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)4 PagedFile (org.neo4j.io.pagecache.PagedFile)4 LogProvider (org.neo4j.logging.LogProvider)4 NoSuchFileException (java.nio.file.NoSuchFileException)3