//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportProgressInTheSpecifiedIntervals() public virtual void ShouldReportProgressInTheSpecifiedIntervals() { // given Indicator indicator = IndicatorMock(); ProgressListener progressListener = Factory.mock(indicator, 10).singlePart(TestName.MethodName, 16); // when progressListener.Started(); for (int i = 0; i < 16; i++) { progressListener.Add(1); } progressListener.Done(); // then InOrder order = inOrder(indicator); order.verify(indicator).startProcess(16); for (int i = 0; i < 10; i++) { order.verify(indicator).progress(i, i + 1); } order.verify(indicator).completeProcess(); order.verifyNoMoreInteractions(); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public void checkCounts(org.neo4j.kernel.impl.api.CountsAccessor counts, final org.neo4j.consistency.report.ConsistencyReporter reporter, org.neo4j.helpers.progress.ProgressMonitorFactory progressFactory) public virtual void CheckCounts(CountsAccessor counts, ConsistencyReporter reporter, ProgressMonitorFactory progressFactory) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int nodes = nodeCounts.size(); int nodes = _nodeCounts.size(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int relationships = relationshipCounts.size(); int relationships = _relationshipCounts.size(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int total = nodes + relationships; int total = nodes + relationships; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger nodeEntries = new java.util.concurrent.atomic.AtomicInteger(0); AtomicInteger nodeEntries = new AtomicInteger(0); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger relationshipEntries = new java.util.concurrent.atomic.AtomicInteger(0); AtomicInteger relationshipEntries = new AtomicInteger(0); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.helpers.progress.ProgressListener listener = progressFactory.singlePart("Checking node and relationship counts", total); ProgressListener listener = progressFactory.SinglePart("Checking node and relationship counts", total); listener.Started(); Counts.accept(new CountsVisitor_AdapterAnonymousInnerClass(this, reporter, nodeEntries, relationshipEntries, listener)); reporter.ForCounts(new CountsEntry(nodeKey(WILDCARD), nodeEntries.get()), CHECK_NODE_KEY_COUNT); reporter.ForCounts(new CountsEntry(relationshipKey(WILDCARD, WILDCARD, WILDCARD), relationshipEntries.get()), CHECK_RELATIONSHIP_KEY_COUNT); listener.Done(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void detectDuplicateInputIds(Radix radix, org.neo4j.unsafe.impl.batchimport.input.Collector collector, org.neo4j.helpers.progress.ProgressListener progress) throws InterruptedException private void DetectDuplicateInputIds(Radix radix, Collector collector, ProgressListener progress) { // We do this collision sort using ParallelSort which has the data cache and the tracker cache, // the tracker cache gets sorted, data cache stays intact. In the collision data case we actually // have one more layer in here so we have tracker cache pointing to collisionNodeIdCache // pointing to dataCache. This can be done using the ParallelSort.Comparator abstraction. // // The Comparator below takes into account dataIndex for each eId its comparing so that an extra // comparison based on dataIndex is done if it's comparing two equal eIds. We do this so that // stretches of multiple equal eIds are sorted by dataIndex (i.e. node id) order, // to be able to write an efficient duplication scanning below and to have deterministic duplication reporting. Comparator duplicateComparator = new ComparatorAnonymousInnerClass(this); (new ParallelSort(radix, As5ByteLongArray(_collisionNodeIdCache), _numberOfCollisions - 1, _collisionTrackerCache, _processorsForParallelWork, progress, duplicateComparator)).run(); // Here we have a populated C // We want to detect duplicate input ids within it long previousEid = 0; int previousGroupId = -1; SameInputIdDetector detector = new SameInputIdDetector(); progress.Started("DEDUPLICATE"); for (int i = 0; i < _numberOfCollisions; i++) { long collisionIndex = _collisionTrackerCache.get(i); long nodeId = _collisionNodeIdCache.get5ByteLong(collisionIndex, 0); long offset = _collisionNodeIdCache.get6ByteLong(collisionIndex, 5); long eid = _dataCache.get(nodeId); int groupId = GroupOf(nodeId); // collisions of same eId AND groupId are always together bool same = eid == previousEid && previousGroupId == groupId; if (!same) { detector.Clear(); } // Potential duplicate object inputId = _collisionValues.get(offset); long nonDuplicateNodeId = detector.Add(nodeId, inputId); if (nonDuplicateNodeId != -1) { // Duplicate collector.CollectDuplicateNode(inputId, nodeId, _groups.get(groupId).name()); _trackerCache.markAsDuplicate(nodeId); UnmarkAsCollision(nonDuplicateNodeId); } previousEid = eid; previousGroupId = groupId; progress.Add(1); } progress.Done(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAggregateProgressFromMultipleProcesses() public virtual void ShouldAggregateProgressFromMultipleProcesses() { // given Indicator indicator = IndicatorMock(); ProgressMonitorFactory.MultiPartBuilder builder = Factory.mock(indicator, 10).multipleParts(TestName.MethodName); ProgressListener first = builder.ProgressForPart("first", 5); ProgressListener other = builder.ProgressForPart("other", 5); builder.Build(); InOrder order = inOrder(indicator); order.verify(indicator).startProcess(10); order.verifyNoMoreInteractions(); // when first.Started(); for (int i = 0; i < 5; i++) { first.Add(1); } first.Done(); // then order.verify(indicator).startPart("first", 5); for (int i = 0; i < 5; i++) { order.verify(indicator).progress(i, i + 1); } order.verify(indicator).completePart("first"); order.verifyNoMoreInteractions(); // when other.Started(); for (int i = 0; i < 5; i++) { other.Add(1); } other.Done(); // then order.verify(indicator).startPart("other", 5); for (int i = 5; i < 10; i++) { order.verify(indicator).progress(i, i + 1); } order.verify(indicator).completePart("other"); order.verify(indicator).completeProcess(); order.verifyNoMoreInteractions(); }
/// <summary> /// There are two types of collisions: /// - actual: collisions coming from equal input value. These might however not impose /// keeping original input value since the colliding values might be for separate id groups, /// just as long as there's at most one per id space. /// - accidental: collisions coming from different input values that happens to coerce into /// the same encoded value internally. /// /// For any encoded value there might be a mix of actual and accidental collisions. As long as there's /// only one such value (accidental or actual) per id space the original input id doesn't need to be kept. /// For scenarios where there are multiple per for any given id space: /// - actual: there are two equal input values in the same id space /// ==> fail, not allowed /// - accidental: there are two different input values coerced into the same encoded value /// in the same id space /// ==> original input values needs to be kept /// </summary> /// <returns> rough number of collisions. The number can be slightly more than it actually is due to benign /// races between detector workers. This is not a problem though, this value serves as a pessimistic value /// for allocating arrays to hold collision data to later sort and use to discover duplicates. </returns> private long DetectAndMarkCollisions(ProgressListener progress) { progress.Started("DETECT"); long totalCount = _highestSetIndex + 1; Workers <DetectWorker> workers = new Workers <DetectWorker>("DETECT"); int processors = _processorsForParallelWork; long stride = totalCount / _processorsForParallelWork; if (stride < 10) { // Multi-threading would be overhead processors = 1; stride = totalCount; } long fromInclusive = 0; long toExclusive = 0; for (int i = 0; i < processors; i++) { bool last = i == processors - 1; fromInclusive = toExclusive; toExclusive = last ? totalCount : toExclusive + stride; workers.Start(new DetectWorker(this, fromInclusive, toExclusive, last, progress)); } workers.AwaitAndThrowOnErrorStrict(); long numberOfCollisions = 0; foreach (DetectWorker detectWorker in workers) { numberOfCollisions += detectWorker.NumberOfCollisions; } progress.Done(); if (numberOfCollisions > int.MaxValue) { throw new InputException("Too many collisions: " + numberOfCollisions); } int intNumberOfCollisions = toIntExact(numberOfCollisions); _monitor.numberOfCollisions(intNumberOfCollisions); return(intNumberOfCollisions); }
private static void ConsistencyCheckIndexStructure(LabelScanStore labelScanStore, IndexAccessors indexes, ConsistencyReporter report, ProgressMonitorFactory progressMonitorFactory) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long schemaIndexCount = org.neo4j.helpers.collection.Iterables.count(indexes.onlineRules()); long schemaIndexCount = Iterables.count(indexes.OnlineRules()); const long additionalCount = 1; // LabelScanStore //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long totalCount = schemaIndexCount + additionalCount; long totalCount = schemaIndexCount + additionalCount; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.helpers.progress.ProgressListener listener = progressMonitorFactory.singlePart("Index structure consistency check", totalCount); ProgressListener listener = progressMonitorFactory.SinglePart("Index structure consistency check", totalCount); listener.Started(); ConsistencyCheckLabelScanStore(labelScanStore, report, listener); ConsistencyCheckSchemaIndexes(indexes, report, listener); listener.Done(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void buildCollisionInfo(System.Func<long, Object> inputIdLookup, long pessimisticNumberOfCollisions, org.neo4j.unsafe.impl.batchimport.input.Collector collector, org.neo4j.helpers.progress.ProgressListener progress) throws InterruptedException private void BuildCollisionInfo(System.Func <long, object> inputIdLookup, long pessimisticNumberOfCollisions, Collector collector, ProgressListener progress) { progress.Started("RESOLVE (~" + pessimisticNumberOfCollisions + " collisions)"); Radix radix = _radixFactory.newInstance(); _collisionNodeIdCache = _cacheFactory.newByteArray(pessimisticNumberOfCollisions, new sbyte[COLLISION_ENTRY_SIZE]); _collisionTrackerCache = _trackerFactory.create(_cacheFactory, pessimisticNumberOfCollisions); _collisionValues = _collisionValuesFactory.apply(pessimisticNumberOfCollisions); for (long nodeId = 0; nodeId <= _highestSetIndex; nodeId++) { long eId = _dataCache.get(nodeId); if (IsCollision(eId)) { // Store this collision input id for matching later in get() long collisionIndex = _numberOfCollisions++; object id = inputIdLookup(nodeId); long eIdFromInputId = Encode(id); long eIdWithoutCollisionBit = ClearCollision(eId); Debug.Assert(eIdFromInputId == eIdWithoutCollisionBit, format("Encoding mismatch during building of " + "collision info. input id %s (a %s) marked as collision where this id was encoded into " + "%d when put, but was now encoded into %d", id, id.GetType().Name, eIdWithoutCollisionBit, eIdFromInputId)); long offset = _collisionValues.add(id); _collisionNodeIdCache.set5ByteLong(collisionIndex, 0, nodeId); _collisionNodeIdCache.set6ByteLong(collisionIndex, 5, offset); // The base of our sorting this time is going to be node id, so register that in the radix radix.RegisterRadixOf(eIdWithoutCollisionBit); } progress.Add(1); } progress.Done(); // Detect input id duplicates within the same group, with source information, line number and the works DetectDuplicateInputIds(radix, collector, progress); // We won't be needing these anymore _collisionTrackerCache.close(); _collisionTrackerCache = null; }