Esempio n. 1
0
 private static void Load(PaCell cell)
 {
     cell.Clear();
     cell.Fill(new object[0]);
     for (int i = 0; i < 1000*1024*1024; i++)
     {
         cell.Root.AppendElement(i);
     }
     cell.Flush();
 }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            string _path = "../../";

            if (System.IO.File.Exists(_path + "cnf.xml"))
            {
                var xcnf = System.Xml.Linq.XElement.Load(_path + "cnf.xml");
                count = Int64.Parse(xcnf.Element("count").Value);
            }
            else
            {
                var xcnf = System.Xml.Linq.XElement.Parse(@"<cnf><count>10000000</count></cnf>");
                xcnf.Save(_path + "cnf.xml");
            }

            Stopwatch timer=new Stopwatch();

            PaCell sequnceCell = new PaCell(new PTypeSequence(new PType(PTypeEnumeration.longinteger)),
                "../../../Databases/sequnce for sort.pa", false);
            sequnceCell.Clear();
            timer.Start();
            sequnceCell.Fill(new object[0]);
               Random r = new Random();

            for (long i = 0L; i < count; i++)
            {
                sequnceCell.Root.AppendElement(count - i);
            }
            sequnceCell.Flush();
            timer.Stop();
            Console.WriteLine("created " + timer.Elapsed.TotalSeconds+"sec.");
            timer.Restart();
            sequnceCell.Root.SortByKey<long, long>(0, (ulong) sequnceCell.Root.Count(), l => l, row=>(long)row, l => (object)l, null);
            timer.Stop();
            Console.WriteLine("sorted " + timer.Elapsed.TotalSeconds + "sec.");
            Console.WriteLine(string.Join(", ", sequnceCell.Root.ElementValues(0, 20)));

            var query1 = sequnceCell.Root.BinarySearchFirst(entry => (int) ((long) entry.Get() - count/2));
            if (query1.IsEmpty)
                Console.WriteLine("search of first empty");
            Console.WriteLine("search of first end");
            var query = sequnceCell.Root.BinarySearchAll(ent => (int) ((long) ent.Get() - count/2)).ToArray();
            if(!query.Any())
                Console.WriteLine("search of all empty");
            Console.WriteLine("search of all end");

            //while (sequnceCell.Root.State!=PaSequenceEntry.StateEnum.Ready)
            //{

            //}
            timer.Restart();
            long old = (long)sequnceCell.Root.Element(0).Get();
            for (long i = 1; i < count; i++)
            {
                long entry2 = (long)sequnceCell.Root.Element(i).Get();
                if (old > entry2) Console.WriteLine("error");
                old = entry2;
                if (i % 100000000 == 0) Console.WriteLine(((double)i) / count * 100);
            }
            timer.Stop();
            Console.WriteLine(timer.Elapsed.TotalSeconds);
        }