示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testRelationshipCountersUpdates()
        public virtual void TestRelationshipCountersUpdates()
        {
            int relationTypes = 2;
            int labels        = 3;

            NodeLabelsCache.Client client = mock(typeof(NodeLabelsCache.Client));
            when(_nodeLabelCache.newClient()).thenReturn(client);
            when(_nodeLabelCache.get(eq(client), eq(1L), any(typeof(int[])))).thenReturn(new int[] { 0, 2 });
            when(_nodeLabelCache.get(eq(client), eq(2L), any(typeof(int[])))).thenReturn(new int[] { 1 });
            when(_nodeLabelCache.get(eq(client), eq(3L), any(typeof(int[])))).thenReturn(new int[] { 1, 2 });
            when(_nodeLabelCache.get(eq(client), eq(4L), any(typeof(int[])))).thenReturn(new int[] {});

            RelationshipCountsProcessor countsProcessor = new RelationshipCountsProcessor(_nodeLabelCache, labels, relationTypes, _countsUpdater, [email protected]_Fields.AutoWithoutPagecache);

            countsProcessor.Process(Record(1, 0, 3));
            countsProcessor.Process(Record(2, 1, 4));

            countsProcessor.Done();

            // wildcard counts
            verify(_countsUpdater).incrementRelationshipCount(ANY, ANY, ANY, 2L);
            verify(_countsUpdater).incrementRelationshipCount(ANY, 0, ANY, 1L);
            verify(_countsUpdater).incrementRelationshipCount(ANY, 1, ANY, 1L);

            // start labels counts
            verify(_countsUpdater).incrementRelationshipCount(0, 0, ANY, 1L);
            verify(_countsUpdater).incrementRelationshipCount(2, 0, ANY, 1L);

            // end labels counts
            verify(_countsUpdater).incrementRelationshipCount(ANY, 0, 1, 1L);
            verify(_countsUpdater).incrementRelationshipCount(ANY, 0, 2, 1L);
        }
示例#2
0
        protected internal override void Done()
        {
            base.Done();
            RelationshipCountsProcessor all = null;

            foreach (RelationshipCountsProcessor processor in _processors.Values)
            {
                if (all == null)
                {
                    all = processor;
                }
                else
                {
                    all.AddCountsFrom(processor);
                }
            }
            if (all != null)
            {
                all.Done();
            }

            foreach (RelationshipCountsProcessor processor in _processors.Values)
            {
                processor.Close();
            }
        }
示例#3
0
        /// <summary>
        /// Keeping all counts for all combinations of label/reltype can require a lot of memory if there are lots of those tokens.
        /// Each processor will allocate such a data structure and so in extreme cases the number of processors will have to
        /// be limited to not surpass the available memory limits.
        /// </summary>
        /// <param name="config"> <seealso cref="Configuration"/> holding things like max number of processors and max memory. </param>
        /// <param name="cache"> <seealso cref="NodeLabelsCache"/> which is the only other data structure occupying memory at this point. </param>
        /// <param name="highLabelId"> high label id for this store. </param>
        /// <param name="highRelationshipTypeId"> high relationship type id for this store. </param>
        /// <returns> number of processors suitable for this step. In most cases this will be 0, which is the typical value used
        /// when just allowing the importer to grab up to <seealso cref="Configuration.maxNumberOfProcessors()"/>. The returned value
        /// will at least be 1. </returns>
        private static int NumberOfProcessors(Configuration config, NodeLabelsCache cache, int highLabelId, int highRelationshipTypeId)
        {
            GatheringMemoryStatsVisitor memVisitor = new GatheringMemoryStatsVisitor();

            cache.AcceptMemoryStatsVisitor(memVisitor);

            long availableMem    = config.MaxMemoryUsage() - memVisitor.TotalUsage;
            long threadMem       = RelationshipCountsProcessor.CalculateMemoryUsage(highLabelId, highRelationshipTypeId);
            long possibleThreads = availableMem / threadMem;

            return(possibleThreads >= config.MaxNumberOfProcessors() ? 0 : toIntExact(max(1, possibleThreads)));
        }
示例#4
0
        protected internal override void Process(RelationshipRecord[] batch, BatchSender sender)
        {
            RelationshipCountsProcessor processor = processor();

            foreach (RelationshipRecord record in batch)
            {
                if (record.InUse())
                {
                    processor.Process(record);
                }
            }
            _progressMonitor.progress(batch.Length);
        }
 public virtual void AddCountsFrom(RelationshipCountsProcessor from)
 {
     MergeCounts(_labelsCounts, from._labelsCounts);
     MergeCounts(_wildcardCounts, from._wildcardCounts);
 }