public static IEnumerable <OValRowInt> Berlin6(TripleStoreInt ts) { short _product = 0, _label = 1; short _bsbm_Product = 2; short _rdftype = 3, _rdfslabel = 4; OVal[] row = new OVal[] { new OVal() { vid = OValEnumeration.obj }, // _product new OVal() { vid = OValEnumeration.val }, // _label new OVal() { vid = OValEnumeration.obj, entity = E(bsbm + "Product") }, rdftype, rdfslabel, }; System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex("^s"); OValRowInt ovr = new OValRowInt(ts, row); var quer = Enumerable.Repeat <OValRowInt>(ovr, 1) ._Spo(_product, _rdftype, _bsbm_Product) ._spD(_product, _rdfslabel, _label) .Where(ovalrow => rx.IsMatch(((Text)ovalrow.row[_label].lit.value).s)) ; return(quer); }
public static IEnumerable <RPackInt> Query2param(TripleStoreInt ts, string sprod) { object[] row = new object[13]; short _label = 0, _comment = 1, _producer = 2, _productFeature = 3, _propertyTextual1 = 4, _propertyTextual2 = 5, _propertyTextual3 = 5, _propertyNumeric1 = 6, _propertyNumeric2 = 7, _propertyTextual4 = 8, _propertyTextual5 = 9, _prolertyNumeric4 = 10; short _p = 11, _f = 12; var quer = Enumerable.Repeat <RPackInt>(new RPackInt(row, ts), 1) .spD(E(sprod), E(rdfs + "label"), _label) .spD(E(sprod), E(rdfs + "comment"), _comment) .spO(E(sprod), E(bsbm + "producer"), _p) .spD(_p, E(rdfs + "label"), _producer) .spo(E(sprod), E(dc + "publisher"), _p) .spO(E(sprod), E(bsbm + "productFeature"), _f) .spD(_f, E(rdfs + "label"), _productFeature) // Следующая группа может быть переставлена из конца в середину, будет быстрее .spD(E(sprod), E(bsbm + "productPropertyTextual1"), _propertyTextual1) .spD(E(sprod), E(bsbm + "productPropertyTextual2"), _propertyTextual2) .spD(E(sprod), E(bsbm + "productPropertyTextual3"), _propertyTextual3) .spD(E(sprod), E(bsbm + "productPropertyNumeric1"), _propertyNumeric1) .spD(E(sprod), E(bsbm + "productPropertyNumeric2"), _propertyNumeric2) ; return(quer); }
public static IEnumerable <OValRowInt> Berlin1(TripleStoreInt ts) { _ts = ts; short _product = 0, _bsbm_productFeature = 1, _bsbm_inst_ProductFeature19 = 2, _bsbm_inst_ProductFeature8 = 3; short _rdftype = 4, _bsbm_inst_ProductType1 = 5, _bsbm_ProductPropertyNumeric1 = 6; short _value1 = 7, _label = 8, _rdfslabel = 9; OVal[] row = new OVal[] { new OVal() { vid = OValEnumeration.obj }, // _product new OVal() { vid = OValEnumeration.obj, entity = E(bsbm + "productFeature") }, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductFeature19") }, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductFeature8") }, rdftype, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductType1") }, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm + "productPropertyNumeric1") }, new OVal() { vid = OValEnumeration.val }, // _value1 new OVal() { vid = OValEnumeration.val }, // _label rdfslabel }; OValRowInt ovr = new OValRowInt(ts, row); var quer = Enumerable.Repeat <OValRowInt>(ovr, 1) ._Spo(_product, _bsbm_productFeature, _bsbm_inst_ProductFeature19) ._spo(_product, _bsbm_productFeature, _bsbm_inst_ProductFeature8) ._spo(_product, _rdftype, _bsbm_inst_ProductType1) ._spD(_product, _bsbm_ProductPropertyNumeric1, _value1) .Where(ovalrow => (int)ovalrow.row[_value1].lit.Value > 1000) ._spD(_product, _rdfslabel, _label) ; return(quer); }
public static IEnumerable <RPackInt> Query6(TripleStoreInt ts) { System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex("^s"); object[] row = new object[2]; short _product = 0, _label = 1; var quer = Enumerable.Repeat <RPackInt>(new RPackInt(row, ts), 1) .Spo(_product, E(rdf + "type"), E(bsbm + "Product")) .spD(_product, E(rdfs + "label"), _label) .Where(pack => rx.IsMatch(((Text)pack.Val(_label).value).s)) ; return(quer); }
// Тестовый запрос для экспериментов public static IEnumerable <RPackInt> Query0(TripleStoreInt ts) { object[] row = new object[3]; short _produc = 0, _value1 = 1, _label = 2; var quer = Enumerable.Repeat <RPackInt>(new RPackInt(row, ts), 1) .Spo(_produc, bsbm + "productFeature", bsbm_inst + "ProductFeature19") //.spo(_produc, bsbm + "productFeature", bsbm_inst + "ProductFeature8") //.spo(_produc, rdf + "type", bsbm_inst + "ProductType1") //.spD(_produc, bsbm + "productPropertyNumeric1", _value1) //.Where(pack => pack.Vai(_value1) > 10) //.spD(_produc, rdfs + "label", _label) ; return(quer); }
// Вариант первого теста public static IEnumerable <QueryNodesSet> Query1_1(TripleStoreInt ts) { object[] row = new object[3]; short _produc = 0, _value1 = 1, _label = 2; var quer = Enumerable.Repeat <QueryNodesSet>(new QueryNodesSet(row, ts), 1) .Spo(_produc, E(bsbm + "productFeature"), E(bsbm_inst + "ProductFeature17")) //.spo(_produc, E(bsbm + "productFeature"), E(bsbm_inst + "ProductFeature7")) //.spo(_produc, E(rdf + "type"), E(bsbm_inst + "ProductType1")) //.spD(_produc, E(bsbm + "productPropertyNumeric1"), _value1) //.Where(pack => pack.Vai(_value1) > 10) //.spD(_produc, E(rdfs + "label"), _label) ; return(quer); }
// Вариант третьего теста public static IEnumerable <RPackInt> Query3_1(TripleStoreInt ts) { object[] row = new object[5]; short _product = 0, _label = 1; short _p1 = 2, _p3 = 3, _testVar = 4; var quer = Enumerable.Repeat <RPackInt>(new RPackInt(row, ts), 1) .Spo(_product, E(bsbm + "productFeature"), E(bsbm_inst + "ProductFeature1")) .spD(_product, E(rdfs + "label"), _label) .spo(_product, E(rdf + "type"), E(bsbm + "Product")) .spD(_product, E(bsbm + "productPropertyNumeric1"), _p1) .Where(pack => pack.Vai(_p1) > 500) .spD(_product, E(bsbm + "productPropertyNumeric3"), _p3) .Where(pack => pack.Vai(_p3) < 1000) ; return(quer); }
// Не выдает результатов, поэтому не доделан public static IEnumerable <RPackInt> Query2(TripleStoreInt ts) { object[] row = new object[13]; short _label = 0, _comment = 1, _producer = 2, _productFeature = 3, _propertyTextual1 = 4, _propertyTextual2 = 5, _propertyTextual3 = 5, _propertyNumeric1 = 6, _propertyNumeric2 = 7, _propertyTextual4 = 8, _propertyTextual5 = 9, _prolertyNumeric4 = 10; short _p = 11, f = 12; var quer = Enumerable.Repeat <RPackInt>(new RPackInt(row, ts), 1) .spD(E(bsbm_inst + "ProductType1"), E(rdfs + "label"), _label) .spD(E(bsbm_inst + "ProductType1"), E(rdfs + "comment"), _comment) .spO(E(bsbm_inst + "ProductType1"), E(bsbm + "producer"), _p) ; return(quer); }
private static void TestEWT(TripleStoreInt ts) { DateTime tt0 = DateTime.Now; EntitiesMemoryHashTable hashTable = new EntitiesMemoryHashTable(ts.ewt); hashTable.Load(); // Проверка построенной ewt Console.WriteLine("n_entities={0}", ts.ewt.EWTable.Root.Count()); bool notfirst = false; int code = Int32.MinValue; long cnt_otriples = 0; foreach (object[] row in ts.ewt.EWTable.Root.ElementValues()) { int cd = (int)row[0]; // Проверка на возрастание значений кода if (notfirst && cd <= code) { Console.WriteLine("ERROR!"); } code = cd; notfirst = true; // Проверка на то, что коды в диапазонах индексов совпадают с cd. Подсчитывается количество object[] odia = (object[])row[1]; long start = (long)odia[0]; long number = (long)odia[1]; foreach (object[] tri in ts.otriples.Root.ElementValues(start, number)) { int c = (int)tri[0]; if (c != cd) { Console.WriteLine("ERROR2!"); } } cnt_otriples += number; } if (cnt_otriples != ts.otriples.Root.Count()) { Console.WriteLine("ERROR3! cnt_triples={0} otriples.Root.Count()={1}", cnt_otriples, ts.otriples.Root.Count()); } Console.WriteLine("Проверка ewt OK. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; }
public static IEnumerable <RPackInt> Query5parameter(TripleStoreInt ts, string sprod) { string dataFromProducer1 = sprod; object[] row = new object[7]; short _product = 0, _productLabel = 1; short _prodFeature = 2, _origProperty1 = 3, _simProperty1 = 4, _origProperty2 = 5, _simProperty2 = 6; var quer = Enumerable.Repeat <RPackInt>(new RPackInt(row, ts), 1) .spO(E(dataFromProducer1), E(bsbm + "productFeature"), _prodFeature) .Spo(_product, E(bsbm + "productFeature"), _prodFeature) .Where(pack => E(dataFromProducer1) != pack.GetE(_product)) .spD(E(dataFromProducer1), E(bsbm + "productPropertyNumeric1"), _origProperty1) .spD(_product, E(bsbm + "productPropertyNumeric1"), _simProperty1) .Where(pack => pack.Vai(_simProperty1) < (pack.Vai(_origProperty1) + 120) && pack.Vai(_simProperty1) > (pack.Vai(_origProperty1) - 120)) .spD(E(dataFromProducer1), E(bsbm + "productPropertyNumeric2"), _origProperty2) .spD(_product, E(bsbm + "productPropertyNumeric2"), _simProperty2) .Where(pack => pack.Vai(_simProperty2) < (pack.Vai(_origProperty2) + 170) && pack.Vai(_simProperty2) > (pack.Vai(_origProperty2) - 170)) .spD(_product, E(rdfs + "label"), _productLabel) // переставлено ; return(quer); }
public static IEnumerable <RPackInt> Query5(TripleStoreInt ts) { string dataFromProducer1 = "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/dataFromProducer1/"; object[] row = new object[7]; short _product = 0, _productLabel = 1; short _prodFeature = 2, _origProperty1 = 3, _simProperty1 = 4, _origProperty2 = 5, _simProperty2 = 6; var quer = Enumerable.Repeat <RPackInt>(new RPackInt(row, ts), 1) .spO(E(dataFromProducer1 + "Product12"), E(bsbm + "productFeature"), _prodFeature) .Spo(_product, E(bsbm + "productFeature"), _prodFeature) .Where(pack => E(dataFromProducer1 + "Product12") != pack.GetE(_product)) //.spD(_product, E(rdfs + "label"), _productLabel) .spD(E(dataFromProducer1 + "Product12"), E(bsbm + "productPropertyNumeric1"), _origProperty1) .spD(_product, E(bsbm + "productPropertyNumeric1"), _simProperty1) .Where(pack => pack.Vai(_simProperty1) < (pack.Vai(_origProperty1) + 120) && pack.Vai(_simProperty1) > (pack.Vai(_origProperty1) - 120)) .spD(E(dataFromProducer1 + "Product12"), E(bsbm + "productPropertyNumeric2"), _origProperty2) .spD(_product, E(bsbm + "productPropertyNumeric2"), _simProperty2) .Where(pack => pack.Vai(_simProperty2) < (pack.Vai(_origProperty2) + 170) && pack.Vai(_simProperty2) > (pack.Vai(_origProperty2) - 170)) .spD(_product, E(rdfs + "label"), _productLabel) // переставлено ; return(quer); }
private static DateTime TestsOfMethods(string[] ids, TripleStoreInt ts) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); DateTime tt0 = DateTime.Now; // ======================= Сравнение бинарного поиска с вычислением диапазона ============= int pf19 = ids[5].GetHashCode(); List <long> trace = new List <long>(); Func <PaEntry, int> fdepth = ent => { counter++; trace.Add(ent.offset); return(((int)ent.Field(2).Get()).CompareTo(pf19)); }; sw.Restart(); counter = 0; trace.Clear(); var query = ts.otriples_op.Root.BinarySearchAll(fdepth); tt0 = DateTime.Now; int cc = query.Count(); sw.Stop(); Console.Write("Test BinarySearchAll: {0} ", cc); Console.WriteLine("Test swduration={0} duration={2} counter={1}", sw.Elapsed.Ticks, counter, (DateTime.Now - tt0).Ticks); tt0 = DateTime.Now; //foreach (int point in trace) Console.Write("{0} ", point); Console.WriteLine(); sw.Restart(); counter = 0; trace.Clear(); ts.otriples_op.Root.BinarySearchScan(0, ts.otriples_op.Root.Count(), fdepth); sw.Stop(); Console.Write("Test of BinaryScan: "); Console.WriteLine("swduration={0} counter={1}", sw.ElapsedTicks, trace.Count()); tt0 = DateTime.Now; //foreach (int point in trace) Console.Write("{0} ", point); Console.WriteLine(); sw.Restart(); counter = 0; trace.Clear(); ts.otriples_op.Root.BinarySearchScan(0, ts.otriples_op.Root.Count(), fdepth); sw.Stop(); Console.Write("Test of BinaryScan: "); Console.WriteLine("swduration={0} counter={1}", sw.ElapsedTicks, trace.Count()); tt0 = DateTime.Now; //foreach (int point in trace) Console.Write("{0} ", point); Console.WriteLine(); sw.Restart(); counter = 0; trace.Clear(); ts.otriples_op.Root.BinarySearchFirst(fdepth); sw.Stop(); Console.Write("Test of BinarySearchFirst: "); Console.WriteLine("swduration={0} counter={1}", sw.ElapsedTicks, trace.Count()); tt0 = DateTime.Now; //foreach (int point in trace) Console.Write("{0} ", point); Console.WriteLine(); sw.Restart(); counter = 0; trace.Clear(); Diapason diap = ts.otriples_op.Root.BinarySearchDiapason(0, ts.otriples_op.Root.Count(), fdepth); sw.Stop(); Console.Write("Test of Diapason: {0} {1} ", diap.start, diap.numb); Console.WriteLine(" swduration={0} counter={1}", sw.ElapsedTicks, counter); tt0 = DateTime.Now; //foreach (int point in trace) Console.Write("{0} ", point); Console.WriteLine(); sw.Restart(); counter = 0; trace.Clear(); ts.otriples_op.Root.BinarySearchFirst(fdepth); sw.Stop(); Console.Write("Test of BinarySearchFirst: "); Console.WriteLine("swduration={0} counter={1}", sw.ElapsedTicks, trace.Count()); tt0 = DateTime.Now; //foreach (int point in trace) Console.Write("{0} ", point); Console.WriteLine(); sw.Restart(); PaEntry test_ent = ts.otriples_op.Root.Element(0).Field(2); int val = -1; foreach (var point in trace) { test_ent.offset = point; val = (int)test_ent.Get(); } sw.Stop(); Console.Write("Test of series: "); Console.WriteLine("swduration={0}", sw.ElapsedTicks); tt0 = DateTime.Now; // ============ Конец сравнения ================ return(tt0); }
public static void Main(string[] args) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); string[] ids = new string[] { //"svet_100616111408_10844", //"pavl_100531115859_2020", //"piu_200809051791", //"pavl_100531115859_6952", //"svet_100616111408_10864", //"w20090506_svetlana_5727", //"piu_200809051742", //"p0013313", //"p0011098", //"svet_100616111408_14354" //"http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature13", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature4", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature8", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature11", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature3", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/Product", }; DateTime tt0 = DateTime.Now; Console.WriteLine("Start"); string path = "../../../Databases/"; //TripleStore<EntityS> ts = new TripleStore<EntityS>(path, new PolarDB.PType(PolarDB.PTypeEnumeration.sstring)); NameSpaceStore nameSpaceStore = new NameSpaceStore(path); TripleStoreInt ts = new TripleStoreInt(path, new StringIntMD5RAMCollision(path), new PredicatesCoding(path), nameSpaceStore, new LiteralStore(path, nameSpaceStore)); Console.WriteLine("InitTripleStore duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; bool toload = true; if (toload) { //ts.LoadXML(path + "0001.xml"); //Console.WriteLine("LoadXML ok."); PolarDB.PaEntry.bufferBytes = 1000000000; //2*1000*1000*1000; //ts.LoadTurtle(@"D:\deployed\dataset_100M.ttl"); ts.LoadTurtle(@"D:\home\FactographDatabases\dataset\dataset10m.ttl", true); Console.WriteLine("LoadTurtle ok."); Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; return; } ts.WarmUp(); Console.WriteLine("WarmUp duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; bool run148q5 = true; if (run148q5) { int cnt = 500;//BerlinTestsInt.sarr.Count(); long dur; DateTime tt00 = DateTime.Now; bool secondtest = true; if (secondtest) { foreach (var sprod in BerlinTestsInt.sarr) { var query = BerlinTestsInt.Query2param(ts, sprod); Console.WriteLine("22222 {0} d={1}", query.Count(), (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; } dur = (DateTime.Now - tt00).Ticks / 10000L; Console.WriteLine("Total time for {0} queries: {1}. Everage: {2}. QpS: {3}", cnt, dur, (double)dur / (double)cnt, cnt * 1000 / dur); tt00 = DateTime.Now; } bool fifthtest = false; if (fifthtest) { foreach (var sprod in Allproducts.Products.Take(2000)) { var query = BerlinTestsInt.Query5parameter(ts, sprod); query.Count(); } tt00 = DateTime.Now; foreach (var sprod in Allproducts.Products.Skip(2000).Take(cnt)) { var query = BerlinTestsInt.Query5parameter(ts, sprod); //var query = BerlinTestsInt.Query2param(ts, sprod); // Console.WriteLine("55555 {0} d={1}", query.Count(), (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; query.Count(); } dur = (DateTime.Now - tt00).Ticks / 10000L; Console.WriteLine("Total time for {0} queries: {1}. Everage: {2}. QpS: {3}", cnt, dur, (double)dur / (double)cnt, cnt * 1000 / dur); tt00 = DateTime.Now; } //tt00 = DateTime.Now; //foreach (var sprod in BerlinTestsInt.sarr) //{ // var query = BerlinTestsInt.Query5parameter(ts, sprod); // //var query = BerlinTestsInt.Query2param(ts, sprod); // Console.WriteLine("22222 {0} d={1}", query.Count(), (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //} //dur = (DateTime.Now - tt00).Ticks / 10000L; //Console.WriteLine("Total time for {0} queries: {1}. Everage: {2}. QpS: {3}", // cnt, dur, (double)dur / (double)cnt, cnt * 1000 / dur); } bool runpseudosoalqltests = false; if (runpseudosoalqltests) { var berlin1 = BerlinTestsInt.Berlin1(ts); tt0 = DateTime.Now; //var query0 = BerlinTests.Query0(ts); var query1 = BerlinTestsInt.Query1(ts); var query2 = BerlinTestsInt.Query2(ts); var query1_1 = BerlinTestsInt.Query1_1(ts); var berlin3 = BerlinTestsInt.Berlin3(ts); var query3 = BerlinTestsInt.Query3(ts); var query5 = BerlinTestsInt.Query5(ts); var berlin6 = BerlinTestsInt.Berlin6(ts); var query6 = BerlinTestsInt.Query6(ts); tt0 = DateTime.Now; //Console.WriteLine(query3.Count()); //Console.WriteLine("query0 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //return; //Console.WriteLine(query1_1.Count()); //Console.WriteLine("1_1 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; ts.TestsOfMethods(ids, ts); Console.WriteLine(query1.Count()); Console.WriteLine("1 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //Console.WriteLine(berlin1.Count()); //Console.WriteLine("Berlin1 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query2.Count()); Console.WriteLine("2 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //Console.WriteLine(berlin3.Count()); //Console.WriteLine("berlin3 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query3.Count()); Console.WriteLine("3 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query5.Count()); Console.WriteLine("5 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //Console.WriteLine(berlin6.Count()); //Console.WriteLine("berlin6 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query6.Count()); Console.WriteLine("6 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //foreach (var rw in query1) //{ // Console.WriteLine("{0} {1}", rw.row[1], rw.row[2]); //} //Console.WriteLine(); //foreach (var ovr in berlin1) //{ // Console.WriteLine("{0} {1}", ovr.row[7], ovr.row[8]); //} return; } bool pseudosparql = false; if (pseudosparql) { var query = BerlinTestsInt.Query3_1(ts); int count = 0; foreach (var pack in query) { count++; var row = pack.row; foreach (var val in row) { Console.Write("{0} ", val); } Console.WriteLine(); } Console.Write("{0} ", count); Console.WriteLine(); Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; return; } //bool run6 = false; //if (run6) //{ // tt0 = DateTime.Now; // foreach (string id in ids) // { // var query = // ts.GetSubjectByObjPred(id, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature") // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature8")) // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType1")) // .SelectMany(_product => ts.GetDataBySubjPred(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productPropertyNumeric1")) // ; // int cnt = query.Count(); // Console.WriteLine(cnt); // //if (id == "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19") // //foreach (var dd in query) // //{ // // Console.WriteLine("dd={0}", dd); // //} // } // Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //} // Контрольный расчет //{ // string id = "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19"; // var query = // ts.GetSubjectByObjPred(id, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature") // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature8")) // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType1")) // //.SelectMany(_product => ts.GetDataBySubjPred(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productPropertyNumeric1")) // ; // int cnt = query.Count(); // Console.WriteLine(cnt); // foreach (var vv in query) // { // Console.WriteLine("r=" + vv); // } //} //Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; }
public static void Main(string[] args) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); string[] ids = new string[] { //"svet_100616111408_10844", //"pavl_100531115859_2020", //"piu_200809051791", //"pavl_100531115859_6952", //"svet_100616111408_10864", //"w20090506_svetlana_5727", //"piu_200809051742", //"p0013313", //"p0011098", //"svet_100616111408_14354" //"http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature13", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature4", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature8", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature11", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature3", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/Product", }; DateTime tt0 = DateTime.Now; Console.WriteLine("Start"); string path = "../../../Databases/"; //TripleStore<EntityS> ts = new TripleStore<EntityS>(path, new PolarDB.PType(PolarDB.PTypeEnumeration.sstring)); TripleStoreInt ts = new TripleStoreInt(path); Console.WriteLine("InitTripleStore duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; bool toload = false; if (toload) { //ts.LoadXML(path + "0001.xml"); //Console.WriteLine("LoadXML ok."); PolarDB.PaEntry.bufferBytes = 1000000000; //2*1000*1000*1000; // ts.LoadTurtle(@"C:\deployed\1M.ttl"); ts.LoadTurtle(@"D:\home\FactographDatabases\dataset\dataset1m.ttl"); Console.WriteLine("LoadTurtle ok."); Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; return; } else { //ts.WarmUp(); //Console.WriteLine("WarmUp duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; } bool totrace = true; if (totrace) { XElement tracing = XElement.Load(@"D:\home\FactographDatabases\dataset\tracing100th.xml"); Console.WriteLine("N_tests = {0}", tracing.Elements().Count()); tt0 = DateTime.Now; int ecnt = 0, ncnt = 0; foreach (XElement spo in tracing.Elements()) { XAttribute s_att = spo.Attribute("subj"); XAttribute p_att = spo.Attribute("pred"); XAttribute o_att = spo.Attribute("obj"); XAttribute r_att = spo.Attribute("res"); string s = s_att == null ? null : s_att.Value; string p = p_att == null ? null : p_att.Value; string o = o_att == null ? null : o_att.Value; string res = r_att == null ? null : r_att.Value; if (spo.Name == "spo") { bool r = ts.ChkOSubjPredObj( s.GetHashCode(), p.GetHashCode(), o.GetHashCode()); if ((res == "true" && r) || (res == "false" && !r)) { ecnt++; } else { ncnt++; } } else if (spo.Name == "spD_") { Literal lit = ts.GetDataBySubjPred( s.GetHashCode(), p.GetHashCode()).FirstOrDefault(); if (lit == null) { ncnt++; } else { bool isEq = false; if (lit.vid == LiteralVidEnumeration.text && ((Text)lit.value).s == res.Substring(1, res.Length - 2)) { isEq = true; } else { isEq = lit.ToString() == res; } if (isEq) { ecnt++; } else { ncnt++; } } } else if (spo.Name == "spO_") { var query = ts.GetObjBySubjPred( s.GetHashCode(), p.GetHashCode()).OrderBy(v => v).ToArray(); if (query.Count() == 0 && res == "") { continue; } ecnt++; } else if (spo.Name == "Spo_") { var query = ts.GetSubjectByObjPred( o.GetHashCode(), p.GetHashCode()).OrderBy(v => v).ToArray(); if (query.Count() == 0 && res == "") { continue; } ecnt++; } } Console.WriteLine("tracing duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine("Equal {0} Not equal {1}", ecnt, ncnt); } bool run148q5 = false; if (run148q5) { int cnt = 500;//BerlinTestsInt.sarr.Count(); long dur; DateTime tt00 = DateTime.Now; bool secondtest = true; if (secondtest) { foreach (var sprod in BerlinTestsInt.sarr) { var query = BerlinTestsInt.Query2param(ts, sprod); Console.WriteLine("22222 {0} d={1}", query.Count(), (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; } dur = (DateTime.Now - tt00).Ticks / 10000L; Console.WriteLine("Total time for {0} queries: {1}. Everage: {2}. QpS: {3}", cnt, dur, (double)dur / (double)cnt, cnt * 1000 / dur); tt00 = DateTime.Now; } bool fifthtest = false; if (fifthtest) { foreach (var sprod in Allproducts.Products.Take(2000)) { var query = BerlinTestsInt.Query5parameter(ts, sprod); query.Count(); } tt00 = DateTime.Now; foreach (var sprod in Allproducts.Products.Skip(2000).Take(cnt)) { var query = BerlinTestsInt.Query5parameter(ts, sprod); //var query = BerlinTestsInt.Query2param(ts, sprod); // Console.WriteLine("55555 {0} d={1}", query.Count(), (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; query.Count(); } dur = (DateTime.Now - tt00).Ticks / 10000L; Console.WriteLine("Total time for {0} queries: {1}. Everage: {2}. QpS: {3}", cnt, dur, (double)dur / (double)cnt, cnt * 1000 / dur); tt00 = DateTime.Now; } //tt00 = DateTime.Now; //foreach (var sprod in BerlinTestsInt.sarr) //{ // var query = BerlinTestsInt.Query5parameter(ts, sprod); // //var query = BerlinTestsInt.Query2param(ts, sprod); // Console.WriteLine("22222 {0} d={1}", query.Count(), (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //} //dur = (DateTime.Now - tt00).Ticks / 10000L; //Console.WriteLine("Total time for {0} queries: {1}. Everage: {2}. QpS: {3}", // cnt, dur, (double)dur / (double)cnt, cnt * 1000 / dur); } bool runpseudosoalqltests = false; if (runpseudosoalqltests) { var berlin1 = BerlinTestsInt.Berlin1(ts); tt0 = DateTime.Now; //var query0 = BerlinTests.Query0(ts); var query1 = BerlinTestsInt.Query1(ts); var query2 = BerlinTestsInt.Query2(ts); var query1_1 = BerlinTestsInt.Query1_1(ts); var berlin3 = BerlinTestsInt.Berlin3(ts); var query3 = BerlinTestsInt.Query3(ts); var query5 = BerlinTestsInt.Query5(ts); var berlin6 = BerlinTestsInt.Berlin6(ts); var query6 = BerlinTestsInt.Query6(ts); tt0 = DateTime.Now; //Console.WriteLine(query3.Count()); //Console.WriteLine("query0 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //return; //Console.WriteLine(query1_1.Count()); //Console.WriteLine("1_1 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; TestsOfMethods(ids, ts); Console.WriteLine(query1.Count()); Console.WriteLine("1 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //Console.WriteLine(berlin1.Count()); //Console.WriteLine("Berlin1 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query2.Count()); Console.WriteLine("2 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //Console.WriteLine(berlin3.Count()); //Console.WriteLine("berlin3 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query3.Count()); Console.WriteLine("3 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query5.Count()); Console.WriteLine("5 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //Console.WriteLine(berlin6.Count()); //Console.WriteLine("berlin6 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; Console.WriteLine(query6.Count()); Console.WriteLine("6 duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //foreach (var rw in query1) //{ // Console.WriteLine("{0} {1}", rw.row[1], rw.row[2]); //} //Console.WriteLine(); //foreach (var ovr in berlin1) //{ // Console.WriteLine("{0} {1}", ovr.row[7], ovr.row[8]); //} return; } bool pseudosparql = false; if (pseudosparql) { var query = BerlinTestsInt.Query3_1(ts); int count = 0; foreach (var pack in query) { count++; var row = pack.row; foreach (var val in row) { Console.Write("{0} ", val); } Console.WriteLine(); } Console.Write("{0} ", count); Console.WriteLine(); Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; return; } //bool run6 = false; //if (run6) //{ // tt0 = DateTime.Now; // foreach (string id in ids) // { // var query = // ts.GetSubjectByObjPred(id, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature") // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature8")) // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType1")) // .SelectMany(_product => ts.GetDataBySubjPred(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productPropertyNumeric1")) // ; // int cnt = query.Count(); // Console.WriteLine(cnt); // //if (id == "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19") // //foreach (var dd in query) // //{ // // Console.WriteLine("dd={0}", dd); // //} // } // Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; //} // Контрольный расчет //{ // string id = "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature19"; // var query = // ts.GetSubjectByObjPred(id, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature") // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productFeature", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature8")) // .Where(_product => ts.ChkOSubjPredObj(_product, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType1")) // //.SelectMany(_product => ts.GetDataBySubjPred(_product, "http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/productPropertyNumeric1")) // ; // int cnt = query.Count(); // Console.WriteLine(cnt); // foreach (var vv in query) // { // Console.WriteLine("r=" + vv); // } //} //Console.WriteLine("duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now; }
public RPackInt(object[] row, TripleStoreInt ts) { this.row = row; this.ts = ts; }
public OValRowInt(TripleStoreInt ts, OVal[] row) { this.row = row; this.ts = ts; }
// Концовка теста не доделана public static IEnumerable <OValRowInt> Berlin3(TripleStoreInt ts) { short _product = 0, _label = 1; short _p1 = 2, _p3 = 3; short _bsbm_productFeature = 4, _bsbm_inst_ProductFeature1 = 5, _bsbm_Product = 6; short _rdftype = 7, _bsbm_ProductPropertyNumeric1 = 8, _bsbm_ProductPropertyNumeric3 = 9, _rdfslabel = 10; OVal[] row = new OVal[] { new OVal() { vid = OValEnumeration.obj }, // _product new OVal() { vid = OValEnumeration.val }, // _label new OVal() { vid = OValEnumeration.val }, // _p1 new OVal() { vid = OValEnumeration.val }, // _p2 new OVal() { vid = OValEnumeration.obj, entity = E(bsbm + "productFeature") }, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductFeature1") }, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm + "Product") }, rdftype, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm + "productPropertyNumeric1") }, new OVal() { vid = OValEnumeration.obj, entity = E(bsbm + "productPropertyNumeric3") }, rdfslabel, }; OValRowInt ovr = new OValRowInt(ts, row); var quer = Enumerable.Repeat <OValRowInt>(ovr, 1) ._Spo(_product, _bsbm_productFeature, _bsbm_inst_ProductFeature1) //._spD(_product, _rdfslabel, _label) //._spo(_product, _rdftype, _bsbm_Product) ._spD(_product, _bsbm_ProductPropertyNumeric1, _p1) //.Where(ovalrow => (int)ovalrow.row[_p1].lit.value > 1) //._spD(_product, _bsbm_ProductPropertyNumeric3, _p3) //.Where(ovalrow => (int)ovalrow.row[_p1].lit.value < 100000) //._spD(_product, _rdfslabel, _label) ; return(quer); }