private int MakeTreeFree(PaCell otriples, PaCell otriples_op, PaCell dtriples_sp) { // Делаю три сканера из трех ячеек DiapasonScanner <SubjPredInt> fields = new DiapasonScanner <SubjPredInt>(dtriples_sp, ent => { object[] v = (object[])ent.Get(); return(new SubjPredInt() { subj = (int)v[0], pred = (int)v[1] }); }); DiapasonScanner <SubjPredInt> direct = new DiapasonScanner <SubjPredInt>(otriples, ent => { object[] v = (object[])ent.Get(); return(new SubjPredInt() { subj = (int)v[0], pred = (int)v[1] }); }); DiapasonScanner <SubjPredInt> inverse = new DiapasonScanner <SubjPredInt>(otriples_op, ent => { object[] v = (object[])ent.Get(); return(new SubjPredInt() { subj = (int)v[2], pred = (int)v[1] }); }); // Стартуем сканеры fields.Start(); direct.Start(); inverse.Start(); // Заведем ячейку для результата сканирования PaCell tree_free = new PaCell(tp_entitiesTree, path + "tree_free.pac", false); tree_free.Clear(); int cnt_e = 0, cnt_ep = 0; // для отладки long c1 = 0, c2 = 0, c3 = 0; // для отладки //PaEntry ent_dtriples = dtriples.Root.Element(0); // вход для доступа к литералам // Начинаем тройное сканирование tree_free.StartSerialFlow(); tree_free.S(); while (fields.HasValue || direct.HasValue || inverse.HasValue) { // Здесь у нас НОВОЕ значение идентификатора cnt_e++; if (cnt_e % 10000000 == 0) { Console.Write("{0} ", cnt_e / 10000000); } int id0 = fields.HasValue ? fields.KeyCurrent.subj : Int32.MaxValue; int id1 = direct.HasValue ? direct.KeyCurrent.subj : Int32.MaxValue; int id2 = inverse.HasValue ? inverse.KeyCurrent.subj : Int32.MaxValue; // Минимальное значение кода идентификатора int id = Math.Min(id0, Math.Min(id1, id2)); // Начало записи tree_free.R(); // Запись идентификатора tree_free.V(id); tree_free.S(); while (fields.HasValue && fields.KeyCurrent.subj == id) { int su = fields.KeyCurrent.subj; int pr = fields.KeyCurrent.pred; var diap = fields.Next(); c3 += diap.numb; for (long ind = diap.start; ind < diap.start + diap.numb; ind++) { object[] row = (object[])dtriples_sp.Root.Element(ind).Get(); int subj = (int)row[0]; int prop = (int)row[1]; long off = (long)row[2]; if (subj != su || prop != pr) { throw new Exception("Assert err: 287282"); } tree_free.V(new object[] { prop, off }); } } tree_free.Se(); tree_free.S(); while (direct.HasValue && direct.KeyCurrent.subj == id) { int su = direct.KeyCurrent.subj; int pr = direct.KeyCurrent.pred; var diap = direct.Next(); c1 += diap.numb; for (long ind = diap.start; ind < diap.start + diap.numb; ind++) { object[] row = (object[])otriples.Root.Element(ind).Get(); int subj = (int)row[0]; int prop = (int)row[1]; int obj = (int)row[2]; if (subj != su || prop != pr) { throw new Exception("Assert err: 287283"); } tree_free.V(new object[] { prop, obj }); } } tree_free.Se(); tree_free.S(); while (inverse.HasValue && inverse.KeyCurrent.subj == id) { int su = inverse.KeyCurrent.subj; int pr = inverse.KeyCurrent.pred; var diap = inverse.Next(); c2 += diap.numb; tree_free.R(); tree_free.V(pr); tree_free.S(); for (long ind = diap.start; ind < diap.start + diap.numb; ind++) { object[] row = (object[])otriples_op.Root.Element(ind).Get(); int subj = (int)row[0]; int prop = (int)row[1]; int obj = (int)row[2]; if (obj != su || prop != pr) { throw new Exception("Assert err: 287284"); } tree_free.V(subj); } tree_free.Se(); tree_free.Re(); } tree_free.Se(); // Конец записи tree_free.Re(); } tree_free.Se(); tree_free.EndSerialFlow(); return(cnt_e); }