1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.8.5.1'

This commit is contained in:
gnosygnu
2016-08-29 23:31:58 -04:00
parent e4a2af026b
commit 232838c732
292 changed files with 4502 additions and 1838 deletions

View File

@@ -48,6 +48,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
this.url__parser = new Xow_url_parser(this);
this.xwiki_mgr = new Xow_xwiki_mgr(this);
this.stats = new Xow_site_stats_mgr(this);
this.lnki_bldr = new Xoh_lnki_bldr(app, href_wtr);
}
public Xoa_app App() {return app;}
public boolean Type_is_edit() {return Bool_.N;}
@@ -65,7 +66,8 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
public Xof_orig_mgr File__orig_mgr() {return orig_mgr;} private final Xof_orig_mgr orig_mgr = new Xof_orig_mgr();
public Xof_bin_mgr File__bin_mgr() {return fsdb_mgr.Bin_mgr();}
public Fsm_mnt_mgr File__mnt_mgr() {return fsdb_mgr.Mnt_mgr();}
public Xoh_href_wtr Html__href_wtr() {return html__href_wtr;} private final Xoh_href_wtr html__href_wtr = new Xoh_href_wtr();
public Xoh_lnki_bldr Html__lnki_bldr() {return lnki_bldr;} private final Xoh_lnki_bldr lnki_bldr;
public Xoh_href_wtr Html__href_wtr() {return href_wtr;} private final Xoh_href_wtr href_wtr = new Xoh_href_wtr();
public boolean Html__hdump_enabled() {return Bool_.Y;}
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
public boolean Html__css_installing() {return html__css_installing;} public void Html__css_installing_(boolean v) {html__css_installing = v;} private boolean html__css_installing;

View File

@@ -24,13 +24,12 @@ public class Xow_cache_mgr {
this.wiki = wiki;
this.page_cache = new Xow_page_cache(wiki);
this.defn_cache = new Xow_defn_cache(wiki.Lang());
this.lst_cache = new Xow_defn_cache(wiki.Lang());
}
public Hash_adp Tmpl_result_cache() {return tmpl_result_cache;} private final Hash_adp tmpl_result_cache = Hash_adp_bry.cs();
public Xow_page_cache Page_cache() {return page_cache;} private Xow_page_cache page_cache;
public Xow_defn_cache Defn_cache() {return defn_cache;} private final Xow_defn_cache defn_cache;
public Xow_defn_cache Lst_cache() {return lst_cache;} private final Xow_defn_cache lst_cache;
public Hash_adp_bry Lst_cache() {return lst_cache;} private final Hash_adp_bry lst_cache = Hash_adp_bry.cs();
public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.New();
public Xow_page_cache Page_cache() {return page_cache;} private Xow_page_cache page_cache;
public Gfo_cache_mgr Commons_cache() {return commons_cache;} private Gfo_cache_mgr commons_cache = new Gfo_cache_mgr().Max_size_(64 * Io_mgr.Len_mb).Reduce_by_(32 * Io_mgr.Len_mb);
public Gfo_cache_mgr Ifexist_cache() {return ifexist_cache;} private Gfo_cache_mgr ifexist_cache = new Gfo_cache_mgr().Max_size_(64 * Io_mgr.Len_mb).Reduce_by_(32 * Io_mgr.Len_mb);
@@ -62,7 +61,7 @@ public class Xow_cache_mgr {
tmpl_result_cache.Clear();
defn_cache.Free_mem_all();
misc_cache.Clear();
lst_cache.Free_mem_all();
lst_cache.Clear();
scrib_lang_names = null;
}
private static Keyval[] scrib_lang_names;

View File

@@ -20,17 +20,16 @@ import gplx.core.intls.*; import gplx.core.caches.*;
import gplx.xowa.langs.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.parsers.tmpls.*;
public class Xow_defn_cache { // stores compiled Xot_defn
private Xol_lang_itm lang; // needed to lowercase names;
private Bry_bfr upper_1st_bfr = Bry_bfr_.Reset(255);
private Gfo_cache_mgr cache = new Gfo_cache_mgr().Max_size_(64 * 1024 * 1024).Reduce_by_(32 * 1024 * 1024);
public class Xow_defn_cache { // stores compiled Xot_defn
private final Xol_lang_itm lang; // needed to lowercase names;
private final Bry_bfr upper_1st_bfr = Bry_bfr_.Reset(255);
private final Gfo_cache_mgr cache = new Gfo_cache_mgr().Max_size_(64 * 1024 * 1024).Reduce_by_(32 * 1024 * 1024);
public Xow_defn_cache(Xol_lang_itm lang) {this.lang = lang;}
public Xot_defn Get_by_key(byte[] name) {return (Xot_defn)cache.Get_by_key(name);}
public void Free_mem_all() {cache.Clear();}
public void Add(Xot_defn defn, byte case_match) {
byte[] name = defn.Name();
int cache_size = defn.Cache_size(); // OBSOLETE: * 2 b/c it has src and root;
cache.Add_replace(name, defn, cache_size);
cache.Add_replace(name, defn, defn.Cache_size());
if (case_match == Xow_ns_case_.Tid__1st) {
name = lang.Case_mgr().Case_build_1st_upper(upper_1st_bfr, name, 0, name.length);
cache.Add_replace(name, defn, 0);

View File

@@ -43,5 +43,5 @@ class Xoctg_fmtr_itm_subc extends Xoctg_fmtr_itm_base {
if (val == 0) return;
if (bfr.Len() > 1) bfr.Add(Bld_contains_text_itm_dlm); // NOTE: 1 b/c Paren_bgn is always added
bfr.Add(msg_mgr.Val_by_id_args(msg_id, val));
} static final byte[] Bld_contains_text_itm_dlm = Bry_.new_a7(", ");
} private static final byte[] Bld_contains_text_itm_dlm = Bry_.new_a7(", ");
}

View File

@@ -25,6 +25,7 @@ public class Xow_db_file_ {
, Tid__html_solo = 10, Tid__html_data = 11
, Tid__file_solo = 12, Tid__file_core = 13, Tid__file_data = 14, Tid__file_user = 15
, Tid__search_link = 16, Tid__random = 17, Tid__css = 18
, Tid__html_user = 19
;
private static final String
Key__core = "core", Key__text = "text", Key__cat = "xtn.category", Key__search_core = "xtn.search.core", Key__wbase = "core.wbase"
@@ -33,6 +34,7 @@ public class Xow_db_file_ {
, Key__html_solo = "html.solo", Key__html_data = "html"
, Key__file_solo = "file.solo", Key__file_core = "file.core", Key__file_data = "file.data", Key__file_user = "file.user"
, Key__search_link = "xtn.search.link", Key__random = "xtn.random", Key__css = "xtn.css"
, Key__html_user = "html.user"
;
public static String To_key(byte v) {
switch (v) {
@@ -54,6 +56,7 @@ public class Xow_db_file_ {
case Tid__search_link: return Key__search_link;
case Tid__random: return Key__random;
case Tid__css: return Key__css;
case Tid__html_user: return Key__html_user;
default: throw Err_.new_unhandled(v);
}
}

View File

@@ -91,6 +91,13 @@ public class Xow_db_mgr {
}
return null;
}
public Xow_db_file Dbs__assert_by_tid(byte tid) {
Xow_db_file rv = Dbs__get_by_tid_or_null(tid);
if (rv == null) {
rv = Dbs__make_by_tid(tid);
}
return rv;
}
public Ordered_hash Dbs__get_hash_by_tid(int tid) {return hash_by_tids.Get_by_tid_or_null((byte)tid);}
public Xow_db_file Dbs__make_by_tid(byte tid) {
int tid_idx = Get_tid_idx(hash_by_tids, tid);
@@ -132,10 +139,10 @@ public class Xow_db_mgr {
case Xow_db_file_.Tid__text_solo:
case Xow_db_file_.Tid__core : {db__core = db; if (props.Layout_text().Tid_is_all_or_few()) db__cat_core = db__text = db; break;}
case Xow_db_file_.Tid__text : {db__text = db; break;}
case Xow_db_file_.Tid__html_data : {db__html = db; break;}
case Xow_db_file_.Tid__wbase : {if (db__wbase == null) db__wbase = db; break;}
case Xow_db_file_.Tid__html_data : {db__html = db; break;}
case Xow_db_file_.Tid__wbase : {if (db__wbase == null) db__wbase = db; break;}
case Xow_db_file_.Tid__cat_core :
case Xow_db_file_.Tid__cat : {if (db__cat_core == null) db__cat_core = db; break;}
case Xow_db_file_.Tid__cat : {if (db__cat_core == null) db__cat_core = db; break;}
}
}
private void Dbs__add(Xow_db_file db_file) {

View File

@@ -33,7 +33,7 @@ public class Xowd_page_itm {
public int Html_db_id() {return html_db_id;} private int html_db_id;
public int Redirect_id() {return redirect_id;} private int redirect_id;
public DateAdp Modified_on() {return modified_on;} public Xowd_page_itm Modified_on_(DateAdp v) {modified_on = v; return this;} private DateAdp modified_on;
public boolean Exists() {return exists;} public Xowd_page_itm Exists_(boolean v) {exists = v; return this;} private boolean exists;
public boolean Exists() {return exists;} private boolean exists;
public int Score() {return score;} private int score;
public Xow_ns Ns() {return ns;} private Xow_ns ns;
public Object Xtn() {return xtn;} public Xowd_page_itm Xtn_(Object v) {this.xtn = v; return this;} private Object xtn;
@@ -45,27 +45,43 @@ public class Xowd_page_itm {
id_val = null;
return this;
}
public void Init_by_sql(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int random_int, int text_db_id, int html_db_id, int redirect_id, int score) {
this.id = id;
this.ns_id = ns_id;
this.ttl_page_db = ttl_page_db;
this.modified_on = modified_on;
this.redirected = redirected;
this.text_len = text_len;
this.random_int = random_int;
this.text_db_id = text_db_id;
this.html_db_id = html_db_id;
this.redirect_id = redirect_id;
this.score = score;
public void Init_by_load__idx(int id, int ns_id, byte[] ttl_page_db, int text_len) {
this.exists = true; // COMMENT: DATE:2016-08-28
this.id = id;
this.ns_id = ns_id;
this.ttl_page_db = ttl_page_db;
this.text_len = text_len;
}
public void Init_by_load__all(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int random_int, int text_db_id, int html_db_id, int redirect_id, int score) {
// same as Init_by_load__idx; COMMENT: DATE:2016-08-28
this.exists = true;
this.id = id;
this.ns_id = ns_id;
this.ttl_page_db = ttl_page_db;
this.text_len = text_len;
// other props
this.redirected = redirected;
this.text_db_id = text_db_id;
this.modified_on = modified_on;
this.random_int = random_int;
this.html_db_id = html_db_id;
this.redirect_id = redirect_id;
this.score = score;
}
public void Init_by_tdb(int id, int text_db_id, int tdb_row_idx, boolean redirected, int text_len, int ns_id, byte[] ttl_page_db) {
this.id = id;
this.text_db_id = text_db_id;
this.tdb_row_idx = tdb_row_idx;
this.redirected = redirected;
this.text_len = text_len;
this.ns_id = ns_id;
this.ttl_page_db = ttl_page_db;
// same as Init_by_load__idx; COMMENT: DATE:2016-08-28
this.exists = true;
this.id = id;
this.ns_id = ns_id;
this.ttl_page_db = ttl_page_db;
this.text_len = text_len;
// other props
this.redirected = redirected;
this.text_db_id = text_db_id;
this.tdb_row_idx = tdb_row_idx;
}
public Xowd_page_itm Ttl_(Xow_ns ns, byte[] ttl_page_db) {
this.ns = ns;

View File

@@ -191,10 +191,7 @@ public class Xowd_page_tbl implements Rls_able {
while (rdr.Move_next()) {
if (cancelable.Canceled()) return;
Xowd_page_itm page = new Xowd_page_itm();
page.Id_ (rdr.Read_int(fld_id));
page.Ns_id_ (rdr.Read_int(fld_ns));
page.Ttl_page_db_ (rdr.Read_bry_by_str(fld_title));
page.Text_len_ (rdr.Read_int(fld_len));
this.Read_page__idx(page, rdr);
rv.Add(page);
}
} finally {rdr.Rls();}
@@ -279,19 +276,19 @@ public class Xowd_page_tbl implements Rls_able {
rslt_count.Val_(rslt_idx);
}
public void Read_page__idx(Xowd_page_itm page, Db_rdr rdr) {
page.Id_ (rdr.Read_int(fld_id));
page.Ns_id_ (rdr.Read_int(fld_ns));
page.Ttl_page_db_ (rdr.Read_bry_by_str(fld_title));
page.Text_len_ (rdr.Read_int(fld_len));
page.Init_by_load__idx
( rdr.Read_int(fld_id)
, rdr.Read_int(fld_ns)
, rdr.Read_bry_by_str(fld_title)
, rdr.Read_int(fld_len)
);
}
public void Read_page__all(Xowd_page_itm page, Db_rdr rdr) {
int html_db_id = rdr.Read_int(fld_html_db_id);
int redirected_id = rdr.Read_int(fld_redirect_id);
// handle page_score defaulting to page_len
int page_len = rdr.Read_int(fld_len);
int page_score = page_len;
if (fld_score != Dbmeta_fld_itm.Key_null)
page_score = rdr.Read_int(fld_score);
page.Init_by_sql
int page_score = fld_score == Dbmeta_fld_itm.Key_null ? page_len : rdr.Read_int(fld_score);
page.Init_by_load__all
( rdr.Read_int(fld_id)
, rdr.Read_int(fld_ns)
, rdr.Read_bry_by_str(fld_title)
@@ -300,8 +297,8 @@ public class Xowd_page_tbl implements Rls_able {
, page_len
, rdr.Read_int(fld_random_int)
, rdr.Read_int(fld_text_db_id)
, html_db_id
, redirected_id
, rdr.Read_int(fld_html_db_id)
, rdr.Read_int(fld_redirect_id)
, page_score
);
}

View File

@@ -36,5 +36,5 @@ class Xowd_page_tbl__id extends Xowd_page_tbl__in_wkr__base {
stmt.Val_int(page.Id());
}
}
@Override public Xowd_page_itm Read_data_to_page(Xowd_page_itm rdr_page) {return (Xowd_page_itm)hash.Get_by(rdr_page.Id_val());}
@Override protected Xowd_page_itm Get_page_or_null(Xowd_page_itm rdr_page) {return (Xowd_page_itm)hash.Get_by(rdr_page.Id_val());}
}

View File

@@ -24,7 +24,7 @@ abstract class Xowd_page_tbl__in_wkr__base extends Db_in_wkr__base {
public void Ctor(Xowd_page_tbl tbl, String tbl_name, String fld_in_name) {this.tbl = tbl; this.tbl_name = tbl_name; this.fld_in_name = fld_in_name;}
public String In_fld_name() {return fld_in_name;}
protected abstract Criteria In_filter(Object[] part_ary);
public abstract Xowd_page_itm Read_data_to_page(Xowd_page_itm rdr_page);
protected abstract Xowd_page_itm Get_page_or_null(Xowd_page_itm rdr_page);
public boolean Fill_idx_fields_only() {return fill_idx_fields_only;} public void Fill_idx_fields_only_(boolean v) {fill_idx_fields_only = v;} private boolean fill_idx_fields_only;
@Override protected Db_qry Make_qry(int bgn, int end) {
Object[] part_ary = In_ary(end - bgn);
@@ -32,21 +32,21 @@ abstract class Xowd_page_tbl__in_wkr__base extends Db_in_wkr__base {
( this.Tbl_name()
, In_filter(part_ary)
, fill_idx_fields_only ? tbl.Flds_select_idx() : tbl.Flds_select_all()
)
;
);
}
@Override protected void Read_data(Cancelable cancelable, Db_rdr rdr) {
Xowd_page_itm temp = new Xowd_page_itm();
Xowd_page_itm load = new Xowd_page_itm();
while (rdr.Move_next()) {
if (cancelable.Canceled()) return;
if (fill_idx_fields_only)
tbl.Read_page__idx(temp, rdr);
tbl.Read_page__idx(load, rdr);
else
tbl.Read_page__all(temp, rdr);
Xowd_page_itm page = Read_data_to_page(temp);
tbl.Read_page__all(load, rdr);
// get page reference from list; copy load values into it; COMMENT:2016-08-28
Xowd_page_itm page = this.Get_page_or_null(load);
if (page == null) continue; // page not found
temp.Exists_(true);
page.Copy(temp);
page.Copy(load);
}
}
}

View File

@@ -37,5 +37,5 @@ class Xowd_page_tbl__ttl extends Xowd_page_tbl__in_wkr__base {
stmt.Val_bry_as_str(page.Ttl_page_db());
}
}
@Override public Xowd_page_itm Read_data_to_page(Xowd_page_itm rdr_page) {return (Xowd_page_itm)hash.Get_by(rdr_page.Ttl_page_db());}
@Override protected Xowd_page_itm Get_page_or_null(Xowd_page_itm rdr_page) {return (Xowd_page_itm)hash.Get_by(rdr_page.Ttl_page_db());}
}

View File

@@ -42,7 +42,7 @@ class Xowd_page_tbl__ttl_ns extends Xowd_page_tbl__in_wkr__base {
stmt.Crt_bry_as_str(page_tbl.Fld_page_title(), page.Ttl_page_db());
}
}
@Override public Xowd_page_itm Read_data_to_page(Xowd_page_itm rdr_page) {
@Override protected Xowd_page_itm Get_page_or_null(Xowd_page_itm rdr_page) {
Xow_ns ns = ns_mgr.Ids_get_or_null(rdr_page.Ns_id());
if (ns == null) return null; // NOTE: ns seems to "randomly" be null when threading during redlinks; guard against null; DATE:2014-01-03
byte[] ttl_wo_ns = rdr_page.Ttl_page_db();

View File

@@ -45,7 +45,6 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
if (!Env_.Mode_testing() && wiki.Init_needed()) wiki.Init_assert(); // NOTE: need to call assert as wiki_finder (and possibly elsewhere) may call load on commons_wiki without ever asserting; DATE:2013-03-19
if (!Load_xdat_itm(tmp_xdat_itm, ns, Xotdb_dir_info_.Tid_ttl, ttl, Xotdb_page_itm_.Txt_ttl_pos, Byte_ascii.Tab, true)) return false;
Xotdb_page_itm_.Txt_ttl_load(rv, tmp_xdat_itm.Itm_bry());
rv.Exists_(true);
return Bry_.Eq(rv.Ttl_page_db(), ttl);
}
public void Load_by_ttls(Cancelable cancelable, Ordered_hash rv, boolean fill_idx_fields_only, int bgn, int end) {// NOTE: Load_by_ttls just a wrapper around Load_by_ttl; for xdat, Load_by_ttl is fast enough

View File

@@ -52,4 +52,5 @@ public class Xopg_module_mgr {
, Tid_packed = 4
, Tid_hiero = 8
;
public static final int Tid_null = 0;
}

View File

@@ -57,5 +57,5 @@ public class Xof_meta_fil {
Bld_url_bfr.Add_byte(md5[i]);
Bld_url_bfr.Add(Bry_url_ext);
return Io_url_.new_fil_(Bld_url_bfr.To_str_and_clear());
} static final byte[] Bry_url_ext = Bry_.new_a7(".csv"); static Bry_bfr Bld_url_bfr = Bry_bfr_.New_w_size(260); // 260 is max path of url
} private static final byte[] Bry_url_ext = Bry_.new_a7(".csv"); static Bry_bfr Bld_url_bfr = Bry_bfr_.New_w_size(260); // 260 is max path of url
}

View File

@@ -99,7 +99,7 @@ public class Xob_xdat_file {
if (insert) bfr.Add(new_itm);
itm_0_bgn = (ary_len * Len_idx_itm) + Len_itm_dlm;
src = bfr.To_bry_and_clear();
} static final byte Dlm_hdr_fld = Byte_ascii.Pipe, Dlm_row = Byte_ascii.Nl;
} private static final byte Dlm_hdr_fld = Byte_ascii.Pipe, Dlm_row = Byte_ascii.Nl;
public void Save(Io_url url) {
Bry_bfr bfr = Bry_bfr_.New();
Srl_save_bry(bfr);