private void Init_bldr_bmks() {
   if (!resume_enabled) // clear cfg entries if resume disabled; note that disabled by default;
     // DATE:2014-10-24
     bldr_cfg_tbl.Delete_grp(Cfg_fsdb_make);
   Db_cfg_hash bmk_hash = bldr_cfg_tbl.Select_as_hash(Cfg_fsdb_make);
   String tier_id_str = bmk_hash.Get_by(Cfg_tier_id_bmk).To_str_or(null);
   if (tier_id_str == null) { // bmks not found; new db;
     bldr_conn.Txn_bgn("bldr__fsdb_make__bldr_conn");
     bldr_cfg_tbl.Insert_int(Cfg_fsdb_make, Cfg_tier_id_bmk, tier_id_bmk);
     bldr_cfg_tbl.Insert_int(Cfg_fsdb_make, Cfg_page_id_bmk, page_id_bmk);
     bldr_cfg_tbl.Insert_int(Cfg_fsdb_make, Cfg_lnki_id_bmk, lnki_id_bmk);
     bldr_conn.Txn_end();
     if (tier_id_bmk == -1) tier_id_bmk = 0;
     if (page_id_bmk == -1) page_id_bmk = 0;
     if (lnki_id_bmk == -1) lnki_id_bmk = 0;
   } else {
     if (tier_id_bmk == -1) {
       tier_id_bmk = Int_.parse(tier_id_str);
       usr_dlg.Note_many("", "", "restoring from bmk: tier_id=~{0}", tier_id_bmk);
     }
     if (page_id_bmk == -1) {
       page_id_bmk = bmk_hash.Get_by(Cfg_page_id_bmk).To_int();
       usr_dlg.Note_many("", "", "restoring from bmk: page_id=~{0}", page_id_bmk);
     }
     if (lnki_id_bmk == -1) {
       lnki_id_bmk = bmk_hash.Get_by(Cfg_lnki_id_bmk).To_int();
       usr_dlg.Note_many("", "", "restoring from bmk: lnki_id=~{0}", lnki_id_bmk);
     }
   }
   tier_id_val = tier_id_bmk;
   page_id_val = page_id_bmk;
   lnki_id_val = lnki_id_bmk;
 }
 @Override
 public void Cmd_end() {
   usr_dlg.Note_many(
       "",
       "",
       "fsdb_make.done: count=~{0} rate=~{1}",
       exec_count,
       Decimal_adp_.divide_safe_(exec_count, System_.Ticks__elapsed_in_sec(time_bgn))
           .To_str("#,###.000"));
   if (src_fsdb_wkr != null) {
     src_fsdb_wkr.Mnt_mgr()
         .Mnts__get_main()
         .Txn_end(); // NOTE: src_fsdb_wkr will be null if no src db defined
   }
   trg_atr_fil.Conn().Txn_end();
   trg_atr_fil.Conn().Rls_conn();
   if (!trg_atr_fil.Conn().Eq(trg_cfg_mgr.Tbl().Conn())) // need to create txn for v1
   trg_cfg_mgr.Tbl().Conn().Txn_end();
   trg_cfg_mgr.Tbl().Conn().Rls_conn();
   if (!trg_mnt_itm.Db_mgr().File__solo_file()) {
     trg_bin_fil.Conn().Txn_end();
     trg_bin_fil.Conn().Rls_conn();
   }
   if (exec_done) {
     bldr_cfg_tbl.Delete_grp(Cfg_fsdb_make); // delete bmks for future reruns; DATE:2014-08-20
     Io_mgr.Instance.DeleteFil_args(wiki.Fsys_mgr().Root_dir().GenSubFil("xowa.file.make.cfg.gfs"))
         .MissingFails_off()
         .Exec();
   }
   bldr_conn.Rls_conn();
 }
Ejemplo n.º 3
0
 @Override
 public void Cmd_run() {
   wiki.Init_by_wiki();
   Xow_db_file core_db = wiki.Data__core_mgr().Db__core();
   Db_conn core_db_conn = core_db.Conn();
   Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
   usr_dlg.Plog_many("", "", "creating page_filter");
   if (!core_db_conn.Meta_tbl_exists("page_filter")) {
     core_db_conn.Meta_tbl_create(
         Dbmeta_tbl_itm.New(
             "page_filter",
             new Dbmeta_fld_itm[] {
               Dbmeta_fld_itm.new_int("page_id").Primary_y_(),
               Dbmeta_fld_itm.new_int("page_text_db_id")
             },
             Dbmeta_idx_itm.new_normal_by_tbl(
                 "page_filter", "db_id__page", "page_text_db_id", "page_id"),
             Dbmeta_idx_itm.new_normal_by_tbl("page_filter", "page_id", "page_id")));
   }
   core_db_conn.Exec_sql_plog_ntx(
       "finding missing redirects",
       String_.Concat_lines_nl_skip_last(
           "INSERT INTO page_filter (page_id, page_text_db_id)",
           "SELECT  ptr.page_id, ptr.page_text_db_id",
           "FROM    page ptr",
           "        LEFT JOIN page orig ON ptr.page_redirect_id = orig.page_id",
           "WHERE   ptr.page_is_redirect = 1",
           "AND     orig.page_id IS NULL",
           "UNION",
           "SELECT  ptr.page_id, ptr.page_text_db_id",
           "FROM    page ptr",
           "WHERE   ptr.page_is_redirect = 1",
           "AND     ptr.page_redirect_id = -1",
           ";"));
   try {
     Xow_db_file[] db_file_ary =
         core_db.Tbl__db().Select_all(wiki.Data__core_mgr().Props(), wiki.Fsys_mgr().Root_dir());
     int len = db_file_ary.length;
     for (int i = 0; i < len; ++i) {
       boolean db_file_is_text = Bool_.N, db_file_is_cat = Bool_.N, db_file_is_search = Bool_.N;
       Xow_db_file db_file = db_file_ary[i];
       switch (db_file.Tid()) {
         case Xow_db_file_.Tid__core:
         case Xow_db_file_.Tid__wiki_solo:
         case Xow_db_file_.Tid__text_solo:
           if (wiki.Data__core_mgr().Props().Layout_text().Tid_is_lot())
             continue; // if mode is lot, then "core" db does not have text, cat, search; skip;
           // DATE:2016-01-31
           db_file_is_text = db_file_is_cat = db_file_is_search = Bool_.Y;
           break;
         case Xow_db_file_.Tid__text:
           db_file_is_text = Bool_.Y;
           break;
         case Xow_db_file_.Tid__cat:
           db_file_is_cat = Bool_.Y;
           break;
         case Xow_db_file_.Tid__search_core:
           db_file_is_search = Bool_.Y;
           break;
       }
       int db_id = db_file.Id();
       if (db_file_is_text)
         Run_sql(
             core_db_conn,
             db_file.Url(),
             db_id,
             "deleting text: " + db_id,
             "DELETE FROM <data_db>text WHERE page_id IN (SELECT page_id FROM page_filter WHERE page_text_db_id = {0});");
       if (db_file_is_cat)
         Run_sql(
             core_db_conn,
             db_file.Url(),
             db_id,
             "deleting cat: " + db_id,
             "DELETE FROM <data_db>cat_link WHERE cl_from IN (SELECT page_id FROM page_filter);");
       if (db_file_is_search)
         Run_sql(
             core_db_conn,
             db_file.Url(),
             db_id,
             "deleting search:" + db_id,
             "DELETE FROM <data_db>search_link WHERE page_id IN (SELECT page_id FROM page_filter);");
       if (db_file_is_text || db_file_is_cat || db_file_is_search) db_file.Conn().Env_vacuum();
     }
   } catch (Exception e) {
     Gfo_usr_dlg_.Instance.Warn_many(
         "", "", "fatal error during page deletion: err=~{0}", Err_.Message_gplx_log(e));
   }
   core_db_conn.Exec_sql_plog_ntx(
       "deleting from table: page",
       "DELETE FROM page WHERE page_id IN (SELECT page_id FROM page_filter);");
   // core_db_conn.Meta_tbl_delete("page_filter");
   core_db_conn.Env_vacuum();
   usr_dlg.Plog_many("", "", "");
 }