Пример #1
0
        protected internal override void Scan()
        {
            long recordsPerCPU = RecordDistributor.CalculateRecordsPerCpu(Store.maxCount(), NumberOfThreads);

            _cacheAccess.prepareForProcessingOfSingleStore(recordsPerCPU);

            QueueDistribution_QueueDistributor <RECORD> distributor = _distribution.distributor(recordsPerCPU, NumberOfThreads);

            distributeRecords(NumberOfThreads, this.GetType().Name + "-" + Name, DEFAULT_QUEUE_SIZE, Store.GetEnumerator(), Progress, Processor, distributor);
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void testRecordDistribution(QueueDistribution queueDistribution) throws InterruptedException
        private static void TestRecordDistribution(QueueDistribution queueDistribution)
        {
            ThreadLocalRandom randomGenerator = ThreadLocalRandom.current();
            int numberOfThreads = randomGenerator.Next(MAX_NUMBER_OF_THREADS);
            int recordsPerCpu   = randomGenerator.Next(int.MaxValue);
            QueueDistribution_QueueDistributor <RelationshipRecord> distributor = queueDistribution.Distributor(recordsPerCpu, numberOfThreads);

            for (int iteration = 0; iteration <= NUMBER_OF_DISTRIBUTION_ITERATIONS; iteration++)
            {
                RelationshipRecord relationshipRecord = new RelationshipRecord(1);
                relationshipRecord.FirstNode  = NextLong(randomGenerator);
                relationshipRecord.SecondNode = NextLong(randomGenerator);
                distributor.Distribute(relationshipRecord, (record, qIndex) => assertThat("Distribution index for record " + record + " should be within a range of available " + "executors, while expected records per cpu is: " + recordsPerCpu, qIndex, allOf(greaterThanOrEqualTo(0), lessThan(numberOfThreads))));
            }
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public void run()
        public override void Run()
        {
            statistics.reset();
            BeforeProcessing(_processor);
            try
            {
                if (_processor.Stage.CacheSlotSizes.Length > 0)
                {
                    _cacheAccess.CacheSlotSizes = _processor.Stage.CacheSlotSizes;
                }
                _cacheAccess.Forward = _processor.Stage.Forward;

                if (_processor.Stage.Parallel)
                {
                    long highId;
                    if (_processor.Stage == CheckStage.Stage1NSPropsLabels)
                    {
                        highId = _storeAccess.NodeStore.HighId;
                    }
                    else if (_processor.Stage == CheckStage.Stage8PSProps)
                    {
                        highId = _storeAccess.PropertyStore.HighId;
                    }
                    else
                    {
                        highId = _storeAccess.NodeStore.HighId;
                    }
                    long recordsPerCPU = RecordDistributor.CalculateRecordsPerCpu(highId, numberOfThreads);
                    QueueDistribution_QueueDistributor <R> distributor = _distribution.distributor(recordsPerCPU, numberOfThreads);
                    _processor.applyFilteredParallel(_store, _progressListener, numberOfThreads, recordsPerCPU, distributor);
                }
                else
                {
                    _processor.applyFiltered(_store, _progressListener);
                }
                _cacheAccess.Forward = true;
            }
            catch (Exception e)
            {
                _progressListener.failed(e);
                throw new Exception(e);
            }
            finally
            {
                AfterProcessing(_processor);
            }
            statistics.print(name);
        }
Пример #4
0
//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");
            }
        }
Пример #5
0
//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 <R extends org.neo4j.kernel.impl.store.record.AbstractBaseRecord> void applyFilteredParallel(final org.neo4j.kernel.impl.store.RecordStore<R> store, final org.neo4j.helpers.progress.ProgressListener progressListener, int numberOfThreads, long recordsPerCpu, final org.neo4j.consistency.checking.full.QueueDistribution_QueueDistributor<R> distributor)
        public virtual void ApplyFilteredParallel <R>(RecordStore <R> store, ProgressListener progressListener, int numberOfThreads, long recordsPerCpu, QueueDistribution_QueueDistributor <R> distributor) where R : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord
        {
            CacheAccess.prepareForProcessingOfSingleStore(recordsPerCpu);
            RecordProcessor <R> processor = new RecordProcessor_AdapterAnonymousInnerClass(this, store);

            ResourceIterable <R> scan = scan(store, _stage.Forward);

            using (ResourceIterator <R> records = scan.GetEnumerator())
            {
                distributeRecords(numberOfThreads, this.GetType().Name, _qSize, cloned(records), progressListener, processor, distributor);
            }
        }