private static void TestSerialInput(ISerialFlow sflow, string path) { XElement db = XElement.Load(path + @"0001.xml"); var query = db.Elements().Where(el => el.Attribute(sema2012m.ONames.rdfabout) != null); sflow.StartSerialFlow(); sflow.S(); foreach (var xelement in query) { string about = xelement.Attribute(sema2012m.ONames.rdfabout).Value; sflow.V(new object[] { 1, new object[] { about, sema2012m.ONames.rdftypestring, xelement.Name.NamespaceName + xelement.Name.LocalName } }); foreach (var prop in xelement.Elements()) { string resource_ent = prop.Name.NamespaceName + prop.Name.LocalName; XAttribute resource = prop.Attribute(sema2012m.ONames.rdfresource); if (resource != null) { sflow.V(new object[] { 1, new object[] { about, resource_ent, resource.Value } }); } else { sflow.V(new object[] { 2, new object[] { about, resource_ent, prop.Value, "" } }); } } } sflow.Se(); sflow.EndSerialFlow(); }
// Генератор тестовых данных private static void GenerateSerialTestFlow(int volume, ISerialFlow receiver) { receiver.StartSerialFlow(); receiver.S(); for (int ii = 0; ii < volume; ii++) { receiver.S(); int num = ii % 1000 == 0 ? 100 : 1; receiver.V(ii); for (int jj = 0; jj < num; jj++) { receiver.V(jj); } receiver.Se(); } receiver.Se(); receiver.EndSerialFlow(); }
private static void TripletSerialInput(ISerialFlow sflow, IEnumerable <string> rdf_filenames) { sflow.StartSerialFlow(); sflow.S(); foreach (string db_falename in rdf_filenames) { ReadXML2Quad(db_falename, (id, property, value, isObj, lang) => sflow.V(isObj ? new object[] { 1, new object[] { id, property, value } } : new object[] { 2, new object[] { id, property, value, lang ?? "" } })); } sflow.Se(); sflow.EndSerialFlow(); }
// ============ Технические методы ============ private void FormingSerialGraph(ISerialFlow serial) { serial.StartSerialFlow(); serial.S(); int hs_e = Int32.MinValue; int vid = Int32.MinValue; int vidstate = 0; int hs_p = Int32.MinValue; bool firsttime = true; bool firstprop = true; foreach (object[] el in quads.Root.Elements().Select(e => e.Value)) { FourFields record = new FourFields((int)el[0], (int)el[1], (int)el[2], (long)el[3]); if (firsttime || record.e_hs != hs_e) { // Начало новой записи firstprop = true; if (!firsttime) { // Закрыть предыдущую запись serial.Se(); serial.Re(); serial.Se(); while (vid < 2 && vidstate <= 2) { serial.S(); serial.Se(); vidstate += 1; } serial.Re(); } vidstate = 0; hs_e = record.e_hs; serial.R(); serial.V(record.e_hs); vid = record.vid; while (vidstate < vid) { serial.S(); serial.Se(); vidstate += 1; } vidstate += 1; serial.S(); } else if (record.vid != vid) { serial.Se(); serial.Re(); firstprop = true; serial.Se(); vid = record.vid; while (vid != vidstate) { serial.S(); serial.Se(); vidstate += 1; } vidstate += 1; serial.S(); } if (firstprop || record.p_hs != hs_p) { hs_p = record.p_hs; if (!firstprop) { serial.Se(); serial.Re(); } firstprop = false; serial.R(); serial.V(record.p_hs); serial.S(); } serial.V(record.off); firsttime = false; } if (!firsttime) { // Закрыть последнюю запись serial.Se(); serial.Re(); serial.Se(); while (vid < 2 && vidstate <= 2) { serial.S(); serial.Se(); vidstate += 1; } serial.Re(); } serial.Se(); serial.EndSerialFlow(); }