コード例 #1
0
ファイル: Merge2_mgr.java プロジェクト: gnosygnu/xowa_android
  public void Merge_data(Xow_wiki wiki, Io_url src_url, int idx_cur) {
    long all_time_bgn = gplx.core.envs.System_.Ticks();
    wiki.Init_by_wiki();
    Db_conn src_conn = Db_conn_bldr.Instance.Get_or_autocreate(false, src_url);
    ctx.Init(wiki, src_conn);

    // merge data
    int hash_len = wkr_hash.Len();
    for (int i = 0; i < hash_len; ++i) {
      if (prog_wkr.Canceled()) break;
      Merge2_wkr wkr = (Merge2_wkr) wkr_hash.Get_at(i);
      // if (prog_wkr.Checkpoint__skip_wkr(src_url, wkr.Tbl_name())) continue;
      long wkr_time_bgn = gplx.core.envs.System_.Ticks();
      wkr.Merge_data(ctx, prog_wkr);
      Gfo_log_.Instance.Info(
          "merge.wkr.done",
          "data",
          src_url.NameAndExt()
              + "|"
              + wkr.Tbl().Tbl_name()
              + "|"
              + gplx.core.envs.System_.Ticks__elapsed_in_frac(wkr_time_bgn));
    }
    if (ctx.Heap__copy_to_wiki()) ctx.Heap__increment_nxt();
    Gfo_log_.Instance.Info(
        "merge.wkr.done",
        "data",
        src_url.NameAndExt()
            + "|-1|"
            + gplx.core.envs.System_.Ticks__elapsed_in_frac(all_time_bgn));
    src_conn.Rls_conn(); // NOTE: must close conn else pack_conn will stay open
  }
コード例 #2
0
 public static Srch_search_qry New__drd(
     Xow_wiki wiki, Srch_ns_mgr ns_mgr, byte[] search_orig, int slab_bgn, int slab_end) {
   return new Srch_search_qry(
       Tid__android,
       ns_mgr,
       Srch_search_phrase.New(wiki.Case_mgr(), search_orig, Bool_.Y),
       slab_bgn,
       slab_end);
 }
コード例 #3
0
 public static Srch_search_qry New__suggest_box(
     Xow_wiki wiki, Srch_search_cfg cfg, byte[] search_orig) {
   return new Srch_search_qry(
       Tid__suggest_box,
       cfg.Ns_mgr(),
       Srch_search_phrase.New(wiki.Case_mgr(), search_orig, Bool_.Y),
       0,
       cfg.Rslts_max());
 }
コード例 #4
0
ファイル: Merge2_mgr.java プロジェクト: gnosygnu/xowa_android
 public void Merge_core(Xow_wiki wiki, Io_url src_url) {
   Db_conn src_conn = Db_conn_bldr.Instance.Get_or_autocreate(false, src_url);
   new Merge_wkr__core().Copy_to_temp(null, wiki, src_conn);
   Gfo_invk_.Invk_by_val(
       wiki.App().Wiki_mgri(), gplx.xowa.wikis.Xoa_wiki_mgr_.Invk__import_by_url, src_url);
   src_conn.Rls_conn(); // NOTE: must close conn else pack_conn will stay open
   // fails b/c no Main_Page; Gfo_invk_.Invk_by_msg(wiki.App().Gui__tab_mgr(),
   // gplx.xowa.guis.tabs.Xog_tab_mgr_.Invk__new_tab, GfoMsg_.new_cast_("").Add("focus",
   // true).Add("site", wiki.Domain_str()).Add("page", String_.new_u8(wiki.Props().Main_page())));
 }
コード例 #5
0
 public static Srch_search_qry New__url_bar(
     Xow_wiki wiki,
     gplx.xowa.apps.apis.xowa.addons.searchs.Xoapi_url_bar cfg,
     byte[] search_orig) {
   return new Srch_search_qry(
       Tid__url_bar,
       cfg.Ns_mgr(),
       Srch_search_phrase.New(wiki.Case_mgr(), search_orig, cfg.Auto_wildcard()),
       0,
       cfg.Max_results());
 }
コード例 #6
0
 public static Fsdb_db_mgr new_src_bin_db_mgr(Xow_wiki wiki, String version) {
   String domain_str = wiki.Domain_str();
   Fsdb_db_mgr rv = null;
   Io_url url = null;
   if (String_.Eq(version, "v1")) {
     url =
         wiki.Fsys_mgr()
             .File_dir()
             .OwnerDir()
             .GenSubDir(domain_str + "-prv"); // v1: EX: /xowa/file/en.wikipedia.org-prv/
     rv = new Fsdb_db_mgr__v1(url);
   } else if (String_.Eq(version, "v2")) {
     url = wiki.Fsys_mgr().Root_dir().GenSubDir("prv"); // v2: EX: /xowa/wiki/en.wikipedia.org/prv/
     rv = Fsdb_db_mgr_.new_detect(wiki, url, url); // note that v2 is prioritized over v1
   } else throw Err_.new_wo_type("fsdb.make:unknown fsdb_type", "version", version);
   if (rv == null)
     throw Err_.new_wo_type(
         "fsdb.make:source fsdb not found", "version", version, "url", url.Raw());
   return rv;
 }
コード例 #7
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;
  }
コード例 #8
0
 public static Srch_search_qry New__search_page(
     Xow_domain_itm[] domains,
     Xow_wiki wiki,
     Srch_search_cfg cfg,
     boolean simple_search,
     byte[] search_orig,
     int slab_idx,
     int slab_len) {
   int slab_bgn = slab_idx * slab_len;
   int slab_end = slab_bgn + slab_len;
   boolean wildcard = simple_search;
   return new Srch_search_qry(
       Tid__search_page,
       cfg.Ns_mgr(),
       Srch_search_phrase.New(wiki.Case_mgr(), search_orig, wildcard),
       slab_bgn,
       slab_end);
 }