1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-05-24 22:43:55 -04:00
parent 6eec99a713
commit 51e6188c1e
1577 changed files with 11555 additions and 10080 deletions

View File

@@ -18,18 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa; import gplx.*;
import gplx.core.primitives.*;
public class ByteAry_fil {
public ListAdp Itms() {return itms;} ListAdp itms = ListAdp_.new_();
public List_adp Itms() {return itms;} List_adp itms = List_adp_.new_();
public Io_url Fil() {return fil;} Io_url fil;
public byte[] Raw_bry() {return raw_bry;} private byte[] raw_bry = Bry_.Empty;
public int Raw_len() {return raw_len.Val();} Int_obj_ref raw_len = Int_obj_ref.zero_();
public int Raw_max() {return raw_max;} private int raw_max = Io_mgr.Len_mb;
public ByteAry_fil Ini_file(Io_url fil) {
this.fil = fil;
raw_bry = Io_mgr._.LoadFilBry_reuse(fil, raw_bry, raw_len);
raw_bry = Io_mgr.I.LoadFilBry_reuse(fil, raw_bry, raw_len);
return this;
}
public Object Xto_itms(Class<?> itm_type) {
Object rv = itms.Xto_ary(itm_type);
Object rv = itms.To_ary(itm_type);
itms.Clear();
if (raw_bry.length > raw_max) raw_bry = Bry_.Empty;
raw_len.Val_zero_();

View File

@@ -48,7 +48,7 @@ class Io_txn_mgr {
}
public boolean Commit() {
int len = list.Count();
Io_txn_itm[] itms = (Io_txn_itm[])list.Xto_ary(Io_txn_itm.class);
Io_txn_itm[] itms = (Io_txn_itm[])list.To_ary(Io_txn_itm.class);
for (int i = 0; i < len; i++) {
Io_txn_itm itm = itms[i];
itm.Txn_init(tmp_dir);
@@ -63,5 +63,5 @@ class Io_txn_mgr {
}
return true;
}
ListAdp list = ListAdp_.new_();
List_adp list = List_adp_.new_();
}

View File

@@ -107,7 +107,7 @@ public class Xob_hive_mgr {
if (prv_itm == null) prv_itm = mgr.Rslt_list_ttls()[0];
mgr.Rslt_prv_(prv_itm);
}
public void Find_bgn(ListAdp list, Xow_ns ns, byte[] key, int count, boolean include_redirects) {
public void Find_bgn(List_adp list, Xow_ns ns, byte[] key, int count, boolean include_redirects) {
byte dir_tid = Xotdb_dir_info_.Tid_ttl;
int xdat_idx = Regy__find_file_ns(key, dir_tid, ns.Num_str());
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), xdat_idx);
@@ -116,7 +116,7 @@ public class Xob_hive_mgr {
xdat.Find(xdat_itm, key, Xotdb_page_itm_.Txt_ttl_pos, Byte_ascii.Tab, false);
Find_nearby_add_fwd(list, dir_tid, ns, include_redirects, count, xdat_idx, xdat_itm.Itm_idx());
} private Xob_xdat_itm xdat_itm = new Xob_xdat_itm(); //Int_2_ref find_nearby_rslt = new Int_2_ref();
// private void Find_nearby_add_bwd(ListAdp list, byte dir_tid, Xow_ns ns, boolean include_redirects, int total, int fil_bgn, int row_bgn) {
// private void Find_nearby_add_bwd(List_adp list, byte dir_tid, Xow_ns ns, boolean include_redirects, int total, int fil_bgn, int row_bgn) {
// if (--row_bgn < 0) {
// --fil_bgn;
// row_bgn = -1;
@@ -142,7 +142,7 @@ public class Xob_hive_mgr {
// --fil_idx;
// }
// }
private void Find_nearby_add_fwd(ListAdp list, byte dir_tid, Xow_ns ns, boolean include_redirects, int total, int fil_bgn, int row_bgn) {
private void Find_nearby_add_fwd(List_adp list, byte dir_tid, Xow_ns ns, boolean include_redirects, int total, int fil_bgn, int row_bgn) {
int fil_idx = fil_bgn;
boolean first = true;
int count = 0;

View File

@@ -37,7 +37,7 @@ class Xob_reg_wtr {
.Add_int_variable(itm_count).Add_byte(Byte_ascii.NewLine);
}
public void Flush(Io_url url) {
Io_mgr._.SaveFilBfr(url, bfr);
// Tfds.Write(url.Raw() + "\n" + Io_mgr._.LoadFilStr(url));
Io_mgr.I.SaveFilBfr(url, bfr);
// Tfds.Write(url.Raw() + "\n" + Io_mgr.I.LoadFilStr(url));
}
}

View File

@@ -62,7 +62,7 @@ public class Xow_data_mgr implements GfoInvkAble {
boolean exists = wiki.Db_mgr().Load_mgr().Load_by_ttl(db_page, ns, ttl.Page_db());
if (!exists) return rv.Missing_();
if (wiki.App().App_type().Uid_is_gui()) // NOTE: must check if gui, else will write during mass build; DATE:2014-05-03
wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "file_load", "loading page for ~{0}", String_.new_utf8_(ttl.Raw()));
wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "file_load", "loading page for ~{0}", String_.new_u8(ttl.Raw()));
wiki.Db_mgr().Load_mgr().Load_page(db_page, ns, !called_from_tmpl);
byte[] bry = db_page.Text();
rv.Data_raw_(bry).Revision_data().Modified_on_(db_page.Modified_on()).Id_(db_page.Id()).Html_db_id_(db_page.Html_db_id());

View File

@@ -131,33 +131,33 @@ class Xow_data_mgr_fxt {
wiki.Db_mgr().Save_mgr().Page_id_next_(0);
}
public Xow_data_mgr_fxt Create(String ttl_str, String data) {
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_utf8_(ttl_str));
wiki.Db_mgr().Save_mgr().Data_create(ttl, Bry_.new_utf8_(data));
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_u8(ttl_str));
wiki.Db_mgr().Save_mgr().Data_create(ttl, Bry_.new_u8(data));
return this;
}
public Xow_data_mgr_fxt Update(String ttl_str, String data) {
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_utf8_(ttl_str));
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_u8(ttl_str));
Xoae_page page = Xoae_page.test_(wiki, ttl);
wiki.Db_mgr().Save_mgr().Data_update(page, Bry_.new_utf8_(data));
wiki.Db_mgr().Save_mgr().Data_update(page, Bry_.new_u8(data));
return this;
}
public Xow_data_mgr_fxt Rename(String old_ttl, String new_ttl) {
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_utf8_(old_ttl));
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_u8(old_ttl));
Xoae_page page = Xoae_page.test_(wiki, ttl);
wiki.Db_mgr().Save_mgr().Data_rename(page, ttl.Ns().Id(), Bry_.new_utf8_(new_ttl));
wiki.Db_mgr().Save_mgr().Data_rename(page, ttl.Ns().Id(), Bry_.new_u8(new_ttl));
return this;
}
public Xow_data_mgr_fxt Tst_regy_title(String expd) {return Tst_regy(Xotdb_dir_info_.Name_title, expd);}
Xow_data_mgr_fxt Tst_regy(String name, String expd) {
Io_url file_orig = Io_url_.mem_fil_("mem/xowa/wiki/en.wikipedia.org/ns/000/" + name + "/reg.csv");
Tfds.Eq_str_lines(expd, Io_mgr._.LoadFilStr(file_orig));
Tfds.Eq_str_lines(expd, Io_mgr.I.LoadFilStr(file_orig));
return this;
}
public Xow_data_mgr_fxt Tst_data_page(String expd) {return Tst_data(Xotdb_dir_info_.Tid_page , Xow_ns_.Id_main, 0, expd);}
public Xow_data_mgr_fxt Tst_data_title(String expd) {return Tst_data(Xotdb_dir_info_.Tid_ttl, Xow_ns_.Id_main, 0, expd);}
public Xow_data_mgr_fxt Tst_data(byte dir_tid, int ns_id, int fil, String expd) {
Io_url url = wiki.Tdb_fsys_mgr().Url_ns_fil(dir_tid, ns_id, fil);
Tfds.Eq_str_lines(expd, Io_mgr._.LoadFilStr(url));
Tfds.Eq_str_lines(expd, Io_mgr.I.LoadFilStr(url));
return this;
}
}

View File

@@ -25,17 +25,17 @@ public class Xow_hive_mgr_fxt {
hive_mgr = new Xob_hive_mgr(wiki);
}
hive_mgr.Clear();
Io_mgr._.InitEngine_mem();
Io_mgr.I.InitEngine_mem();
} private Xob_hive_mgr hive_mgr; Xoae_app app;
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
public void Find_nearby(String key, int count, boolean include_redirects, String... expd) {
ListAdp list = ListAdp_.new_();
wiki.Hive_mgr().Find_bgn(list, wiki.Ns_mgr().Ns_main(), Bry_.new_ascii_(key), count, include_redirects);
List_adp list = List_adp_.new_();
wiki.Hive_mgr().Find_bgn(list, wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), count, include_redirects);
int actl_len = list.Count();
String[] actl = new String[actl_len];
for (int i = 0; i < actl_len; i++) {
Xowd_page_itm itm = (Xowd_page_itm)list.FetchAt(i);
actl[i] = String_.new_ascii_(itm.Ttl_page_db());
Xowd_page_itm itm = (Xowd_page_itm)list.Get_at(i);
actl[i] = String_.new_a7(itm.Ttl_page_db());
}
Tfds.Eq_ary_str(expd, actl);
}
@@ -65,7 +65,7 @@ public class Xow_hive_mgr_fxt {
}
public Xow_hive_mgr_fxt Create_ctg(String key_str, int... pages) {Create_ctg(app, hive_mgr, key_str, pages); return this;}
public static void Create_ctg(Xoae_app app, Xob_hive_mgr hive_mgr, String key_str, int... pages) {
byte[] key_bry = Bry_.new_ascii_(key_str);
byte[] key_bry = Bry_.new_a7(key_str);
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b512();
bfr.Add(key_bry);
int pages_len = pages.length;
@@ -91,7 +91,7 @@ public class Xow_hive_mgr_fxt {
hive_mgr.Create(Xotdb_dir_info_.Tid_id, key_bry, row);
}
public Xow_hive_mgr_fxt Load(String url, String... expd) {
String actl = Io_mgr._.LoadFilStr(url);
String actl = Io_mgr.I.LoadFilStr(url);
Tfds.Eq_ary_str(expd, String_.SplitLines_nl(actl));
return this;
}

View File

@@ -35,7 +35,7 @@ public class Xowd_hive_mgr {
reg_mgr.Update_add(fil_idx, key);
}
Io_url url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
byte[] bry = Io_mgr._.LoadFilBry(url);
byte[] bry = Io_mgr.I.LoadFilBry(url);
Xob_xdat_file xdat = new Xob_xdat_file();
if (bry != Bry_.Empty)
xdat.Parse(bry, bry.length, url);
@@ -59,7 +59,7 @@ public class Xowd_hive_mgr {
reg_mgr.Update_add(fil_idx, key);
}
Io_url url = fsys_mgr.Url_site_fil(dir_tid, fil_idx);
byte[] bry = Io_mgr._.LoadFilBry(url);
byte[] bry = Io_mgr.I.LoadFilBry(url);
Xob_xdat_file xdat = new Xob_xdat_file();
if (bry != Bry_.Empty)
xdat.Parse(bry, bry.length, url);
@@ -78,7 +78,7 @@ public class Xowd_hive_mgr {
if (new_key != null)
reg_save = reg_mgr.Update_change(fil_idx, old_key, new_key);
Io_url url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
byte[] bry = Io_mgr._.LoadFilBry(url);
byte[] bry = Io_mgr.I.LoadFilBry(url);
Xob_xdat_file xdat = new Xob_xdat_file();
if (bry != Bry_.Empty)
xdat.Parse(bry, bry.length, url);

View File

@@ -70,28 +70,28 @@ class Xowd_hive_mgr_fxt {
}
public Xowd_hive_mgr_fxt Tst_reg(String expd) {
Io_url file_orig = Io_url_.mem_fil_("mem/xowa/wiki/en.wikipedia.org/ns/000/title/reg.csv");
Tfds.Eq_str_lines(expd, Io_mgr._.LoadFilStr(file_orig));
Tfds.Eq_str_lines(expd, Io_mgr.I.LoadFilStr(file_orig));
return this;
}
public Xowd_hive_mgr_fxt Tst_fil(int fil, String expd) {
Io_url url = wiki.Tdb_fsys_mgr().Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Id_main, fil);
Tfds.Eq_str_lines(expd, Io_mgr._.LoadFilStr(url));
Tfds.Eq_str_lines(expd, Io_mgr.I.LoadFilStr(url));
return this;
}
public Xowd_hive_mgr_fxt Update(String key, String data) {
mgr.Update(wiki.Ns_mgr().Ns_main(), Bry_.new_ascii_(key), null, Bry_.new_ascii_(data), 0, Byte_ascii.Pipe, true, true);
mgr.Update(wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), null, Bry_.new_a7(data), 0, Byte_ascii.Pipe, true, true);
return this;
}
public Xowd_hive_mgr_fxt Create(String key, String data) {
mgr.Create(wiki.Ns_mgr().Ns_main(), Bry_.new_ascii_(key), Bry_.new_ascii_(data), null);
mgr.Create(wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), Bry_.new_a7(data), null);
return this;
}
public Xowd_hive_mgr_fxt Create_and_sort(String key, String data) {
mgr.Create(wiki.Ns_mgr().Ns_main(), Bry_.new_ascii_(key), Bry_.new_ascii_(data), new Bry_comparer_bgn_eos(0));
mgr.Create(wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), Bry_.new_a7(data), new Bry_comparer_bgn_eos(0));
return this;
}
// public void Get(String ttl_str, boolean exists) {
// Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_utf8_(ttl_str));
// Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_u8(ttl_str));
// Xowd_page_itm row = mgr.Get(ttl.Ns(), ttl.Full_txt());
// Tfds.Eq(exists, row != null);
// }

View File

@@ -24,7 +24,7 @@ public class Xowd_hive_regy_itm {// csv file with the format of "idx|bgn|end|cou
public byte[] End() {return end;} public Xowd_hive_regy_itm End_(byte[] v) {end = v; return this;} private byte[] end;
public int Count() {return count;} public Xowd_hive_regy_itm Count_(int v) {this.count = v; return this;} private int count;
public static Xowd_hive_regy_itm[] parse_fil_(ByteAry_fil utl) {
ListAdp rv = utl.Itms();
List_adp rv = utl.Itms();
byte[] ary = utl.Raw_bry();
int ary_len = utl.Raw_len(); if (ary_len == 0) return Xowd_hive_regy_itm.Ary_empty; //throw Err_mgr._.fmt_("xowa.wiki.data", "title_registry_file_not_found", "title_registry file not found: ~{0}", utl.Fil().Xto_api());
Int_obj_ref pos = Int_obj_ref.zero_();

View File

@@ -70,7 +70,7 @@ public class Xowd_regy_mgr {
Xowd_hive_regy_itm itm = files_ary[i];
itm.Srl_save(bfr);
}
Io_mgr._.SaveFilBfr(fil, bfr);
Io_mgr.I.SaveFilBfr(fil, bfr);
}
public static final int Regy_null = -1;
}

View File

@@ -61,28 +61,28 @@ class Xowd_regy_mgr_fxt {
public void Clear() {
if (mgr == null) {
mgr_url = Io_url_.mem_fil_("mem/hive_regy.csv");
Io_mgr._.DeleteFil(mgr_url);
Io_mgr.I.DeleteFil(mgr_url);
mgr = new Xowd_regy_mgr(mgr_url);
}
else {
mgr.Clear();
}
}
public Xowd_regy_mgr_fxt Create(String key) {mgr.Create(Bry_.new_ascii_(key)); return this;}
public Xowd_regy_mgr_fxt Update_add(int fil_idx, String key) {mgr.Update_add(fil_idx, Bry_.new_ascii_(key)); return this;}
public Xowd_regy_mgr_fxt Update_change(int fil_idx, String old_key, String new_key) {mgr.Update_change(fil_idx, Bry_.new_ascii_(old_key), Bry_.new_ascii_(new_key)); return this;}
public Xowd_regy_mgr_fxt Create(String key) {mgr.Create(Bry_.new_a7(key)); return this;}
public Xowd_regy_mgr_fxt Update_add(int fil_idx, String key) {mgr.Update_add(fil_idx, Bry_.new_a7(key)); return this;}
public Xowd_regy_mgr_fxt Update_change(int fil_idx, String old_key, String new_key) {mgr.Update_change(fil_idx, Bry_.new_a7(old_key), Bry_.new_a7(new_key)); return this;}
public Xowd_regy_mgr_fxt Load(String lines) {
Io_mgr._.SaveFilStr(mgr_url, lines);
Io_mgr.I.SaveFilStr(mgr_url, lines);
mgr = new Xowd_regy_mgr(mgr_url);
return this;
}
public Xowd_regy_mgr_fxt Save() {mgr.Save(); return this;}
public Xowd_regy_mgr_fxt Tst_file(String expd) {
Tfds.Eq_str_lines(expd, Io_mgr._.LoadFilStr(mgr_url));
Tfds.Eq_str_lines(expd, Io_mgr.I.LoadFilStr(mgr_url));
return this;
}
public Xowd_regy_mgr_fxt Tst_find(String find, int expd) {
Tfds.Eq(expd, mgr.Files_find(Bry_.new_ascii_(find)));
Tfds.Eq(expd, mgr.Files_find(Bry_.new_a7(find)));
return this;
}
}