Exemple #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);
        }
        public RelationshipCountsProcessor(NodeLabelsCache nodeLabelCache, int highLabelId, int highRelationshipTypeId, Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater countsUpdater, NumberArrayFactory cacheFactory)
        {
            this._nodeLabelCache = nodeLabelCache;
            this._client         = nodeLabelCache.NewClient();
            this._countsUpdater  = countsUpdater;

            // Make room for high id + 1 since we need that extra slot for the ANY counts
            this._anyLabel            = highLabelId;
            this._anyRelationshipType = highRelationshipTypeId;
            this._itemsPerType        = _anyLabel + 1;
            this._itemsPerLabel       = _anyRelationshipType + 1;
            this._labelsCounts        = cacheFactory.NewLongArray(SideSize() * SIDES, 0);
            this._wildcardCounts      = cacheFactory.NewLongArray(_anyRelationshipType + 1, 0);
        }