public NameTableUniversal(string path) { this.path = path; PType tp_tabelement = new PTypeRecord( new NamedType("code", new PType(PTypeEnumeration.integer)), new NamedType("str", new PType(PTypeEnumeration.sstring))); this.table = new TableView(path + "cstable", tp_tabelement); //next_code = (int)table.Count(); offset_array = new IndexViewImmutable<int>(path + "offsets") { Table = this.table, KeyProducer = pair => (int)((object[])(((object[])pair)[1]))[0], tosort = false }; offsets = new IndexDynamic<int, IndexViewImmutable<int>>(true) { Table = this.table, //KeyProducer = pair => (int)((object[])pair)[0], KeyProducer = pair => (int)((object[])(((object[])pair)[1]))[0], IndexArray = offset_array }; table.RegisterIndex(offsets); s_index_array_path = path + "s_index"; s_index_array = new IndexHalfkeyImmutable<string>(s_index_array_path) { Table = table, KeyProducer = pair => (string)((object[])(((object[])pair)[1]))[1], HalfProducer = key => key.GetHashModifiedBernstein() }; s_index_array.Scale = new ScaleCell(path + "dyna_index_str_half") { IndexCell = s_index_array.IndexCell }; //s_index_array.Scale = new ScaleMemory() { IndexCell = s_index_array.IndexCell }; s_index = new IndexDynamic<string, IndexHalfkeyImmutable<string>>(true) { Table = table, KeyProducer = pair => (string)((object[])(((object[])pair)[1]))[1], IndexArray = s_index_array }; table.RegisterIndex(s_index); }
public Stan3TabsInt(string path) { PType tp_person = new PTypeRecord( new NamedType("code", new PType(PTypeEnumeration.integer)), new NamedType("name", new PType(PTypeEnumeration.sstring)), new NamedType("age", new PType(PTypeEnumeration.integer))); PType tp_photo_doc = new PTypeRecord( new NamedType("code", new PType(PTypeEnumeration.integer)), new NamedType("name", new PType(PTypeEnumeration.sstring))); PType tp_reflection = new PTypeRecord( new NamedType("code", new PType(PTypeEnumeration.integer)), // Может не быть new NamedType("reflected", new PType(PTypeEnumeration.integer)), // ссылки на коды new NamedType("in_doc", new PType(PTypeEnumeration.integer))); tab_person = new TableView(path + "person", tp_person); tab_photo_doc = new TableView(path + "photo_doc", tp_photo_doc); tab_reflection = new TableView(path + "reflection", tp_reflection); // Индексы: Персона Func<object, int> person_code_keyproducer = v => (int)((object[])((object[])v)[1])[0]; ind_arr_person = new IndexKeyImmutable<int>(path + "person_ind") { Table = tab_person, KeyProducer = person_code_keyproducer, Scale = null }; //ind_arr_person.Scale = new ScaleCell(path + "person_ind") { IndexCell = ind_arr_person.IndexCell }; //ind_arr_person.Scale.Build(); index_person = new IndexDynamic<int, IndexKeyImmutable<int>>(true) { Table = tab_person, IndexArray = ind_arr_person, KeyProducer = person_code_keyproducer }; // Индексы - документ Func<object, int> photo_doc_code_keyproducer = v => (int)((object[])((object[])v)[1])[0]; ind_arr_photo_doc = new IndexKeyImmutable<int>(path + "photo_doc_ind") { Table = tab_photo_doc, KeyProducer = photo_doc_code_keyproducer, Scale = null }; //ind_arr_photo_doc.Scale = new ScaleCell(path + "photo_doc_ind") { IndexCell = ind_arr_photo_doc.IndexCell }; //ind_arr_photo_doc.Scale.Build(); index_photo_doc = new IndexDynamic<int, IndexKeyImmutable<int>>(true) { Table = tab_photo_doc, IndexArray = ind_arr_photo_doc, KeyProducer = photo_doc_code_keyproducer }; // Индекс - reflection-reflected Func<object, int> reflected_keyproducer = v => (int)((object[])((object[])v)[1])[1]; ind_arr_reflected = new IndexKeyImmutable<int>(path + "reflected_ind") { Table = tab_reflection, KeyProducer = reflected_keyproducer, Scale = null }; //ind_arr_reflected.Scale = new ScaleCell(path + "reflected_ind") { IndexCell = ind_arr_reflected.IndexCell }; //ind_arr_reflected.Scale.Build(); index_reflected = new IndexDynamic<int, IndexKeyImmutable<int>>(false) { Table = tab_reflection, IndexArray = ind_arr_reflected, KeyProducer = reflected_keyproducer }; // Индекс - reflection-in_doc Func<object, int> in_doc_keyproducer = v => (int)((object[])((object[])v)[1])[2]; ind_arr_in_doc = new IndexKeyImmutable<int>(path + "in_doc_ind") { Table = tab_reflection, KeyProducer = in_doc_keyproducer, Scale = null }; //ind_arr_in_doc.Scale = new ScaleCell(path + "in_doc_ind") { IndexCell = ind_arr_in_doc.IndexCell }; //ind_arr_in_doc.Scale.Build(); index_in_doc = new IndexDynamic<int, IndexKeyImmutable<int>>(false) { Table = tab_reflection, IndexArray = ind_arr_in_doc, KeyProducer = in_doc_keyproducer }; Func<object, string> name_keyproducer = v => (string)((object[])((object[])v)[1])[1]; ind_arr_person_name = new IndexViewImmutable<string>(path + "personname_ind") { Table = tab_person, KeyProducer = name_keyproducer, Scale = null }; //ind_arr_person_name.Scale = new ScaleCell(path + "personname_ind") {IndexCell = ind_arr_in_doc.IndexCell}; //ind_arr_person_name.Scale.Build(); index_person_name = new IndexDynamic<string, IndexViewImmutable<string>>(false) { Table = tab_person, IndexArray = ind_arr_person_name, KeyProducer = name_keyproducer }; tab_person.RegisterIndex(index_person); tab_person.RegisterIndex(index_person_name); tab_photo_doc.RegisterIndex(index_photo_doc); tab_reflection.RegisterIndex(index_reflected); tab_reflection.RegisterIndex(index_in_doc); }