private void InitializeLinking(BatchingNeoStores neoStores, NodeRelationshipCache nodeRelationshipCache, DataStatistics distribution) { PrintStageHeader("(3/4) Relationship linking", ESTIMATED_REQUIRED_MEMORY_USAGE, bytes(BaselineMemoryRequirement(neoStores) + defensivelyPadMemoryEstimate(nodeRelationshipCache.MemoryEstimation(distribution.NodeCount)))); // The reason the highId of the relationship store is used, as opposed to actual number of imported relationships // is that the stages underneath operate on id ranges, not knowing which records are actually in use. long relationshipRecordIdCount = neoStores.RelationshipStore.HighId; // The progress counting of linking stages is special anyway, in that it uses the "progress" stats key, // which is based on actual number of relationships, not relationship ids. long actualRelationshipCount = distribution.RelationshipCount; InitializeProgress(relationshipRecordIdCount + actualRelationshipCount * 2 + actualRelationshipCount * 2, ImportStage.Linking); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSplitUpRelationshipTypesInBatches() public virtual void ShouldSplitUpRelationshipTypesInBatches() { // GIVEN int denseNodeThreshold = 5; int numberOfNodes = 100; int numberOfTypes = 10; NodeRelationshipCache cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, denseNodeThreshold); cache.NodeCount = numberOfNodes + 1; Direction[] directions = Direction.values(); for (int i = 0; i < numberOfNodes; i++) { int count = Random.Next(1, denseNodeThreshold * 2); cache.setCount(i, count, Random.Next(numberOfTypes), Random.among(directions)); } cache.CountingCompleted(); IList <RelationshipTypeCount> types = new List <RelationshipTypeCount>(); int numberOfRelationships = 0; for (int i = 0; i < numberOfTypes; i++) { int count = Random.Next(1, 100); types.Add(new RelationshipTypeCount(i, count)); numberOfRelationships += count; } types.sort((t1, t2) => Long.compare(t2.Count, t1.Count)); DataStatistics typeDistribution = new DataStatistics(0, 0, types.ToArray()); { // WHEN enough memory for all types long memory = cache.CalculateMaxMemoryUsage(numberOfRelationships) * numberOfTypes; int upToType = ImportLogic.NextSetOfTypesThatFitInMemory(typeDistribution, 0, memory, cache.NumberOfDenseNodes); // THEN assertEquals(types.Count, upToType); } { // and WHEN less than enough memory for all types long memory = cache.CalculateMaxMemoryUsage(numberOfRelationships) * numberOfTypes / 3; int startingFromType = 0; int rounds = 0; while (startingFromType < types.Count) { rounds++; startingFromType = ImportLogic.NextSetOfTypesThatFitInMemory(typeDistribution, startingFromType, memory, cache.NumberOfDenseNodes); } assertEquals(types.Count, startingFromType); assertThat(rounds, greaterThan(1)); } }
public override void Initialize(DependencyResolver dependencyResolver) { this._dependencyResolver = dependencyResolver; Input_Estimates estimates = dependencyResolver.ResolveDependency(typeof(Input_Estimates)); BatchingNeoStores neoStores = dependencyResolver.ResolveDependency(typeof(BatchingNeoStores)); IdMapper idMapper = dependencyResolver.ResolveDependency(typeof(IdMapper)); NodeRelationshipCache nodeRelationshipCache = dependencyResolver.ResolveDependency(typeof(NodeRelationshipCache)); _pageCacheArrayFactoryMonitor = dependencyResolver.ResolveDependency(typeof(PageCacheArrayFactoryMonitor)); long biggestCacheMemory = estimatedCacheSize(neoStores, nodeRelationshipCache.MemoryEstimation(estimates.NumberOfNodes()), idMapper.MemoryEstimation(estimates.NumberOfNodes())); 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, bytes(NodesDiskUsage(estimates, neoStores) + RelationshipsDiskUsage(estimates, neoStores) + estimates.SizeOfNodeProperties() + estimates.SizeOfRelationshipProperties()), ESTIMATED_REQUIRED_MEMORY_USAGE, bytes(biggestCacheMemory)); Console.WriteLine(); }