コード例 #1
0
 public void Select_tasks_steps(
     Xobc_task_step_hash task_step_hash,
     Xobc_step_map_tbl step_map_tbl,
     byte[] wiki_abrv,
     String wiki_date) {
   task_step_hash.Clear();
   Db_rdr rdr =
       conn.Stmt_sql(
               String_.Concat_lines_nl_skip_last(
                   "SELECT  DISTINCT sm.task_id, sm.step_id",
                   "FROM    " + tbl_name + " imps",
                   "        JOIN " + step_map_tbl.Tbl_name() + " sm ON sm.step_id = imps.step_id",
                   "WHERE   imps.wiki_abrv = ?",
                   "AND     imps.wiki_date = ?"))
           .Crt_bry_as_str(fld_wiki_abrv, wiki_abrv)
           .Crt_str(fld_wiki_date, wiki_date)
           .Exec_select__rls_auto();
   try {
     while (rdr.Move_next()) {
       task_step_hash.Add(rdr.Read_int("task_id"), rdr.Read_int("step_id"));
     }
   } finally {
     rdr.Rls();
   }
 }
コード例 #2
0
ファイル: Xoud_site_tbl.java プロジェクト: qq98982/xowa
 private Xoud_site_row new_row(Db_rdr rdr) {
   return new Xoud_site_row(
       rdr.Read_int(fld_site_id),
       rdr.Read_int(fld_site_priority),
       rdr.Read_str(fld_site_domain),
       rdr.Read_str(fld_site_name),
       rdr.Read_str(fld_site_path),
       rdr.Read_str(fld_site_xtn));
 }
コード例 #3
0
ファイル: Xoud_site_tbl.java プロジェクト: qq98982/xowa
 public Xoud_site_row[] Select_all() {
   List_adp rv = List_adp_.new_();
   Db_rdr rdr = conn.Stmt_select(tbl_name, flds).Exec_select__rls_auto();
   try {
     while (rdr.Move_next()) rv.Add(new_row(rdr));
     return (Xoud_site_row[]) rv.To_ary_and_clear(Xoud_site_row.class);
   } finally {
     rdr.Rls();
   }
 }
コード例 #4
0
 public int Get_pending_count() {
   Db_rdr rdr =
       make_conn.Stmt_sql("SELECT Count(*) AS Count_of FROM xomp_page mp WHERE mp.page_status = 0")
           .Exec_select__rls_auto();
   try {
     return rdr.Move_next() ? rdr.Read_int("Count_of") : 0;
   } finally {
     rdr.Rls();
   }
 }
コード例 #5
0
 public Xobc_import_step_itm Select_one(int step_id) {
   Db_rdr rdr =
       conn.Stmt_select(tbl_name, flds, fld_step_id)
           .Crt_int(fld_step_id, step_id)
           .Exec_select__rls_auto();
   try {
     return (rdr.Move_next()) ? New_itm(rdr) : Xobc_import_step_itm.Null;
   } finally {
     rdr.Rls();
   }
 }
コード例 #6
0
 private Xobc_import_step_itm New_itm(Db_rdr rdr) {
   return new Xobc_import_step_itm(
       rdr.Read_int(fld_step_id),
       rdr.Read_int(fld_host_id),
       rdr.Read_bry_by_str(fld_wiki_abrv),
       rdr.Read_str(fld_wiki_date),
       rdr.Read_str(fld_import_name),
       rdr.Read_int(fld_import_type),
       rdr.Read_byte(fld_import_zip),
       rdr.Read_long(fld_import_size_zip),
       rdr.Read_long(fld_import_size_raw),
       rdr.Read_str(fld_import_md5),
       rdr.Read_long(fld_prog_size_end),
       rdr.Read_int(fld_prog_count_end));
 }
コード例 #7
0
 public Xobc_import_step_itm[] Select_by_task_id(int task_id) {
   List_adp list = List_adp_.New();
   Db_rdr rdr =
       conn.Stmt_sql(
               Db_sql_.Make_by_fmt(
                   String_.Ary(
                       "SELECT  s.*",
                       "FROM    import_step s",
                       "        JOIN step_map sm ON s.step_id = sm.step_id",
                       "WHERE   sm.task_id = {0}"),
                   task_id))
           .Exec_select__rls_auto();
   try {
     while (rdr.Move_next()) {
       list.Add(New_itm(rdr));
     }
   } finally {
     rdr.Rls();
   }
   return (Xobc_import_step_itm[]) list.To_ary_and_clear(Xobc_import_step_itm.class);
 }
コード例 #8
0
  private int Load_from_db(List_adp list, int uid_prv) {
    // prepare for page_tbl
    String sql =
        String_.Format(
            String_.Concat_lines_nl_skip_last // ANSI.Y
                (
                "SELECT  mp.xomp_uid",
                ",       pp.page_id",
                ",       pp.page_namespace",
                ",       pp.page_title",
                ",       pp.page_text_db_id",
                "FROM    xomp_page mp",
                "        JOIN <page_db>page pp ON mp.page_id = pp.page_id",
                "WHERE   mp.xomp_uid > {0}",
                "AND     mp.page_status = 0",
                "LIMIT   {1}"),
            uid_prv,
            num_pages_per_load);
    this.attach_mgr.Conn_links_(
        new Db_attach_itm("page_db", wiki.Data__core_mgr().Db__core().Conn()));
    sql = attach_mgr.Resolve_sql(sql);

    // run page_tbl
    int rv = -1;
    Xomp_text_db_loader text_db_loader = new Xomp_text_db_loader(wiki);
    attach_mgr.Attach();
    Db_rdr rdr = make_conn.Stmt_sql(sql).Exec_select__rls_auto();
    try {
      while (rdr.Move_next()) {
        rv = rdr.Read_int("xomp_uid");
        int text_db_id = rdr.Read_int("page_text_db_id");
        Xomp_page_itm ppg = new Xomp_page_itm(rdr.Read_int("page_id"));
        ppg.Init_by_page(
            rdr.Read_int("page_namespace"), rdr.Read_bry_by_str("page_title"), text_db_id);
        list.Add(ppg);
        text_db_loader.Add(text_db_id, ppg);
      }
    } finally {
      rdr.Rls();
    }
    attach_mgr.Detach();

    text_db_loader.Load();
    return rv;
  }
コード例 #9
0
 private void Init(Db_engine engine) {
   init = false;
   tbl_mgr.Clear();
   idx_mgr.Clear();
   Dbmeta_parser__tbl tbl_parser = new Dbmeta_parser__tbl();
   Dbmeta_parser__idx idx_parser = new Dbmeta_parser__idx();
   Db_qry__select_in_tbl qry =
       Db_qry__select_in_tbl.new_(
           "sqlite_master",
           String_.Ary_empty,
           String_.Ary("type", "name", "sql"),
           Db_qry__select_in_tbl.Order_by_null);
   Db_rdr rdr = engine.Stmt_by_qry(qry).Exec_select__rls_auto();
   try {
     Gfo_usr_dlg_.Instance.Log_many(
         "", "", "db.schema.load.bgn: conn=~{0}", engine.Conn_info().Db_api());
     while (rdr.Move_next()) {
       String type_str = rdr.Read_str("type");
       String name = rdr.Read_str("name");
       String sql = rdr.Read_str("sql");
       try {
         int type_int = Dbmeta_itm_tid.Xto_int(type_str);
         switch (type_int) {
           case Dbmeta_itm_tid.Tid_table:
             if (String_.Has_at_bgn(name, "sqlite_"))
               continue; // ignore b/c of non-orthodox syntax; EX: "CREATE TABLE
                         // sqlite_sequence(name, seq)"; also "CREATE TABLE
                         // sqlite_stat(tbl,idx,stat)";
             tbl_mgr.Add(tbl_parser.Parse(Bry_.new_u8(sql)));
             break;
           case Dbmeta_itm_tid.Tid_index:
             if (sql == null)
               continue; // ignore "autoindex"; EX: sqlite_autoindex_temp_page_len_avg_1
             idx_mgr.Add(idx_parser.Parse(Bry_.new_u8(sql)));
             break;
           default:
             Gfo_usr_dlg_.Instance.Log_many(
                 "",
                 "",
                 "db.schema.unknown type: conn=~{0} type=~{1} name=~{2} sql=~{3}",
                 engine.Conn_info().Db_api(),
                 type_str,
                 name,
                 sql);
             break;
         }
       } catch (
           Exception
               e) { // tables / indexes may be unparseable; skip them; EX: CREATE TABLE unparseable
                    // (col_1 /*comment*/ int); DATE:2016-06-08
         Gfo_usr_dlg_.Instance.Log_many(
             "",
             "",
             "db.schema.unparseable: conn=~{0} type=~{1} name=~{2} sql=~{3} err=~{4}",
             engine.Conn_info().Db_api(),
             type_str,
             name,
             sql,
             Err_.Message_gplx_log(e));
       }
     }
   } finally {
     rdr.Rls();
   }
 }