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;
  }
Пример #2
0
  public void Split__trg__nth__rls(Split_ctx ctx, Db_conn trg_conn) {
    // make rndm_rng and add
    Rndm_rng_itm rng_itm = bldr.Exec_rng_end_or_null();
    if (rng_itm == null) return;
    Rndm_rng_tbl rng_tbl = new Rndm_rng_tbl(trg_conn);
    rng_tbl.Create_tbl();
    Db_stmt rng_stmt = rng_tbl.Insert_stmt();
    rng_tbl.Insert(
        rng_stmt, rng_itm.Mgr_idx(), rng_itm.Rng_idx(), rng_itm.Seq_bgn(), rng_itm.Seq_end());
    rng_stmt.Rls();
    bldr.Conn().Txn_end();

    // make rndm_seq and bulk copy
    Rndm_seq_tbl seq_tbl = new Rndm_seq_tbl(trg_conn);
    seq_tbl.Create_tbl();
    Split_tbl_.Bld_insert_by_select(tmp_bfr, seq_tbl.Tbl_name(), seq_tbl.Flds());
    tmp_bfr.Add_str_u8_fmt(
        "WHERE {0} = {1} AND {2} = {3}",
        seq_tbl.Fld__qry_idx(), bldr.Qry_idx(), seq_tbl.Fld__rng_idx(), bldr.Rng_idx());
    attach_mgr.Conn_main_(trg_conn).Conn_links_(new Db_attach_itm("src_db", bldr.Conn()));
    attach_mgr.Exec_sql(tmp_bfr.To_str_and_clear());
    //			bldr.Conn().Txn_bgn("rndm");
  }