mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.3.1
This commit is contained in:
@@ -24,9 +24,9 @@ class Io_sort_cmd_img implements Io_sort_cmd {
|
||||
public Io_url_gen Make_url_gen() {return make_url_gen;} public Io_sort_cmd_img Make_url_gen_(Io_url_gen v) {make_url_gen = v; return this;} Io_url_gen make_url_gen;
|
||||
public void Sort_bgn() {
|
||||
prv_itm_bgn = prv_itm_end = 0;
|
||||
} byte line_dlm = Byte_ascii.Nil;
|
||||
} byte line_dlm = Byte_ascii.Null;
|
||||
public void Sort_do(Io_line_rdr rdr) {
|
||||
if (line_dlm == Byte_ascii.Nil) line_dlm = rdr.Line_dlm();
|
||||
if (line_dlm == Byte_ascii.Null) line_dlm = rdr.Line_dlm();
|
||||
int rdr_key_bgn = rdr.Key_pos_bgn(), rdr_key_end = rdr.Key_pos_end();
|
||||
if (prv_itm_end == 0 || !Bry_.Match(rdr.Bfr(), rdr_key_bgn, rdr_key_end, fil_bfr.Bfr(), prv_itm_bgn, prv_itm_end)) {
|
||||
int fil_bfr_len = fil_bfr.Len();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Io_sort_cmd_ns implements Io_make_cmd {
|
||||
if (key_bfr_0.Len() == 0) {key_bfr_0.Add_mid(bfr, key_bgn, key_end);}
|
||||
key_bfr_n.Clear().Add_mid(bfr, key_bgn, key_end);
|
||||
fil_wtr.Bfr().Add_mid(rdr.Bfr(), itm_bgn, itm_end);
|
||||
fil_wtr.Add_idx(Byte_ascii.Nil);
|
||||
fil_wtr.Add_idx(Byte_ascii.Null);
|
||||
++itm_count;
|
||||
}
|
||||
public void Sort_end() {
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.consoles.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.cfgs.*; import gplx.xowa.bldrs.langs.*;
|
||||
public class Xob_bldr implements GfoInvkAble {
|
||||
private boolean pause_at_end = false; private long prv_prog_time; private Xob_xml_parser dump_parser;
|
||||
@@ -67,9 +68,9 @@ public class Xob_bldr implements GfoInvkAble {
|
||||
}
|
||||
app.Usr_dlg().Note_many("", "", "bldr done: ~{0}", TimeSpanAdp_.from_(time_bgn).XtoStrUiAbbrv());
|
||||
cmd_mgr.Clear();
|
||||
if (pause_at_end && !Env_.Mode_testing()) {ConsoleAdp._.ReadLine("press enter to continue");}
|
||||
if (pause_at_end && !Env_.Mode_testing()) {Console_adp__sys.I.Read_line("press enter to continue");}
|
||||
}
|
||||
catch (Exception e) {throw Exc_.new_exc(e, "bldr", "unknown error");}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "bldr", "unknown error");}
|
||||
}
|
||||
private void Cancel() {
|
||||
int cmd_mgr_len = cmd_mgr.Len();
|
||||
|
||||
@@ -22,14 +22,14 @@ public class Xob_make_cmd_site implements Io_make_cmd {
|
||||
int make_fil_max = 65 * Io_mgr.Len_kb, fil_count = 0, itm_count = 0, itm_key_end = 0; Io_url reg_url;
|
||||
public Xob_make_cmd_site(Gfo_usr_dlg usr_dlg, Io_url make_dir, int make_fil_max) {this.usr_dlg = usr_dlg; this.make_dir = make_dir; this.make_fil_max = make_fil_max;} Gfo_usr_dlg usr_dlg;
|
||||
public Io_sort_cmd Make_dir_(Io_url v) {make_dir = v; return this;} Io_url make_dir;
|
||||
public byte Line_dlm() {return line_dlm;} public Xob_make_cmd_site Line_dlm_(byte v) {line_dlm = v; return this;} private byte line_dlm = Byte_ascii.Nil;
|
||||
public byte Line_dlm() {return line_dlm;} public Xob_make_cmd_site Line_dlm_(byte v) {line_dlm = v; return this;} private byte line_dlm = Byte_ascii.Null;
|
||||
public void Sort_bgn() {
|
||||
fil_count = itm_count = itm_key_end = 0;
|
||||
reg_url = make_dir.GenSubFil(Xotdb_dir_info_.Name_reg_fil);
|
||||
fil_wtr = Xob_xdat_file_wtr.new_file_(make_fil_max, make_dir);
|
||||
}
|
||||
public void Sort_do(Io_line_rdr rdr) {
|
||||
if (line_dlm == Byte_ascii.Nil) line_dlm = rdr.Line_dlm();
|
||||
if (line_dlm == Byte_ascii.Null) line_dlm = rdr.Line_dlm();
|
||||
int rdr_key_bgn = rdr.Key_pos_bgn(), rdr_key_end = rdr.Key_pos_end();
|
||||
int rdr_key_len = rdr_key_end - rdr_key_bgn;
|
||||
int rdr_val_bgn = rdr_key_end, /* NOTE: no +1: want to include fld_dlm for below*/ rdr_val_end = rdr.Itm_pos_end() - 1; // -1: ignore rdr_dlm
|
||||
|
||||
@@ -108,7 +108,7 @@ public class Xob_xdat_file {
|
||||
wtr.Write(bfr.Bfr(), 0, bfr.Len());
|
||||
wtr.Flush();
|
||||
}
|
||||
catch (Exception e) {throw Exc_.new_exc(e, "xo", "failed to save file", "url", url.Xto_api());}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "xo", "failed to save file", "url", url.Xto_api());}
|
||||
finally {
|
||||
wtr.Rls();
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class Xob_xdat_file {
|
||||
public Xob_xdat_file Clear() {src = null; itm_ends = Int_.Ary_empty; return this;}
|
||||
private int[] itm_ends = Int_.Ary_empty; private int itm_0_bgn;
|
||||
public Xob_xdat_file Parse(byte[] src, int src_len, Io_url url) {// SEE:NOTE_1;xdat format
|
||||
if (src_len == 0) throw Exc_.new_("file cannot be empty for parse", "url", url.Raw());
|
||||
if (src_len == 0) throw Err_.new_wo_type("file cannot be empty for parse", "url", url.Raw());
|
||||
int itm_count = 0, tmp_len = Parse_tmp_len; int[] tmp = Parse_tmp;
|
||||
try {
|
||||
int slot_bgn = 0, slot_old = 0, slot_new = 0;
|
||||
@@ -171,7 +171,7 @@ public class Xob_xdat_file {
|
||||
itm_ends[i] = tmp[i];
|
||||
itm_0_bgn = slot_bgn + Len_itm_dlm;
|
||||
this.src = Bry_.Mid(src, 0, itm_ends_last + itm_0_bgn);
|
||||
} catch (Exception e) {throw Exc_.new_exc(e, "xo", "failed to parse idx", "itm_count", itm_count, "url", url.Raw());}
|
||||
} catch (Exception e) {throw Err_.new_exc(e, "xo", "failed to parse idx", "itm_count", itm_count, "url", url.Raw());}
|
||||
return this;
|
||||
} private static final int Parse_tmp_len = 8 * 1024; static int[] Parse_tmp = new int[Parse_tmp_len];
|
||||
static final int Len_itm_dlm = 1, Len_idx_itm = 6, Offset_base85 = 4; // 6 = 5 (base85_int) + 1 (new_line/pipe)
|
||||
@@ -196,8 +196,8 @@ public class Xob_xdat_file {
|
||||
}
|
||||
}
|
||||
class Xob_xdat_file_ {
|
||||
public static int BinarySearch(int itm_0_bgn, byte[] src, int[] itm_ends, byte[] lkp, int lkp_bgn, byte lkp_dlm, int itm_end_adj, boolean exact, Xob_xdat_itm xdat_itm) {if (lkp == null) throw Exc_.new_null("lkp is null");
|
||||
int itm_ends_len = itm_ends.length; if (itm_ends_len == 0) throw Exc_.new_("itm_ends_len cannot have 0 itms");
|
||||
public static int BinarySearch(int itm_0_bgn, byte[] src, int[] itm_ends, byte[] lkp, int lkp_bgn, byte lkp_dlm, int itm_end_adj, boolean exact, Xob_xdat_itm xdat_itm) {if (lkp == null) throw Err_.new_null();
|
||||
int itm_ends_len = itm_ends.length; if (itm_ends_len == 0) throw Err_.new_wo_type("itm_ends_len cannot have 0 itms");
|
||||
int lo = -1, hi = itm_ends_len - 1; // NOTE: -1 is necessary; see test
|
||||
int itm_idx = (hi - lo) / 2;
|
||||
int lkp_len = lkp.length;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xob_xdat_file_wtr {
|
||||
public Bry_bfr Bfr() {return bfr;} Bry_bfr bfr;
|
||||
public Xob_xdat_file_wtr Add_idx(byte data_dlm) {return Add_idx_direct(bfr.Len(), data_dlm);}
|
||||
public Xob_xdat_file_wtr Add_idx_direct(int itm_len, byte data_dlm) {
|
||||
if (data_dlm != Byte_ascii.Nil) { // write closing dlm for data_eny, unless Byte_.Null passed in
|
||||
if (data_dlm != Byte_ascii.Null) { // write closing dlm for data_eny, unless Byte_.Null passed in
|
||||
bfr.Add_byte(data_dlm);
|
||||
++itm_len;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ public class Xob_xdat_file_wtr_tst {
|
||||
tst_Write(wtr, ">a", "<1>a");
|
||||
tst_Write(wtr, ">b", "<1>a>b");
|
||||
tst_Add_idx(wtr, 7);
|
||||
wtr.Bfr().Add(Bry_.new_u8("<2>b>cc"));
|
||||
wtr.Bfr().Add(Bry_.new_a7("<2>b>cc"));
|
||||
tst_Add_idx(wtr, 15);
|
||||
wtr.Bfr().Add(Bry_.new_u8("<3>c>dd"));
|
||||
wtr.Bfr().Add(Bry_.new_a7("<3>c>dd"));
|
||||
tst_Add_idx(wtr, 23);
|
||||
tst_Flush(wtr, String_.Concat
|
||||
( "!!!!(|!!!!)|!!!!)|\n"
|
||||
|
||||
@@ -58,6 +58,6 @@ public class Xobd_parser implements Xobd_wkr {
|
||||
}
|
||||
public void Wkr_print() {}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
throw Exc_.new_unimplemented();
|
||||
throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.consoles.*;
|
||||
import gplx.ios.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xobd_rdr implements Xob_cmd {
|
||||
private Xob_bldr bldr; private Xowe_wiki wiki;
|
||||
@@ -53,20 +54,20 @@ public class Xobd_rdr implements Xob_cmd {
|
||||
wkr_ary[i].Wkr_run(page);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Exc_.Noop(e);
|
||||
Err_.Noop(e);
|
||||
long dividend = fil.Fil_pos();
|
||||
if (dividend >= fil_len) dividend = fil_len - 1; // prevent % from going over 100
|
||||
String msg = DecimalAdp_.CalcPctStr(dividend, fil_len, "00.00") + "|" + String_.new_u8(page.Ttl_full_db()) + "|\n" + Err_.Message_lang(e) + "|" + Xot_tmpl_wtr.Err_string; Xot_tmpl_wtr.Err_string = "";
|
||||
String msg = DecimalAdp_.CalcPctStr(dividend, fil_len, "00.00") + "|" + String_.new_u8(page.Ttl_full_db()) + "|" + Err_.Message_gplx_log(e) + "|" + Xot_tmpl_wtr.Err_string; Xot_tmpl_wtr.Err_string = "";
|
||||
bldr.Usr_dlg().Log_wkr().Log_to_session(msg);
|
||||
ConsoleAdp._.WriteLine(msg);
|
||||
Console_adp__sys.I.Write_str_w_nl(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
String msg = Err_.Message_lang(e);
|
||||
bldr.Usr_dlg().Log_wkr().Log_to_session(msg);
|
||||
ConsoleAdp._.WriteLine(msg);
|
||||
throw Exc_.new_exc(e, "xo", "error while reading dump");
|
||||
Console_adp__sys.I.Write_str_w_nl(msg);
|
||||
throw Err_.new_exc(e, "xo", "error while reading dump");
|
||||
}
|
||||
finally {fil.Rls();}
|
||||
bldr.Usr_dlg().Prog_none("", "", "reading completed: performing post-processing clean-up");
|
||||
@@ -96,6 +97,6 @@ public class Xobd_rdr implements Xob_cmd {
|
||||
String optRdrFillFmt = "reading ~{0} MB: ~{1} ~{2}";
|
||||
static final String GRP_KEY = "xowa.bldr.rdr";
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
throw Exc_.new_unimplemented();
|
||||
throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user