Пример #1
0
 public override void Init(string connectionstring)
 {
     string prefix = "polar:";
     if (!connectionstring.StartsWith(prefix)) throw new Exception(string.Format("Err: wrong connectionstring for PBEAdapter [{0}]", connectionstring));
     connectionstring = connectionstring.Substring(prefix.Length);
     string[] parts = connectionstring.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
     foreach (string part in parts)
     {
         string param = part;
         int pos = part.IndexOf('=');
         string keyword = null;
         if (pos > 0)
         {
             keyword = part.Substring(0, pos).Trim().ToLower();
             param = part.Substring(pos + 1).Trim();
         }
         if (keyword == null || keyword == "path")
         {
             path = param;
         }
         else
         {
         }
         graph = new PolarBasedRdfGraph(connectionstring);
     }
 }
Пример #2
0
        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            string[] ids = new[]
            {
                "svet_100616111408_10844",
                "pavl_100531115859_2020",
                "piu_200809051791",
                "pavl_100531115859_6952",
                "svet_100616111408_10864",
                "w20090506_svetlana_5727",
                "piu_200809051742",
                "p0013313",
                "p0011098",
                "svet_100616111408_14354"
            };


            string path = @"..\..\..\Databases\";

            Console.WriteLine("Start");
            PolarBasedRdfGraph graph = new PolarBasedRdfGraph(path);
            bool toload = false;

            if (toload)
            {
                XElement db = XElement.Load(path + "0001.xml");
                graph.StartFillDb();
                graph.Load(db.Elements());
                graph.FinishFillDb();
            }

            //var query = graph.SearchByName("марчук");
            //foreach (XElement rec in query)
            //{
            //    Console.WriteLine(rec.ToString());
            //}
            watch.Start();
            var item = graph.GetItemByIdBasic("w20070417_5_8436", true);

            watch.Stop();
            Console.WriteLine(item.ToString());
            Console.WriteLine(watch.ElapsedTicks);

            watch.Restart();
            foreach (string id in ids)
            {
                graph.GetItemByIdBasic(id, true);
            }
            watch.Stop();
            Console.WriteLine(watch.ElapsedTicks);
        }
Пример #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Start");
            string path = @"D:\home\dev2012\PolarDemo\Databases\";

            string[] ids = new[]
            {
                "svet_100616111408_10844",
                "pavl_100531115859_2020",
                "piu_200809051791",
                "pavl_100531115859_6952",
                "svet_100616111408_10864",
                "w20090506_svetlana_5727",
                "piu_200809051742",
                "p0013313",
                "p0011098",
                "svet_100616111408_14354"
            };
            XElement formats             = XElement.Load(path + "ApplicationProfile.xml").Element("formats");
            XElement format              = formats.Elements("record").First(r => r.Attribute("type").Value == "http://fogid.net/o/person");
            bool     toload              = false;
            XElement db                  = null;
            IEnumerable <XElement> query = Enumerable.Empty <XElement>();

            DateTime tt0 = DateTime.Now;

            var graph = new PolarBasedRdfGraph(path);

            Console.WriteLine("graph ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            //toload = true;
            if (toload)
            {
                db    = XElement.Load(path + "0001.xml");
                query = db.Elements()
                        .Where(el => el.Attribute(ONames.rdfabout) != null);
                graph.StartFillDb();
                // Загрузка элементами или потоками элементов
                graph.Load(query);
                graph.FinishFillDb();
                Console.WriteLine("Load ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            }
            var xFlow = graph.SearchByName("марчук");

            foreach (XElement x in xFlow)
            {
                //Console.WriteLine(x.ToString());
            }
            Console.WriteLine("SearchByName ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;

            var xres = graph.GetItemByIdBasic("w20070417_5_8436", true); // Это я

            //var xres = graph.GetItemByIdBasic("piu_200809051508", true); // Это Г.И.
            //var xres = graph.GetItemByIdBasic("w20071030_1_20927", true); // Это Андрей
            Console.WriteLine("GetItemByIdBasic ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            foreach (string id in ids)
            {
                graph.GetItemByIdBasic(id, true);
            }
            Console.WriteLine("10 GetItemByIdBasic ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            xres = graph.GetItemById("w20070417_5_8436", format);
            //xres = engine.GetItemById("piu_200809051508", format);
            //if (xres != null) Console.WriteLine(xres.ToString());
            Console.WriteLine("GetItemById ok. Duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            foreach (string id in ids)
            {
                graph.GetItemById(id, format);
            }
            Console.WriteLine("10 GetItemById ok. Duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;

            //// Редактирование
            //XElement record1 = new XElement(ONames.tag_person, new XAttribute(ONames.rdfabout, "testzone_0001"),
            //    new XElement(ONames.tag_name, "Пупкин Василий Васильевич"),
            //    new XElement(ONames.tag_fromdate, "2013-11-22"));
            //graph.InsertXElement(record1);
            //Console.WriteLine("InsertXElement ok. Duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            //xFlow = graph.SearchByName("пупкин");
            //foreach (XElement x in xFlow)
            //{
            //    Console.WriteLine(x.ToString());
            //}
            //Console.WriteLine("SearchByName ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            //xres = graph.GetItemByIdBasic("testzone_0001", true); // Это Пупкин
            //if (xres != null) Console.WriteLine(xres.ToString());

            //graph.Delete("testzone_0001");
            //xFlow = graph.SearchByName("пупкин");
            //foreach (XElement x in xFlow)
            //{
            //    Console.WriteLine(x.ToString());
            //}
            //Console.WriteLine("Delete ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            //xres = graph.GetItemByIdBasic("testzone_0001", true); // Это Пупкин
            //if (xres != null) Console.WriteLine(xres.ToString());
            tt0 = DateTime.Now;
            graph.GetItemByIdB("w20070417_5_8436", true); // Это я
            Console.WriteLine("GetItemByIdB ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            tt0 = DateTime.Now;
            foreach (string id in ids)
            {
                graph.GetItemByIdB(id, true);
            }
            Console.WriteLine("10 GetItemByIdB ok. Duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
        }