コード例 #1
0
 internal LabelGetter(NodeLabelsCache cache, int[][] expectedLabels, int numberOfNodes)
 {
     this.Cache          = cache;
     this.Client         = cache.NewClient();
     this.ExpectedLabels = expectedLabels;
     this.NumberOfNodes  = numberOfNodes;
 }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSupportConcurrentGet() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSupportConcurrentGet()
        {
            // GIVEN
            int highLabelId   = 10;
            int numberOfNodes = 100;

            int[][]         expectedLabels = new int[numberOfNodes][];
            NodeLabelsCache cache          = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, highLabelId);

            for (int i = 0; i < numberOfNodes; i++)
            {
                cache.Put(i, AsLongArray(expectedLabels[i] = RandomLabels(_random.Next(5), highLabelId)));
            }

            // WHEN
            Race getRace = new Race();

            for (int i = 0; i < 10; i++)
            {
                getRace.AddContestant(new LabelGetter(cache, expectedLabels, numberOfNodes));
            }

            // THEN expected labels should be had (asserted in LabelGetter), and no exceptions (propagated by go())
            getRace.Go();
        }
コード例 #3
0
 public ProcessRelationshipCountsDataStep(StageControl control, NodeLabelsCache cache, Configuration config, int highLabelId, int highRelationshipTypeId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, NumberArrayFactory cacheFactory, ProgressReporter progressReporter) : base(control, "COUNT", config, NumberOfProcessors(config, cache, highLabelId, highRelationshipTypeId))
 {
     this._cache                  = cache;
     this._highLabelId            = highLabelId;
     this._highRelationshipTypeId = highRelationshipTypeId;
     this._countsUpdater          = countsUpdater;
     this._cacheFactory           = cacheFactory;
     this._progressMonitor        = progressReporter;
 }
コード例 #4
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)));
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnEmptyArrayForNodeWithNoLabelsAndNoLabelsWhatsoever()
        public virtual void ShouldReturnEmptyArrayForNodeWithNoLabelsAndNoLabelsWhatsoever()
        {
            // GIVEN
            NodeLabelsCache cache = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 0);

            NodeLabelsCache.Client client = cache.NewClient();

            // WHEN
            int[] target = new int[3];
            cache.Get(client, 0, target);

            // THEN
            assertEquals(-1, target[0]);
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCacheSmallSetOfLabelsPerNode()
        public virtual void ShouldCacheSmallSetOfLabelsPerNode()
        {
            // GIVEN
            NodeLabelsCache cache = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 5, CHUNK_SIZE);

            NodeLabelsCache.Client client = cache.NewClient();
            long nodeId = 0;

            // WHEN
            cache.Put(nodeId, new long[] { 1, 2, 3 });

            // THEN
            int[] readLabels = new int[3];
            cache.Get(client, nodeId, readLabels);
            assertArrayEquals(new int[] { 1, 2, 3 }, readLabels);
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleLargeAmountOfLabelsPerNode()
        public virtual void ShouldHandleLargeAmountOfLabelsPerNode()
        {
            // GIVEN
            int             highLabelId = 1000;
            NodeLabelsCache cache       = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, highLabelId, CHUNK_SIZE);

            NodeLabelsCache.Client client = cache.NewClient();
            long nodeId = 0;

            // WHEN
            int[] labels = RandomLabels(200, 1000);
            cache.Put(nodeId, AsLongArray(labels));

            // THEN
            int[] readLabels = new int[labels.Length];
            cache.Get(client, nodeId, readLabels);
            assertArrayEquals(labels, readLabels);
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEndTargetArrayWithMinusOne()
        public virtual void ShouldEndTargetArrayWithMinusOne()
        {
            // GIVEN
            NodeLabelsCache cache = new NodeLabelsCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 10);

            NodeLabelsCache.Client client = cache.NewClient();
            cache.Put(10, new long[] { 5, 6, 7, 8 });

            // WHEN
            int[] target = new int[20];
            assertSame(target, cache.Get(client, 10, target));
            assertEquals(5, target[0]);
            assertEquals(6, target[1]);
            assertEquals(7, target[2]);
            assertEquals(8, target[3]);

            // THEN
            assertEquals(-1, target[4]);
        }