//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static DataStatistics importRelationships(int numRunners, org.neo4j.unsafe.impl.batchimport.input.Input input, org.neo4j.unsafe.impl.batchimport.store.BatchingNeoStores stores, org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdMapper idMapper, org.neo4j.unsafe.impl.batchimport.input.Collector badCollector, org.neo4j.unsafe.impl.batchimport.staging.ExecutionMonitor executionMonitor, Monitor monitor, boolean validateRelationshipData) throws java.io.IOException public static DataStatistics ImportRelationships(int numRunners, Input input, BatchingNeoStores stores, IdMapper idMapper, Collector badCollector, ExecutionMonitor executionMonitor, Monitor monitor, bool validateRelationshipData) { DataStatistics typeDistribution = new DataStatistics(monitor, new RelationshipTypeCount[0]); System.Func <EntityImporter> importers = () => new RelationshipImporter(stores, idMapper, typeDistribution, monitor, badCollector, validateRelationshipData, stores.UsesDoubleRelationshipRecordUnits()); ImportData(RELATIONSHIP_IMPORT_NAME, numRunners, input.Relationships(), stores, importers, executionMonitor, new MemoryUsageStatsProvider(stores, idMapper)); return(typeDistribution); }
//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)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGrowArrayProperly() public virtual void ShouldGrowArrayProperly() { // given DataStatistics stats = new DataStatistics(1, 1, new RelationshipTypeCount[0]); // when int typeId = 1_000; using (Client client = stats.NewClient()) { client.Increment(typeId); } // then RelationshipTypeCount count = TypeCount(stats.GetEnumerator(), typeId); assertEquals(1, count.Count); assertEquals(typeId, count.TypeId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSumCounts() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSumCounts() { // given DataStatistics stats = new DataStatistics(1, 2, new RelationshipTypeCount[0]); Race race = new Race(); int types = 10; long[] expected = new long[types]; int threads = Runtime.Runtime.availableProcessors(); for (int i = 0; i < threads; i++) { long[] local = new long[types]; for (int j = 0; j < types; j++) { local[j] = Random.Next(1_000, 2_000); expected[j] += local[j]; } race.AddContestant(() => { using (DataStatistics.Client client = stats.NewClient()) { for (int typeId = 0; typeId < types; typeId++) { while (local[typeId]-- > 0) { client.Increment(typeId); } } } }); } // when race.Go(); // then stats.forEach(count => assertEquals(expected[count.TypeId], count.Count)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUseDataStatisticsCountsForPrintingFinalStats() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUseDataStatisticsCountsForPrintingFinalStats() { // given ExecutionMonitor monitor = mock(typeof(ExecutionMonitor)); using (BatchingNeoStores stores = batchingNeoStoresWithExternalPageCache(Storage.fileSystem(), Storage.pageCache(), NULL, Storage.directory().directory(), defaultFormat(), DEFAULT, Instance, EMPTY, defaults())) { // when RelationshipTypeCount[] relationshipTypeCounts = new RelationshipTypeCount[] { new RelationshipTypeCount(0, 33), new RelationshipTypeCount(1, 66) }; DataStatistics dataStatistics = new DataStatistics(100123, 100456, relationshipTypeCounts); using (ImportLogic logic = new ImportLogic(Storage.directory().directory(), Storage.fileSystem(), stores, DEFAULT, Instance, monitor, defaultFormat(), NO_MONITOR)) { logic.PutState(dataStatistics); logic.Success(); } // then verify(monitor).done(eq(true), anyLong(), contains(dataStatistics.ToString())); } }
protected internal RelationshipImporter(BatchingNeoStores stores, IdMapper idMapper, DataStatistics typeDistribution, Monitor monitor, Collector badCollector, bool validateRelationshipData, bool doubleRecordUnits) : base(stores, monitor) { this._doubleRecordUnits = doubleRecordUnits; this._relationshipTypeTokenRepository = stores.RelationshipTypeRepository; this._idMapper = idMapper; this._badCollector = badCollector; this._validateRelationshipData = validateRelationshipData; this._relationshipStore = stores.RelationshipStore; this._relationshipRecord = _relationshipStore.newRecord(); this._relationshipIds = new BatchingIdGetter(_relationshipStore); this._typeCounts = typeDistribution.NewClient(); this._prepareIdSequence = PrepareIdSequence.of(doubleRecordUnits).apply(stores.RelationshipStore); _relationshipRecord.InUse = true; }
public Client(DataStatistics outerInstance) { this._outerInstance = outerInstance; }