use of org.neo4j.kernel.impl.store.PropertyValueRecordSizeCalculator 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.kernel.impl.store.PropertyValueRecordSizeCalculator in project neo4j by neo4j.
the class CsvInputEstimateCalculationIT method shouldCalculateCorrectEstimatesOnEmptyData.
@Test
void shouldCalculateCorrectEstimatesOnEmptyData() throws Exception {
// given
Groups groups = new Groups();
Collection<DataFactory> nodeData = singletonList(generateData(defaultFormatNodeFileHeader(), new MutableLong(), 0, 0, ":ID", "nodes-1.csv", groups));
Collection<DataFactory> relationshipData = singletonList(generateData(defaultFormatRelationshipFileHeader(), new MutableLong(), 0, 0, ":START_ID,:TYPE,:END_ID", "rels-1.csv", groups));
Input input = new CsvInput(nodeData, defaultFormatNodeFileHeader(), relationshipData, defaultFormatRelationshipFileHeader(), IdType.INTEGER, COMMAS, CsvInput.NO_MONITOR, groups, INSTANCE);
// when
Input.Estimates estimates = input.calculateEstimates(new PropertyValueRecordSizeCalculator(LATEST_RECORD_FORMATS.property().getRecordSize(NO_STORE_HEADER), GraphDatabaseInternalSettings.string_block_size.defaultValue(), 0, GraphDatabaseInternalSettings.array_block_size.defaultValue(), 0));
// then
assertEquals(0, estimates.numberOfNodes());
assertEquals(0, estimates.numberOfRelationships());
assertEquals(0, estimates.numberOfRelationshipProperties());
assertEquals(0, estimates.numberOfNodeProperties());
assertEquals(0, estimates.numberOfNodeLabels());
}
Aggregations