mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.4.1.1
This commit is contained in:
@@ -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.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.specials.allPages.*; import gplx.xowa.tdbs.*;
|
||||
public class Xob_hive_mgr {
|
||||
public Xob_hive_mgr(Xowe_wiki wiki) {this.wiki = wiki; this.fsys_mgr = wiki.Tdb_fsys_mgr();} private Xowe_wiki wiki; Xotdb_fsys_mgr fsys_mgr;
|
||||
@@ -25,7 +26,7 @@ public class Xob_hive_mgr {
|
||||
int xdat_idx = Regy__find_file_ns(key, dir_tid, ns.Num_str());
|
||||
Xob_xdat_file xdat_main = new Xob_xdat_file();
|
||||
xdat_main = xdat_load_(xdat_main, dir_tid, ns, xdat_idx);
|
||||
xdat_main.Find(xdat_itm, key, Xodb_page_.Txt_ttl_pos, Byte_ascii.Tab, false);
|
||||
xdat_main.Find(xdat_itm, key, Xotdb_page_itm_.Txt_ttl_pos, Byte_ascii.Tab, false);
|
||||
int itm_idx = xdat_itm.Itm_idx();
|
||||
Special_allpages_query_fwd(mgr, dir_tid, ns, include_redirects, count, xdat_idx, itm_idx , xdat_main);
|
||||
Special_allpages_query_bwd(mgr, dir_tid, ns, include_redirects, count, xdat_idx, itm_idx - 1, xdat_main);
|
||||
@@ -41,8 +42,8 @@ public class Xob_hive_mgr {
|
||||
boolean loop = true;
|
||||
int regy_len = regy.Files_ary().length;
|
||||
int rslt_list_len = mgr.Rslt_list_len();
|
||||
Xodb_page[] rslt_list_ttls = mgr.Rslt_list_ttls();
|
||||
Xodb_page nxt_itm = null;
|
||||
Xowd_page_itm[] rslt_list_ttls = mgr.Rslt_list_ttls();
|
||||
Xowd_page_itm nxt_itm = null;
|
||||
while (loop) {
|
||||
if (fil_idx == regy_len) break;
|
||||
if (xdat_file == null) {
|
||||
@@ -52,7 +53,7 @@ public class Xob_hive_mgr {
|
||||
int rows_len = xdat_file.Count();
|
||||
for (; row_idx < rows_len; row_idx++) {
|
||||
xdat_file.GetAt(xdat_itm, row_idx);
|
||||
Xodb_page ttl_itm = Xodb_page_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
Xowd_page_itm ttl_itm = Xotdb_page_itm_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
if (!include_redirects && ttl_itm.Redirected()) continue;
|
||||
++count;
|
||||
nxt_itm = ttl_itm;
|
||||
@@ -76,7 +77,7 @@ public class Xob_hive_mgr {
|
||||
}
|
||||
int count = 0;
|
||||
boolean loop = true;
|
||||
Xodb_page prv_itm = null;
|
||||
Xowd_page_itm prv_itm = null;
|
||||
while (loop) {
|
||||
if (fil_idx == -1) break;
|
||||
if (xdat_file == null) {
|
||||
@@ -87,7 +88,7 @@ public class Xob_hive_mgr {
|
||||
row_idx = xdat_file.Count() - 1;
|
||||
for (; row_idx > -1; row_idx--) {
|
||||
xdat_file.GetAt(xdat_itm, row_idx);
|
||||
Xodb_page ttl_itm = Xodb_page_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
Xowd_page_itm ttl_itm = Xotdb_page_itm_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
if (!include_redirects && ttl_itm.Redirected()) continue;
|
||||
// list.Add(ttl_itm);
|
||||
++count;
|
||||
@@ -112,7 +113,7 @@ public class Xob_hive_mgr {
|
||||
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), xdat_idx);
|
||||
byte[] xdat_bry = gplx.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
xdat.Find(xdat_itm, key, Xodb_page_.Txt_ttl_pos, Byte_ascii.Tab, false);
|
||||
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) {
|
||||
@@ -133,7 +134,7 @@ public class Xob_hive_mgr {
|
||||
// first = false;
|
||||
// for (; row_idx > -1; row_idx--) {
|
||||
// xdat.GetAt(xdat_itm, row_idx);
|
||||
// Xodb_page ttl_itm = Xodb_page_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
// Xowd_page_itm ttl_itm = Xotdb_page_itm_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
// if (!include_redirects && ttl_itm.Type_redirect()) continue;
|
||||
// list.Add(ttl_itm);
|
||||
// if (++count == total) {loop = false; break;}
|
||||
@@ -157,7 +158,7 @@ public class Xob_hive_mgr {
|
||||
first = false;
|
||||
for (; row_idx < rows_len; row_idx++) {
|
||||
xdat.GetAt(xdat_itm, row_idx);
|
||||
Xodb_page ttl_itm = Xodb_page_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
Xowd_page_itm ttl_itm = Xotdb_page_itm_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
if (!include_redirects && ttl_itm.Redirected()) continue;
|
||||
list.Add(ttl_itm);
|
||||
if (++count == total) {loop = false; break;}
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.primitives.*;
|
||||
public class Xodb_page implements Xobl_data_itm {
|
||||
public Xodb_page() {this.Clear();}
|
||||
public int Id() {return id;} public Xodb_page Id_(int v) {id = v; id_val = null; return this;} private int id;
|
||||
public Int_obj_val Id_val() {if (id_val == null) id_val = Int_obj_val.new_(id); return id_val;} private Int_obj_val id_val;
|
||||
public int Ns_id() {return ns_id;} public Xodb_page Ns_id_(int v) {ns_id = v; return this;} private int ns_id;
|
||||
public byte[] Ttl_page_db() {return ttl_page_db;} public Xodb_page Ttl_page_db_(byte[] v) {ttl_page_db = v; return this;} private byte[] ttl_page_db; // EX: Category1
|
||||
public byte[] Ttl_full_db() {return ttl_full_db;} private byte[] ttl_full_db; // EX: Category:Category1
|
||||
public boolean Redirected() {return redirected;} public Xodb_page Redirected_(boolean v) {redirected = v; return this;} private boolean redirected;
|
||||
public int Wtxt_len() {return wtxt_len;} public Xodb_page Wtxt_len_(int v) {wtxt_len = v; return this;} private int wtxt_len;
|
||||
public int Wtxt_db_id() {return wtxt_db_id;} public Xodb_page Wtxt_db_id_(int v) {wtxt_db_id = v; return this;} private int wtxt_db_id;
|
||||
public byte[] Wtxt() {return wtxt;} public Xodb_page Wtxt_(byte[] v) {wtxt = v; if (v != null) wtxt_len = v.length; return this;} private byte[] wtxt;
|
||||
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 Xodb_page Modified_on_(DateAdp v) {modified_on = v; return this;} private DateAdp modified_on;
|
||||
public boolean Exists() {return exists;} public Xodb_page Exists_(boolean v) {exists = v; return this;} private boolean exists;
|
||||
public Xow_ns Ns() {return ns;} private Xow_ns ns;
|
||||
public Object Xtn() {return xtn;} public Xodb_page Xtn_(Object v) {this.xtn = v; return this;} private Object xtn;
|
||||
public int Tdb_row_idx() {return tdb_row_idx;} public void Tdb_row_idx_(int v) {tdb_row_idx = v;} private int tdb_row_idx;
|
||||
public Xodb_page Init(int id, byte[] ttl_page_db, boolean redirected, int wtxt_len, int wtxt_db_id, int tdb_row_idx) {
|
||||
this.id = id; this.ttl_page_db = ttl_page_db; this.redirected = redirected;
|
||||
this.wtxt_len = wtxt_len; this.wtxt_db_id = wtxt_db_id; this.tdb_row_idx = tdb_row_idx;
|
||||
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 wtxt_len, int wtxt_db_id, int html_db_id, int redirect_id) {
|
||||
this.id = id;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
this.modified_on = modified_on;
|
||||
this.redirected = redirected;
|
||||
this.wtxt_len = wtxt_len;
|
||||
this.wtxt_db_id = wtxt_db_id;
|
||||
this.html_db_id = html_db_id;
|
||||
this.redirect_id = redirect_id;
|
||||
}
|
||||
public void Init_by_tdb(int id, int wtxt_db_id, int tdb_row_idx, boolean redirected, int wtxt_len, int ns_id, byte[] ttl_page_db) {
|
||||
this.id = id;
|
||||
this.wtxt_db_id = wtxt_db_id;
|
||||
this.tdb_row_idx = tdb_row_idx;
|
||||
this.redirected = redirected;
|
||||
this.wtxt_len = wtxt_len;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
}
|
||||
public Xodb_page Ttl_(Xow_ns ns, byte[] ttl_page_db) {
|
||||
this.ns = ns;
|
||||
ns_id = ns.Id();
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
this.ttl_full_db = ns.Gen_ttl(ttl_page_db);
|
||||
return this;
|
||||
}
|
||||
public Xodb_page Ttl_(Xoa_ttl ttl) {
|
||||
ttl_full_db = ttl.Full_txt();
|
||||
ttl_page_db = ttl.Page_db();
|
||||
ns = ttl.Ns();
|
||||
ns_id = ns.Id();
|
||||
return this;
|
||||
}
|
||||
public Xodb_page Ttl_(byte[] v, Xow_ns_mgr ns_mgr) {
|
||||
ttl_full_db = v;
|
||||
Object o = ns_mgr.Names_get_w_colon(v, 0, v.length);
|
||||
if (o == null) {
|
||||
ns = ns_mgr.Ns_main();
|
||||
ttl_page_db = v;
|
||||
}
|
||||
else {
|
||||
ns = (Xow_ns)o;
|
||||
ttl_page_db = Bry_.Mid(v, ns.Name_txt_w_colon().length, v.length); // EX: "Template:A" -> "Template:" + "A"
|
||||
}
|
||||
ns_id = ns.Id();
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
id = Id_null; wtxt_len = 0; // wtxt_len should be 0 b/c wtxt defaults to 0;
|
||||
wtxt_db_id = tdb_row_idx = 0; // default to 0, b/c some tests do not set and will fail at -1
|
||||
ns_id = Int_.MinValue;
|
||||
ttl_full_db = ttl_page_db = null; wtxt = Bry_.Empty; // default to Ary_empty for entries that have <wtxt />
|
||||
ns = null;
|
||||
redirected = exists = false;
|
||||
modified_on = DateAdp_.MinValue;
|
||||
id_val = null;
|
||||
html_db_id = -1;
|
||||
redirect_id = -1;
|
||||
}
|
||||
public void Copy(Xodb_page orig) {
|
||||
this.id = orig.id;
|
||||
this.wtxt_len = orig.wtxt_len;
|
||||
this.wtxt_db_id = orig.wtxt_db_id;
|
||||
this.tdb_row_idx = orig.tdb_row_idx;
|
||||
this.ns_id = orig.ns_id;
|
||||
this.ttl_full_db = orig.ttl_full_db;
|
||||
this.ttl_page_db = orig.ttl_page_db;
|
||||
this.wtxt = orig.wtxt;
|
||||
this.ns = orig.ns;
|
||||
this.redirected = orig.redirected;
|
||||
this.exists = orig.exists;
|
||||
this.modified_on = orig.modified_on;
|
||||
this.id_val = null;
|
||||
this.html_db_id = orig.html_db_id;
|
||||
}
|
||||
public void Srl_save(Bry_bfr bfr) {Xodb_page_.Txt_id_save(bfr, this);}
|
||||
public static final int Id_null = -1, Modified_on_null_int = 0;
|
||||
public static final Xodb_page[] Ary_empty = new Xodb_page[0];
|
||||
public static final Xodb_page Null = null;
|
||||
public static Xodb_page new_tmp() {return new Xodb_page();}
|
||||
public static Xodb_page new_srch(int id, int wtxt_len) {return new Xodb_page().Id_(id).Wtxt_len_(wtxt_len);}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.brys.*;
|
||||
public class Xodb_page_ {
|
||||
static final int Txt_len_id = 5, Txt_len_fil_idx = 5, Txt_len_row_idx = 5, Txt_len_type = 1, Txt_len_text_len = 5;
|
||||
public static final int Txt_ttl_pos = Txt_len_id + Txt_len_fil_idx + Txt_len_row_idx + Txt_len_type + Txt_len_text_len + 5;
|
||||
public static final int Txt_ttl_len__fixed = Txt_len_id + Txt_len_fil_idx + Txt_len_row_idx + Txt_len_type + Txt_len_text_len + 5 + 1; // 5=| 1=\n
|
||||
public static Xodb_page Txt_ttl_load(byte[] bry) {
|
||||
Xodb_page rv = new Xodb_page();
|
||||
Txt_ttl_load(rv, bry, 0, bry.length);
|
||||
return rv;
|
||||
}
|
||||
public static void Txt_ttl_load(Xodb_page page, byte[] bry) {Txt_ttl_load(page, bry, 0, bry.length);}
|
||||
private static void Txt_ttl_load(Xodb_page page, byte[] bry, int bgn, int end) {
|
||||
try {
|
||||
page.Init_by_tdb
|
||||
( Base85_utl.XtoIntByAry (bry, bgn + 0, bgn + 4)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 6, bgn + 10)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 12, bgn + 16)
|
||||
, bry[18] == Byte_ascii.Num_1
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 20, bgn + 24)
|
||||
, page.Ns_id()
|
||||
, Bry_.Mid (bry, bgn + 26, end)
|
||||
);
|
||||
} catch (Exception e) {throw Err_.err_(e, "parse_by_ttl failed: {0}", String_.new_utf8_(bry, bgn, end));}
|
||||
}
|
||||
public static void Txt_ttl_save(Bry_bfr bfr, Xodb_page page) {Txt_ttl_save(bfr, page.Id(), page.Wtxt_db_id(), page.Tdb_row_idx(), page.Redirected(), page.Wtxt_len(), page.Ttl_page_db());}
|
||||
public static void Txt_ttl_save(Bry_bfr bfr, int id, int file_idx, int row_idx, boolean redirect, int text_len, byte[] ttl_wo_ns) {
|
||||
bfr .Add_base85_len_5(id) .Add_byte_pipe()
|
||||
.Add_base85_len_5(file_idx) .Add_byte_pipe()
|
||||
.Add_base85_len_5(row_idx) .Add_byte_pipe()
|
||||
.Add_byte(redirect ? Byte_ascii.Num_1 : Byte_ascii.Num_0).Add_byte_pipe()
|
||||
.Add_base85_len_5(text_len) .Add_byte_pipe()
|
||||
.Add(ttl_wo_ns) .Add_byte_nl()
|
||||
;
|
||||
}
|
||||
public static void Txt_id_load(Xodb_page page, byte[] bry) {Txt_id_load(page, bry, 0, bry.length);}
|
||||
private static void Txt_id_load(Xodb_page page, byte[] bry, int bgn, int end) {
|
||||
try {
|
||||
page.Clear();
|
||||
page.Init_by_tdb
|
||||
( Base85_utl.XtoIntByAry (bry, bgn + 0, bgn + 4)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 6, bgn + 10)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 12, bgn + 16)
|
||||
, bry[18] == Byte_ascii.Num_1
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 20, bgn + 24)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 26, bgn + 30)
|
||||
, Bry_.Mid (bry, bgn + 32, end)
|
||||
);
|
||||
} catch (Exception e) {throw Err_.err_(e, "parse_by_id failed: {0}", String_.new_utf8_(bry, bgn, end));}
|
||||
}
|
||||
public static void Txt_id_save(Bry_bfr bfr, Xodb_page page) {
|
||||
bfr .Add_base85_len_5(page.Id()) .Add_byte_pipe()
|
||||
.Add_base85_len_5(page.Wtxt_db_id()) .Add_byte_pipe()
|
||||
.Add_base85_len_5(page.Tdb_row_idx()) .Add_byte_pipe()
|
||||
.Add_byte(page.Redirected() ? Byte_ascii.Num_1 : Byte_ascii.Num_0).Add_byte_pipe()
|
||||
.Add_base85_len_5(page.Wtxt_len()) .Add_byte_pipe()
|
||||
.Add_base85_len_5(page.Ns_id()) .Add_byte_pipe()
|
||||
.Add(page.Ttl_page_db()) .Add_byte_nl();
|
||||
}
|
||||
public static void Txt_page_save(Bry_bfr bfr, int id, DateAdp modified_on, byte[] title, byte[] text, boolean add_nl) {
|
||||
int ts = Bit_.Xto_int_date_short(modified_on.XtoSegAry());
|
||||
bfr .Add_base85(id , Base85_utl.Len_int) .Add_byte(Txt_page_dlm) // needed for mass template load
|
||||
.Add_base85(ts , Base85_utl.Len_int) .Add_byte(Txt_page_dlm)
|
||||
.Add(title) .Add_byte(Txt_page_dlm) // needed for rebuilding ttl files
|
||||
.Add(text) .Add_byte(Txt_page_dlm);
|
||||
if (add_nl)
|
||||
bfr.Add_byte_nl(); // NOTE: each page row is separated by \t\n
|
||||
}
|
||||
public static final byte Txt_page_dlm = Byte_ascii.Tab;
|
||||
public static final int Txt_page_len__fixed = 1 + 5 + 1 + 5 + 1 + 1 + 1; // \tid|date|title|text\n
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.lists.*; /*ComparerAble*/
|
||||
public class Xodb_page_sorter implements ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xodb_page lhs = (Xodb_page)lhsObj, rhs = (Xodb_page)rhsObj;
|
||||
return order * Compare_rows(compareType, lhs, rhs);
|
||||
}
|
||||
private static int Compare_rows(byte compareType, Xodb_page lhs, Xodb_page rhs) {
|
||||
switch (compareType) {
|
||||
case Tid_ns_ttl: {
|
||||
int rv = Int_.Compare(lhs.Ns_id(), rhs.Ns_id());
|
||||
return rv == CompareAble_.Same ? Bry_.Compare(lhs.Ttl_page_db(), rhs.Ttl_page_db()) : rv;
|
||||
}
|
||||
case Tid_itm_len: return Int_.Compare(lhs.Wtxt_len(), rhs.Wtxt_len());
|
||||
case Tid_id: return Int_.Compare(lhs.Id(), rhs.Id());
|
||||
case Tid_ttl: return Bry_.Compare(lhs.Ttl_page_db(), rhs.Ttl_page_db());
|
||||
case Tid_ctg_tid_sortkey:
|
||||
gplx.xowa.ctgs.Xoctg_page_xtn lhs_xtn = (gplx.xowa.ctgs.Xoctg_page_xtn)lhs.Xtn();
|
||||
gplx.xowa.ctgs.Xoctg_page_xtn rhs_xtn = (gplx.xowa.ctgs.Xoctg_page_xtn)rhs.Xtn();
|
||||
if (lhs_xtn == null || rhs_xtn == null) return CompareAble_.Same;
|
||||
int tid_comparable = Byte_.Compare(lhs_xtn.Tid(), rhs_xtn.Tid());
|
||||
if (tid_comparable != CompareAble_.Same) return tid_comparable;
|
||||
return Bry_.Compare(lhs_xtn.Sortkey(), rhs_xtn.Sortkey());
|
||||
default: throw Err_.unhandled(compareType);
|
||||
}
|
||||
}
|
||||
Xodb_page_sorter(byte compareType, int order) {this.compareType = compareType; this.order = order;}
|
||||
byte compareType; int order;
|
||||
static final byte Tid_ns_ttl = 0, Tid_itm_len = 2, Tid_id = 3, Tid_ttl = 4, Tid_ctg_tid_sortkey = 5;
|
||||
static final int Asc = 1, Dsc = -1;
|
||||
public static final Xodb_page_sorter TitleAsc = new Xodb_page_sorter(Tid_ttl , Asc);
|
||||
public static final Xodb_page_sorter EnyLenDsc = new Xodb_page_sorter(Tid_itm_len , Dsc);
|
||||
public static final Xodb_page_sorter IdAsc = new Xodb_page_sorter(Tid_id , Asc);
|
||||
public static final Xodb_page_sorter Ns_id_TtlAsc = new Xodb_page_sorter(Tid_ns_ttl , Asc);
|
||||
public static final Xodb_page_sorter Ctg_tid_sortkey_asc = new Xodb_page_sorter(Tid_ctg_tid_sortkey , Asc);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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 org.junit.*;
|
||||
public class Xodb_page_tst {
|
||||
@Before public void init() {fxt.Init();} private Xodb_page_fxt fxt = new Xodb_page_fxt();
|
||||
@Test public void Ttl_() {
|
||||
fxt.Test_ttl_("User_talk:A", Xow_ns_.Id_user_talk, "A");
|
||||
fxt.Test_ttl_("User talk:A", Xow_ns_.Id_user_talk, "A");
|
||||
}
|
||||
}
|
||||
class Xodb_page_fxt {
|
||||
public void Init() {
|
||||
if (ns_mgr == null) {
|
||||
ns_mgr = new Xow_ns_mgr(gplx.xowa.langs.cases.Xol_case_mgr_.Ascii());
|
||||
ns_mgr.Add_new(Xow_ns_.Id_main, "");
|
||||
ns_mgr.Add_new(Xow_ns_.Id_user_talk, "User talk");
|
||||
ns_mgr.Init_w_defaults();
|
||||
tmp_page = new Xodb_page();
|
||||
}
|
||||
} private Xow_ns_mgr ns_mgr; Xodb_page tmp_page;
|
||||
public void Test_ttl_(String ttl, int expd_ns, String expd_ttl) {
|
||||
tmp_page.Ttl_(Bry_.new_ascii_(ttl), ns_mgr);
|
||||
Tfds.Eq(expd_ns, tmp_page.Ns_id());
|
||||
Tfds.Eq(expd_ttl, String_.new_ascii_(tmp_page.Ttl_page_db()));
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,9 @@ 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.lists.*; /*ComparerAble*/ import gplx.xowa.bldrs.imports.ctgs.*;
|
||||
import gplx.lists.*; /*ComparerAble*/ import gplx.xowa.bldrs.cmds.ctgs.*;
|
||||
import gplx.xowa.dbs.*; import gplx.xowa.wikis.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xow_data_mgr implements GfoInvkAble {
|
||||
private Xop_redirect_mgr redirect_mgr;
|
||||
private Xoa_url tmp_url = Xoa_url.blank_();
|
||||
@@ -52,14 +53,14 @@ public class Xow_data_mgr implements GfoInvkAble {
|
||||
}
|
||||
public Xoae_page Get_page(Xoae_page rv, Xow_ns ns, Xoa_ttl ttl, boolean called_from_tmpl, boolean redirect_force) {
|
||||
int redirects = 0;
|
||||
Xodb_page db_page = Xodb_page.new_tmp();
|
||||
Xowd_page_itm db_page = Xowd_page_itm.new_tmp();
|
||||
while (true) {
|
||||
boolean exists = wiki.Db_mgr().Load_mgr().Load_by_ttl(db_page, ns, ttl.Page_db());
|
||||
if (!exists) return rv.Missing_();
|
||||
if (wiki.Appe().Mode() == Xoa_app_.Mode_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.Db_mgr().Load_mgr().Load_page(db_page, ns, !called_from_tmpl);
|
||||
byte[] bry = db_page.Wtxt();
|
||||
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());
|
||||
if (redirect_force) return rv;
|
||||
Xoa_ttl redirect_ttl = redirect_mgr.Extract_redirect(bry, bry.length);
|
||||
|
||||
@@ -16,7 +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.xowa.tdbs.*;
|
||||
import gplx.xowa.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xow_hive_mgr_fxt {
|
||||
public void Clear() {
|
||||
if (hive_mgr == null) {
|
||||
@@ -34,7 +34,7 @@ public class Xow_hive_mgr_fxt {
|
||||
int actl_len = list.Count();
|
||||
String[] actl = new String[actl_len];
|
||||
for (int i = 0; i < actl_len; i++) {
|
||||
Xodb_page itm = (Xodb_page)list.FetchAt(i);
|
||||
Xowd_page_itm itm = (Xowd_page_itm)list.FetchAt(i);
|
||||
actl[i] = String_.new_ascii_(itm.Ttl_page_db());
|
||||
}
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
@@ -54,7 +54,7 @@ public class Xow_hive_mgr_fxt {
|
||||
byte[] ttl_bry = tmp_bfr.Xto_bry_and_clear();
|
||||
if (ttl_idx == 0) ttl_0 = ttl_bry;
|
||||
else if (ttl_idx == ttls_per_file - 1) ttl_n = ttl_bry;
|
||||
Xodb_page_.Txt_ttl_save(xdat_wtr.Bfr(), id++, 0, ttl_idx, ttl_idx % 2 == 1, 1, ttl_bry);
|
||||
Xotdb_page_itm_.Txt_ttl_save(xdat_wtr.Bfr(), id++, 0, ttl_idx, ttl_idx % 2 == 1, 1, ttl_bry);
|
||||
xdat_wtr.Add_idx(Byte_ascii.Nil);
|
||||
}
|
||||
xdat_wtr.Flush(wiki.Appe().Usr_dlg());
|
||||
@@ -72,7 +72,7 @@ public class Xow_hive_mgr_fxt {
|
||||
for (int i = 0; i < pages_len; i++)
|
||||
bfr.Add_byte_pipe().Add_base85_len_5(pages[i]);
|
||||
bfr.Add_byte_nl();
|
||||
byte[] row = bfr.Mkr_rls().Xto_bry_and_clear();
|
||||
byte[] row = bfr.To_bry_and_rls();
|
||||
hive_mgr.Create(Xotdb_dir_info_.Tid_category, key_bry, row);
|
||||
}
|
||||
public Xow_hive_mgr_fxt Create_id(int id, int fil_idx, int row_idx, boolean type_redirect, int itm_len, int ns_id, String ttl) {Create_id(app, hive_mgr, id, fil_idx, row_idx, type_redirect, itm_len, ns_id, ttl); return this;}
|
||||
|
||||
@@ -92,7 +92,7 @@ class Xowd_hive_mgr_fxt {
|
||||
}
|
||||
// public void Get(String ttl_str, boolean exists) {
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_utf8_(ttl_str));
|
||||
// Xodb_page row = mgr.Get(ttl.Ns(), ttl.Full_txt());
|
||||
// Xowd_page_itm row = mgr.Get(ttl.Ns(), ttl.Full_txt());
|
||||
// Tfds.Eq(exists, row != null);
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user