//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void distribute(RECORD record, org.neo4j.consistency.checking.full.RecordDistributor.RecordConsumer<RECORD> consumer) throws InterruptedException public override void Distribute(RECORD record, RecordConsumer <RECORD> consumer) { try { consumer.Accept(record, NextQIndex); } finally { NextQIndex = (NextQIndex + 1) % NumberOfThreads; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void distribute(org.neo4j.kernel.impl.store.record.RelationshipRecord relationship, org.neo4j.consistency.checking.full.RecordDistributor.RecordConsumer<org.neo4j.kernel.impl.store.record.RelationshipRecord> consumer) throws InterruptedException public override void Distribute(RelationshipRecord relationship, RecordConsumer <RelationshipRecord> consumer) { int qIndex1 = ( int )Math.Min(MaxAvailableThread, Math.Abs(relationship.FirstNode) / RecordsPerCpu); int qIndex2 = ( int )Math.Min(MaxAvailableThread, Math.Abs(relationship.SecondNode) / RecordsPerCpu); try { consumer.Accept(relationship, qIndex1); if (qIndex1 != qIndex2) { consumer.Accept(relationship, qIndex2); } } catch (System.IndexOutOfRangeException e) { throw Exceptions.withMessage(e, e.Message + ", recordsPerCPU:" + RecordsPerCpu + ", relationship:" + relationship + ", number of threads: " + NumberOfThreads); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldDistributeRelationshipRecordsByNodeId() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldDistributeRelationshipRecordsByNodeId() { // GIVEN QueueDistribution_QueueDistributor <RelationshipRecord> distributor = new QueueDistribution_RelationshipNodesQueueDistributor(5, 100); RecordConsumer <RelationshipRecord> consumer = mock(typeof(RecordConsumer)); // WHEN/THEN RelationshipRecord relationship = relationship(0, 0, 1); distributor.Distribute(relationship, consumer); verify(consumer, times(1)).accept(relationship, 0); relationship = relationship(1, 0, 7); distributor.Distribute(relationship, consumer); verify(consumer, times(1)).accept(relationship, 0); verify(consumer, times(1)).accept(relationship, 1); relationship = relationship(3, 26, 11); distributor.Distribute(relationship, consumer); verify(consumer, times(1)).accept(relationship, 5); verify(consumer, times(1)).accept(relationship, 2); }
//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 static <RECORD> void distributeRecords(int numberOfThreads, String workerNames, int queueSize, java.util.Iterator<RECORD> records, final org.neo4j.helpers.progress.ProgressListener progress, RecordProcessor<RECORD> processor, org.neo4j.consistency.checking.full.QueueDistribution_QueueDistributor<RECORD> idDistributor) public static void DistributeRecords <RECORD>(int numberOfThreads, string workerNames, int queueSize, IEnumerator <RECORD> records, ProgressListener progress, RecordProcessor <RECORD> processor, QueueDistribution_QueueDistributor <RECORD> idDistributor) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (!records.hasNext()) { return; } //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") final java.util.concurrent.ArrayBlockingQueue<RECORD>[] recordQ = new java.util.concurrent.ArrayBlockingQueue[numberOfThreads]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': ArrayBlockingQueue <RECORD>[] recordQ = new ArrayBlockingQueue[numberOfThreads]; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.unsafe.impl.batchimport.cache.idmapping.string.Workers<RecordCheckWorker<RECORD>> workers = new org.neo4j.unsafe.impl.batchimport.cache.idmapping.string.Workers<>(workerNames); Workers <RecordCheckWorker <RECORD> > workers = new Workers <RecordCheckWorker <RECORD> >(workerNames); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger idGroup = new java.util.concurrent.atomic.AtomicInteger(-1); AtomicInteger idGroup = new AtomicInteger(-1); for (int threadId = 0; threadId < numberOfThreads; threadId++) { recordQ[threadId] = new ArrayBlockingQueue <RECORD>(queueSize); workers.Start(new RecordCheckWorker <RECORD>(threadId, idGroup, recordQ[threadId], processor)); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int[] recsProcessed = new int[numberOfThreads]; int[] recsProcessed = new int[numberOfThreads]; RecordConsumer <RECORD> recordConsumer = (record, qIndex) => { recordQ[qIndex].put(record); recsProcessed[qIndex]++; }; try { while (records.MoveNext()) { try { // Put records into the queues using the queue distributor. Each Worker will pull and process. RECORD record = records.Current; idDistributor.Distribute(record, recordConsumer); progress.Add(1); } catch (InterruptedException) { Thread.CurrentThread.Interrupt(); break; } } // No more records to distribute, mark as done so that the workers will exit when no more records in queue. foreach (RecordCheckWorker <RECORD> worker in workers) { worker.Done(); } workers.AwaitAndThrowOnError(); } catch (InterruptedException) { Thread.CurrentThread.Interrupt(); throw new Exception("Was interrupted while awaiting completion"); } }