예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveDenseNodesWithBigCounts()
        public virtual void ShouldHaveDenseNodesWithBigCounts()
        {
            // A count of a dense node follow a different path during import, first there's counting per node
            // then import goes into actual import of relationships where individual chain degrees are
            // kept. So this test will first set a total count, then set count for a specific chain

            // GIVEN
            _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1, 100, Base);
            long nodeId = 1;
            int  typeId = 10;

            _cache.NodeCount = nodeId + 1;
            _cache.setCount(nodeId, 2, typeId, OUTGOING);                 // surely dense now
            _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, 1, true);
            _cache.getAndPutRelationship(nodeId, typeId, INCOMING, 2, true);

            // WHEN
            long highCountOut = NodeRelationshipCache.MaxCount - 100;
            long highCountIn  = NodeRelationshipCache.MaxCount - 50;

            _cache.setCount(nodeId, highCountOut, typeId, OUTGOING);
            _cache.setCount(nodeId, highCountIn, typeId, INCOMING);
            _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, 1, true);
            _cache.getAndPutRelationship(nodeId, typeId, INCOMING, 2, true);

            // THEN
            assertEquals(highCountOut + 1, _cache.getCount(nodeId, typeId, OUTGOING));
            assertEquals(highCountIn + 1, _cache.getCount(nodeId, typeId, INCOMING));
        }
예제 #2
0
            internal virtual long GetAndResetCount(long relGroupIndex, int typeId, Direction direction)
            {
                long index = Rebase(relGroupIndex);

                while (index != EMPTY)
                {
                    ByteArray array = this.Array.at(index);
                    if (GetTypeId(array, index) == typeId)
                    {
                        int  offset = CountOffset(direction);
                        long count  = _outerInstance.getCount(array, index, offset);
                        _outerInstance.setCount(array, index, offset, 0);
                        return(count);
                    }
                    index = GetNext(array, index);
                }
                return(0);
            }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveSparseNodesWithBigCounts()
        public virtual void ShouldHaveSparseNodesWithBigCounts()
        {
            // GIVEN
            _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1, 100, Base);
            long nodeId = 1;
            int  typeId = 10;

            _cache.NodeCount = nodeId + 1;

            // WHEN
            long highCount = NodeRelationshipCache.MaxCount - 100;

            _cache.setCount(nodeId, highCount, typeId, OUTGOING);
            long nextHighCount = _cache.incrementCount(nodeId);

            // THEN
            assertEquals(highCount + 1, nextHighCount);
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailFastOnTooHighCountOnNode()
        public virtual void ShouldFailFastOnTooHighCountOnNode()
        {
            // GIVEN
            _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 10, 100, Base);
            long nodeId = 5;
            long count  = NodeRelationshipCache.MaxCount - 1;
            int  typeId = 10;

            _cache.NodeCount = 10;
            _cache.setCount(nodeId, count, typeId, OUTGOING);

            // WHEN
            _cache.incrementCount(nodeId);
            try
            {
                _cache.incrementCount(nodeId);
                fail("Should have failed");
            }
            catch (System.InvalidOperationException)
            {
                // THEN Good
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCacheMultipleDenseNodeRelationshipHeads()
        public virtual void ShouldCacheMultipleDenseNodeRelationshipHeads()
        {
            // GIVEN
            _cache           = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1);
            _cache.NodeCount = 10;
            long nodeId = 3;

            _cache.setCount(nodeId, 10, 0, OUTGOING);

            // WHEN
            IDictionary <Pair <int, Direction>, long> firstRelationshipIds = new Dictionary <Pair <int, Direction>, long>();
            int typeCount = 3;

            for (int typeId = 0, relationshipId = 0; typeId < typeCount; typeId++)
            {
                foreach (Direction direction in Direction.values())
                {
                    long firstRelationshipId = relationshipId++;
                    _cache.getAndPutRelationship(nodeId, typeId, direction, firstRelationshipId, true);
                    firstRelationshipIds[Pair.of(typeId, direction)] = firstRelationshipId;
                }
            }
            AtomicInteger visitCount = new AtomicInteger();
            GroupVisitor  visitor    = (nodeId1, typeId, @out, @in, loop) =>
            {
                visitCount.incrementAndGet();
                assertEquals(firstRelationshipIds[Pair.of(typeId, OUTGOING)], @out);
                assertEquals(firstRelationshipIds[Pair.of(typeId, INCOMING)], @in);
                assertEquals(firstRelationshipIds[Pair.of(typeId, BOTH)], loop);
                return(0);
            };

            _cache.getFirstRel(nodeId, visitor);

            // THEN
            assertEquals(typeCount, visitCount.get());
        }