public void TestWAHBitArray4()
        {
            var b     = new WAHBitArray();
            int count = 25;

            for (int i = 0; i < 5; i++)
            {
                b.Set(i, true);
            }
            for (int i = 5; i < count + 5; i++)
            {
                b.Set(i, false);
            }
            for (int i = 30; i < 64; i++)
            {
                b.Set(i, i != 35);
            }
            for (int i = 64; i < 100; i++)
            {
                b.Set(i, true);
            }
            var expected = b.GetBitIndexes().ToArray();
            var b2       = new WAHBitArray(WAHBitArray.TYPE.Compressed_WAH, b.GetCompressed());
            var actual   = b2.GetBitIndexes().ToArray();

            expected.Should(Be.EqualTo(actual));
        }
        public void TestWAHBitArray1()
        {
            var b     = new WAHBitArray();
            int count = 31;

            for (int i = 0; i < count; i++)
            {
                b.Set(i, true);
            }
            var expected = b.GetBitIndexes().ToArray();
            var b2       = new WAHBitArray(WAHBitArray.TYPE.Compressed_WAH, b.GetCompressed());
            var actual   = b2.GetBitIndexes().ToArray();

            expected.Should(Be.EqualTo(actual));
        }
Пример #3
0
        public void DumpPFNIndex()
        {
            if (!Vtero.VerboseOutput)
            {
                return;
            }

            var idx = pfnTableIdx.GetBitIndexes();
            int i   = 0;

            Console.WriteLine("Dumping PFN index");
            foreach (var pfn in idx)
            {
                Console.Write("{pfn:X8} ");
                i += 8;
                if (i >= Console.WindowWidth - 7)
                {
                    Console.Write(Environment.NewLine);
                }
            }
        }
Пример #4
0
        private Result <T> ReturnRows2 <T>(WAHBitArray ba, List <T> trows, int start, int count, List <int> orderby)
        {
            DateTime   dt   = FastDateTime.Now;
            List <T>   rows = new List <T>();
            Result <T> ret  = new Result <T>();
            int        skip = start;
            int        c    = 0;

            ret.TotalCount = (int)ba.CountOnes();
            if (count == -1)
            {
                count = ret.TotalCount;
            }
            if (count > 0)
            {
                foreach (int i in orderby)
                {
                    if (ba.Get(i))
                    {
                        if (skip > 0)
                        {
                            skip--;
                        }
                        else
                        {
                            bool b = OutputRow <T>(rows, i);
                            if (b && count > 0)
                            {
                                c++;
                            }
                        }
                        ba.Set(i, false);
                        if (c == count)
                        {
                            break;
                        }
                    }
                }
                foreach (int i in ba.GetBitIndexes())
                {
                    if (c < count)
                    {
                        if (skip > 0)
                        {
                            skip--;
                        }
                        else
                        {
                            bool b = OutputRow <T>(rows, i);
                            if (b && count > 0)
                            {
                                c++;
                            }
                        }
                        if (c == count)
                        {
                            break;
                        }
                    }
                }
            }
            if (trows != null)// TODO : move to start and decrement in count
            {
                foreach (var o in trows)
                {
                    rows.Add(o);
                }
            }
            _log.Debug("query rows fetched (ms) : " + FastDateTime.Now.Subtract(dt).TotalMilliseconds);
            _log.Debug("query rows count : " + rows.Count.ToString("#,0"));
            ret.OK    = true;
            ret.Count = rows.Count;
            ret.Rows  = rows;
            return(ret);
        }