use of org.neo4j.internal.id.DefaultIdGeneratorFactory 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));
}
}
use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class RecordStorageMigratorIT method shouldKeepCheckpointLogVersionIfPresentBeforeMigration.
@ParameterizedTest
@MethodSource("versions")
void shouldKeepCheckpointLogVersionIfPresentBeforeMigration(String version, LogPosition expectedLogPosition, Function<TransactionId, Boolean> txIdComparator) throws Exception {
// given
Path prepare = testDirectory.directory("prepare");
var fs = testDirectory.getFileSystem();
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, databaseLayout.databaseDirectory(), prepare);
RecordStoreVersionCheck check = getVersionCheck(pageCache, databaseLayout);
String versionToMigrateFrom = getVersionToMigrateFrom(check);
String versionToMigrateTo = getVersionToMigrateTo(check);
// explicitly set a checkpoint log version into the meta data store
long checkpointLogVersion = 4;
MetaDataStore.setRecord(pageCache, databaseLayout.metadataStore(), CHECKPOINT_LOG_VERSION, checkpointLogVersion, databaseLayout.getDatabaseName(), NULL);
// when
RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, NullLogService.getInstance(), jobScheduler, PageCacheTracer.NULL, batchImporterFactory, INSTANCE);
// when
migrator.migrate(databaseLayout, migrationLayout, SILENT.startSection("section"), versionToMigrateFrom, versionToMigrateTo, EMPTY);
migrator.moveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, versionToMigrateTo);
// then
try (NeoStores neoStores = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, nullLogProvider(), PageCacheTracer.NULL, writable()).openNeoStores(StoreType.META_DATA)) {
neoStores.start(NULL);
assertThat(neoStores.getMetaDataStore().getCheckpointLogVersion()).isEqualTo(checkpointLogVersion);
}
}
use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class RecordStorageMigratorIT method shouldStartCheckpointLogVersionFromZeroIfMissingBeforeMigration.
@ParameterizedTest
@MethodSource("versions")
void shouldStartCheckpointLogVersionFromZeroIfMissingBeforeMigration(String version, LogPosition expectedLogPosition, Function<TransactionId, Boolean> txIdComparator) throws Exception {
// given
Path prepare = testDirectory.directory("prepare");
var fs = testDirectory.getFileSystem();
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, databaseLayout.databaseDirectory(), prepare);
RecordStoreVersionCheck check = getVersionCheck(pageCache, databaseLayout);
String versionToMigrateFrom = getVersionToMigrateFrom(check);
String versionToMigrateTo = getVersionToMigrateTo(check);
// when
RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, NullLogService.getInstance(), jobScheduler, PageCacheTracer.NULL, batchImporterFactory, INSTANCE);
// when
migrator.migrate(databaseLayout, migrationLayout, SILENT.startSection("section"), versionToMigrateFrom, versionToMigrateTo, EMPTY);
migrator.moveMigratedFiles(migrationLayout, databaseLayout, versionToMigrateFrom, versionToMigrateTo);
// then
try (NeoStores neoStores = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, nullLogProvider(), PageCacheTracer.NULL, writable()).openNeoStores(StoreType.META_DATA)) {
neoStores.start(NULL);
assertThat(neoStores.getMetaDataStore().getCheckpointLogVersion()).isEqualTo(0);
}
}
use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class RecordStorageEngineRule method get.
private RecordStorageEngine get(FileSystemAbstraction fs, PageCache pageCache, Health databaseHealth, DatabaseLayout databaseLayout, Function<TransactionApplierFactoryChain, TransactionApplierFactoryChain> transactionApplierTransformer, IndexUpdateListener indexUpdateListener, LockService lockService, TokenHolders tokenHolders, Config config, ConstraintRuleAccessor constraintSemantics, IndexConfigCompleter indexConfigCompleter) {
IdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
NullLogProvider nullLogProvider = NullLogProvider.getInstance();
RecordStorageEngine engine = new ExtendedRecordStorageEngine(databaseLayout, config, pageCache, fs, nullLogProvider, tokenHolders, mock(SchemaState.class), constraintSemantics, indexConfigCompleter, lockService, databaseHealth, idGeneratorFactory, new DefaultIdController(), transactionApplierTransformer);
engine.addIndexUpdateListener(indexUpdateListener);
life.add(engine);
return engine;
}
use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class DynamicArrayStoreTest method dynamicArrayStore.
private DynamicArrayStore dynamicArrayStore() {
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs, immediate(), DEFAULT_DATABASE_NAME);
DynamicArrayStore store = new DynamicArrayStore(storeFile, idFile, Config.defaults(), IdType.ARRAY_BLOCK, idGeneratorFactory, pageCache, NullLogProvider.getInstance(), 1, Standard.LATEST_RECORD_FORMATS, writable(), DEFAULT_DATABASE_NAME, immutable.empty());
store.initialise(true, NULL);
return store;
}
Aggregations