예제 #1
0
        public void TestGroupVisitor()
        {
            var visitor = new GroupVisitor(provider, option, new List <IFuncVisit>());
            Expression <Func <Peoples, object> > ex = t => new { t.Age, t.BirthDay };
            var a   = visitor.Visit(ex);
            var sql = new StringBuilder(visitor.GetSql().ToString().Trim());

            _queryBuilder.RenameTableType(sql, visitor.GetTableDic(), null, visitor.GroupDic);
            Assert.AreEqual("group by `Peoples`.`Age`,`Peoples`.`BirthDay`", sql.ToString());

            ex  = t => t.Age;
            a   = visitor.Visit(ex);
            sql = new StringBuilder(visitor.GetSql().ToString().Trim());

            _queryBuilder.RenameTableType(sql, visitor.GetTableDic(), null, visitor.GroupDic);
            Assert.AreEqual("group by `Peoples`.`Age`", sql.ToString());
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldKeepNextGroupIdForNextRound()
        public virtual void ShouldKeepNextGroupIdForNextRound()
        {
            // GIVEN
            _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1, 100, Base);
            long nodeId = 0;
            int  typeId = 10;

            _cache.NodeCount = nodeId + 1;
            _cache.incrementCount(nodeId);
            GroupVisitor groupVisitor = mock(typeof(GroupVisitor));

            when(groupVisitor.Visit(anyLong(), anyInt(), anyLong(), anyLong(), anyLong())).thenReturn(1L, 2L, 3L);

            long firstRelationshipGroupId;
            {
                // WHEN importing the first type
                long relationshipId = 10;
                _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, true);
                firstRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor);

                // THEN
                assertEquals(1L, firstRelationshipGroupId);
                verify(groupVisitor).visit(nodeId, typeId, relationshipId, -1L, -1L);

                // Also simulate going back again ("clearing" of the cache requires this)
                _cache.setForwardScan(false, true);
                _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, false);
                _cache.setForwardScan(true, true);
            }

            long secondRelationshipGroupId;
            {
                // WHEN importing the second type
                long relationshipId = 11;
                _cache.getAndPutRelationship(nodeId, typeId, INCOMING, relationshipId, true);
                secondRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor);

                // THEN
                assertEquals(2L, secondRelationshipGroupId);
                verify(groupVisitor).visit(nodeId, typeId, -1, relationshipId, -1L);

                // Also simulate going back again ("clearing" of the cache requires this)
                _cache.setForwardScan(false, true);
                _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, false);
                _cache.setForwardScan(true, true);
            }

            {
                // WHEN importing the third type
                long relationshipId = 10;
                _cache.getAndPutRelationship(nodeId, typeId, BOTH, relationshipId, true);
                long thirdRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor);
                assertEquals(3L, thirdRelationshipGroupId);
                verify(groupVisitor).visit(nodeId, typeId, -1L, -1L, relationshipId);
            }
        }
예제 #3
0
            internal virtual long VisitGroup(long nodeId, long relGroupIndex, GroupVisitor visitor)
            {
                long currentIndex = Rebase(relGroupIndex);
                long first        = EMPTY;

                while (currentIndex != EMPTY)
                {
                    ByteArray array  = this.Array.at(currentIndex);
                    long      @out   = All48Bits(array, currentIndex, IdOffset(Direction.OUTGOING));
                    int       typeId = GetTypeId(array, currentIndex);
                    long      @in    = All48Bits(array, currentIndex, IdOffset(Direction.INCOMING));
                    long      loop   = All48Bits(array, currentIndex, IdOffset(Direction.BOTH));
                    long      next   = GetNext(array, currentIndex);
                    long      nextId = @out == EMPTY && @in == EMPTY && loop == EMPTY ? EMPTY : visitor.Visit(nodeId, typeId, @out, @in, loop);
                    if (first == EMPTY)
                    {                              // This is the one we return
                        first = nextId;
                    }
                    currentIndex = next;
                }
                return(first);
            }
예제 #4
0
 public override void Accept(GroupVisitor visitor)
 {
     visitor.Visit(this);
 }