mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.7.3.1
This commit is contained in:
@@ -19,18 +19,18 @@ package gplx.xowa.dbs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xodb_file {
|
||||
public Xodb_file(int id, byte tid) {this.id = id; this.tid = tid;}
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xodb_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public int Id() {return id;} private int id;
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public Io_url Url() {return url;} public Xodb_file Url_(Io_url v) {url = v; return this;} private Io_url url;
|
||||
public String Url_rel() {return url_rel;} public Xodb_file Url_rel_(String v) {this.url_rel = v; return this;} private String url_rel;
|
||||
public Db_connect Connect() {return connect;} public Xodb_file Connect_(Db_connect v) {connect = v; return this;} Db_connect connect;
|
||||
public long File_len() {return file_len;} public void File_len_add(int v) {file_len += v;} long file_len;
|
||||
public long File_max() {return file_max;} public Xodb_file File_max_(long v) {file_max = v; return this;} long file_max;
|
||||
public int Id() {return id;} private int id;
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public Io_url Url() {return url;} public Xodb_file Url_(Io_url v) {url = v; return this;} private Io_url url;
|
||||
public String Url_rel() {return url_rel;} public Xodb_file Url_rel_(String v) {url_rel = v; return this;} private String url_rel;
|
||||
public long File_len() {return file_len;} public Xodb_file File_len_add(int v) {file_len += v; return this;} private long file_len;
|
||||
public long File_max() {return file_max;} public Xodb_file File_max_(long v) {file_max = v; return this;} private long file_max;
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xodb_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public Db_connect Connect() {return connect;} public Xodb_file Connect_(Db_connect v) {connect = v; return this;} private Db_connect connect;
|
||||
public Db_provider Provider() {
|
||||
if (provider == null) provider = Db_provider_pool._.FetchOrNew(connect);
|
||||
return provider;
|
||||
} Db_provider provider;
|
||||
} private Db_provider provider;
|
||||
public void Provider_(Db_provider p) {provider = p;}
|
||||
public void Rls() {
|
||||
if (provider == null) return;
|
||||
@@ -39,37 +39,7 @@ public class Xodb_file {
|
||||
provider.Rls();
|
||||
} finally {provider = null;}
|
||||
}
|
||||
public static final byte Tid_core = 1, Tid_text = 2, Tid_category = 3, Tid_search = 4, Tid_wikidata = 5, Tid_temp = 6;
|
||||
public static String Tid_to_name(byte v) {
|
||||
switch (v) {
|
||||
case Tid_core: return "core";
|
||||
case Tid_text: return "text";
|
||||
case Tid_category: return "category";
|
||||
case Tid_wikidata: return "wikidata";
|
||||
case Tid_temp: return "temp";
|
||||
case Tid_search: return "search";
|
||||
default: throw Err_.unhandled(v);
|
||||
}
|
||||
}
|
||||
|
||||
public static Xodb_file load_(int id, byte tid, String url) {return new Xodb_file(id, tid).Url_rel_(url).Cmd_mode_(Db_cmd_mode.Ignore);}
|
||||
public static Xodb_file make_(int id, byte tid, String url) {return new Xodb_file(id, tid).Url_rel_(url).Cmd_mode_(Db_cmd_mode.Create);}
|
||||
public void Index_create(Gfo_usr_dlg usr_dlg, Db_idx_itm[] idxs) {
|
||||
int len = idxs.length;
|
||||
provider.Txn_mgr().Txn_end_all(); // commit any pending transactions
|
||||
for (int i = 0; i < len; i++) {
|
||||
provider.Txn_mgr().Txn_bgn_if_none();
|
||||
String index = idxs[i].Xto_sql();
|
||||
usr_dlg.Prog_many("", "", "creating index: ~{0} ~{1}", id, index);
|
||||
provider.Exec_sql(index);
|
||||
provider.Txn_mgr().Txn_end_all();
|
||||
}
|
||||
}
|
||||
public static final Db_idx_itm
|
||||
Indexes_page_title = Db_idx_itm.sql_("CREATE UNIQUE INDEX IF NOT EXISTS page__title ON page (page_namespace, page_title, page_id, page_len, page_is_redirect);") // PERF:page_id for general queries; PERF: page_len for search_suggest; PREF:page_is_redirect for oimg
|
||||
, Indexes_page_random = Db_idx_itm.sql_("CREATE UNIQUE INDEX IF NOT EXISTS page__name_random ON page (page_namespace, page_random_int);")
|
||||
, Indexes_categorylinks_main = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS categorylinks__cl_main ON categorylinks (cl_to_id, cl_type_id, cl_sortkey, cl_from);")
|
||||
, Indexes_categorylinks_from = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS categorylinks__cl_from ON categorylinks (cl_from);")
|
||||
, Indexes_wikidata_qids = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS wdata_qids__src ON wdata_qids (wq_src_wiki, wq_src_ns, wq_src_ttl);")
|
||||
, Indexes_wikidata_pids = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS wdata_pids__src ON wdata_pids (wp_src_lang, wp_src_ttl);")
|
||||
;
|
||||
}
|
||||
|
||||
33
400_xowa/src/gplx/xowa/dbs/Xodb_file_tid_.java
Normal file
33
400_xowa/src/gplx/xowa/dbs/Xodb_file_tid_.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.dbs; import gplx.*; import gplx.xowa.*;
|
||||
public class Xodb_file_tid_ {
|
||||
public static final byte Tid_core = 1, Tid_text = 2, Tid_category = 3, Tid_search = 4, Tid_wikidata = 5, Tid_temp = 6;
|
||||
public static final String Key_core = "core", Key_text = "text", Key_category = "category", Key_wikidata = "wikidata", Key_temp = "temp", Key_search = "search";
|
||||
public static String Xto_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_core: return Key_core;
|
||||
case Tid_text: return Key_text;
|
||||
case Tid_category: return Key_category;
|
||||
case Tid_wikidata: return Key_wikidata;
|
||||
case Tid_temp: return Key_temp;
|
||||
case Tid_search: return Key_search;
|
||||
default: throw Err_.unhandled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,10 @@ public class Xodb_fsys_mgr {
|
||||
this.trg_name = trg_name;
|
||||
return this;
|
||||
} private Io_url src_dir; private String trg_name;
|
||||
public Db_provider Core_provider() {return core_provider;} Db_provider core_provider;
|
||||
public Db_provider Page_provider() {return page_provider;} Db_provider page_provider;
|
||||
public Db_provider Category_provider() {return category_provider;} Db_provider category_provider;
|
||||
public Db_provider Wdata_provider() {return wikidata_provider;} Db_provider wikidata_provider;
|
||||
public Db_provider Core_provider() {return core_provider;} private Db_provider core_provider;
|
||||
public Db_provider Page_provider() {return page_provider;} private Db_provider page_provider;
|
||||
public Db_provider Category_provider() {return category_provider;} private Db_provider category_provider;
|
||||
public Db_provider Wdata_provider() {return wikidata_provider;} private Db_provider wikidata_provider;
|
||||
public Io_url Trg_dir() {return trg_dir;} private Io_url trg_dir;
|
||||
public int Tid_text_idx() {return tid_text_idx;} public Xodb_fsys_mgr Tid_text_idx_(int v) {tid_text_idx = v; return this;} private int tid_text_idx = File_id_core;
|
||||
public long Tid_text_max() {return tid_text_max;} long tid_text_max = Heap_max_infinite;
|
||||
@@ -41,18 +41,18 @@ public class Xodb_fsys_mgr {
|
||||
Io_url url = trg_dir.GenSubFil(file.Url_rel()); // relative name only
|
||||
file.Connect_(Db_connect_.sqlite_(url)).Url_(url);
|
||||
switch (file.Tid()) {
|
||||
case Xodb_file.Tid_core : file.Provider_(p); Init_by_tid_core(file); break;
|
||||
case Xodb_file.Tid_category : if (category_provider_core_null) {Init_by_tid_category(file); category_provider_core_null = false;}break;
|
||||
case Xodb_file.Tid_wikidata : Init_by_tid_wikidata(file); break;
|
||||
case Xodb_file.Tid_text : Init_by_tid_text(file); break;
|
||||
case Xodb_file_tid_.Tid_core : file.Provider_(p); Init_by_tid_core(file); break;
|
||||
case Xodb_file_tid_.Tid_category : if (category_provider_core_null) {Init_by_tid_category(file); category_provider_core_null = false;}break;
|
||||
case Xodb_file_tid_.Tid_wikidata : Init_by_tid_wikidata(file); break;
|
||||
case Xodb_file_tid_.Tid_text : Init_by_tid_text(file); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Init_make(Xow_ns_mgr ns_mgr, String ns_map_str, long text_max) {
|
||||
Init_by_tid_core(Make(Xodb_file.Tid_core));
|
||||
Init_by_tid_core(Make(Xodb_file_tid_.Tid_core));
|
||||
Init_by_ns_map(ns_mgr, Xodb_ns_map_mgr.Parse(Bry_.new_ascii_(ns_map_str)));
|
||||
if (text_max > 0)
|
||||
Init_by_tid_text(Init_make_file(Xodb_file.Tid_text, text_max));
|
||||
Init_by_tid_text(Init_make_file(Xodb_file_tid_.Tid_text, text_max));
|
||||
}
|
||||
public Xodb_file Init_make_file(byte tid, long max) {
|
||||
if (max == Max_core_db) return files_ary[File_id_core];
|
||||
@@ -68,7 +68,7 @@ public class Xodb_fsys_mgr {
|
||||
Xodb_ns_map_itm itm = ns_map_itms[i];
|
||||
int[] ns_ids = itm.Ns_ids();
|
||||
int ns_ids_len = ns_ids.length;
|
||||
Xodb_file file = Make(Xodb_file.Tid_text);
|
||||
Xodb_file file = Make(Xodb_file_tid_.Tid_text);
|
||||
for (int j = 0; j < ns_ids_len; j++) {
|
||||
int ns_id = ns_ids[j];
|
||||
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id); if (ns == null) continue; // some dumps may not have ns; for example, pre-2013 dumps won't have Module (828)
|
||||
@@ -97,7 +97,7 @@ public class Xodb_fsys_mgr {
|
||||
for (int i = 0; i < files_ary_len; i++) {
|
||||
Xodb_file file = files_ary[i];
|
||||
if (Byte_.In(file.Tid(), tids))
|
||||
file.Index_create(usr_dlg, idxs);
|
||||
Xodb_fsdb_mgr_.Index_create(usr_dlg, file, idxs);
|
||||
}
|
||||
}
|
||||
public void Overwrite(int file_idx) {Create_sqlite3(src_dir, trg_dir, trg_name, file_idx);}
|
||||
@@ -105,13 +105,13 @@ public class Xodb_fsys_mgr {
|
||||
Io_url url = trg_dir.GenSubFil(name + ".sqlite3");
|
||||
if (!Io_mgr._.ExistsFil(url))
|
||||
Io_mgr._.CopyFil(src_dir.GenSubFil("xowa.sqlite3"), url, true);
|
||||
return Xodb_file.make_(-1, Xodb_file.Tid_temp, url.NameAndExt()).Connect_(Db_connect_.sqlite_(url));
|
||||
return Xodb_file.make_(-1, Xodb_file_tid_.Tid_temp, url.NameAndExt()).Connect_(Db_connect_.sqlite_(url));
|
||||
}
|
||||
public Xodb_file Make(byte file_tid) {
|
||||
int file_idx = files_ary_len;
|
||||
Io_url url = Create_sqlite3(src_dir, trg_dir, trg_name, file_idx);
|
||||
Xodb_file rv = Xodb_file.make_(file_idx, file_tid, url.NameAndExt()).Connect_(Db_connect_.sqlite_(url));
|
||||
gplx.xowa.dbs.tbls.Xodb_xowa_cfg_tbl.Insert_str(rv.Provider(), "db.meta", "type_name", Xodb_file.Tid_to_name(file_tid));
|
||||
gplx.xowa.dbs.tbls.Xodb_xowa_cfg_tbl.Insert_str(rv.Provider(), "db.meta", "type_name", Xodb_file_tid_.Xto_key(file_tid));
|
||||
files_ary = (Xodb_file[])Array_.Resize(files_ary, files_ary_len + 1);
|
||||
files_ary[files_ary_len] = rv;
|
||||
++files_ary_len;
|
||||
@@ -130,3 +130,17 @@ public class Xodb_fsys_mgr {
|
||||
public static final int Heap_max_infinite = 0;
|
||||
public static final long Max_core_db = -1;
|
||||
}
|
||||
class Xodb_fsdb_mgr_ {
|
||||
public static void Index_create(Gfo_usr_dlg usr_dlg, Xodb_file file, Db_idx_itm[] idxs) {
|
||||
Db_provider provider = file.Provider();
|
||||
provider.Txn_mgr().Txn_end_all(); // commit any pending transactions
|
||||
int len = idxs.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
provider.Txn_mgr().Txn_bgn_if_none();
|
||||
String index = idxs[i].Xto_sql();
|
||||
usr_dlg.Prog_many("", "", "creating index: ~{0} ~{1}", file.Id(), index);
|
||||
provider.Exec_sql(index);
|
||||
provider.Txn_mgr().Txn_end_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
private Db_provider search_provider = null;
|
||||
private void Search_version_init() {
|
||||
if (search_provider == null) {
|
||||
Xodb_file search_file = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file.Tid_search);
|
||||
Xodb_file search_file = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file_tid_.Tid_search);
|
||||
if (search_file == null) {
|
||||
search_provider = Db_provider_.Null;
|
||||
search_version = gplx.xowa.specials.search.Xosrh_core.Version_1;
|
||||
@@ -128,7 +128,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
if (search_version == gplx.xowa.specials.search.Xosrh_core.Version_1)
|
||||
db_mgr.Tbl_page().Select_by_search(cancelable, rv, search, results_max);
|
||||
else {
|
||||
Xodb_search_title_word_tbl.Select_by_word(cancelable, rv, search, results_max, db_mgr.Fsys_mgr().Get_tid_root(Xodb_file.Tid_search).Provider());
|
||||
Xodb_search_title_word_tbl.Select_by_word(cancelable, rv, search, results_max, db_mgr.Fsys_mgr().Get_tid_root(Xodb_file_tid_.Tid_search).Provider());
|
||||
db_mgr.Tbl_page().Select_by_id_list(cancelable, true, rv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
if (pids_root == null)
|
||||
pids_root = wiki.App().Wiki_mgr().Wdata_mgr().Wdata_wiki().Fsys_mgr().Site_dir().GenSubDir_nest("data", "pid");
|
||||
Xob_xdat_itm pid_itm = Load_xdat_itm_by_dir(pids_root.GenSubDir(String_.new_utf8_(lang_key)), pid_name); if (pid_itm == null) return gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null;
|
||||
return Bry_.X_to_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
return Bry_.Xto_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
} Io_url pids_root;
|
||||
public int Load_ctg_count(byte[] ttl) {return wiki.Db_mgr().Category_version() == Xoa_ctg_mgr.Version_1 ? Load_ctg_count_v1(ttl) : Load_ctg_count_v2(ttl);}
|
||||
int Load_ctg_count_v1(byte[] ttl) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
public DateAdp Dump_date_query() {
|
||||
DateAdp rv = wiki.Props().Modified_latest();
|
||||
if (rv != null) return rv;
|
||||
Io_url url = fsys_mgr.Get_url(Xodb_file.Tid_core);
|
||||
Io_url url = fsys_mgr.Get_url(Xodb_file_tid_.Tid_core);
|
||||
return Io_mgr._.QueryFil(url).ModifiedTime();
|
||||
}
|
||||
public void Init_make(String ns_map) {
|
||||
|
||||
32
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_row.java
Normal file
32
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_row.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
|
||||
import gplx.ios.*;
|
||||
public class Hdump_page_row {
|
||||
public int Id() {return id;} private int id;
|
||||
public byte[] Html() {return html;} private byte[] html;
|
||||
public int Frags_len() {return frags_len;} private int frags_len;
|
||||
public int Make_id() {return make_id;} private int make_id;
|
||||
public Hdump_page_row Ctor(int id, byte[] html, int frags_len, int make_id) {
|
||||
this.id = id;
|
||||
this.html = html;
|
||||
this.frags_len = frags_len;
|
||||
this.make_id = make_id;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
86
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_tbl.java
Normal file
86
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_tbl.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
|
||||
import gplx.dbs.*; import gplx.ios.*;
|
||||
public class Hdump_page_tbl {
|
||||
private Db_stmt stmt_select, stmt_insert, stmt_update;
|
||||
private Io_stream_zip_mgr zip_mgr; private byte zip_tid;
|
||||
public void Ctor(Io_stream_zip_mgr zip_mgr, byte zip_tid) {this.zip_mgr = zip_mgr; this.zip_tid = zip_tid;}
|
||||
@gplx.Virtual public void Insert(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds_all);
|
||||
try {
|
||||
html = zip_mgr.Zip(zip_tid, html);
|
||||
stmt_insert.Val_int_(page_id).Val_bry_(html).Val_int_(frags_len).Val_int_(make_id).Exec_insert();
|
||||
} finally {stmt_insert.Rls();}
|
||||
}
|
||||
@gplx.Virtual public void Update(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
if (stmt_update == null) stmt_update = Db_stmt_.new_update_(provider, Tbl_name, Flds_all);
|
||||
try {
|
||||
html = zip_mgr.Zip(zip_tid, html);
|
||||
stmt_update.Val_int_(page_id).Val_bry_(html).Val_int_(frags_len).Val_int_(make_id).Exec_update();
|
||||
} finally {stmt_update.Rls();}
|
||||
}
|
||||
@gplx.Virtual public void Select(Db_provider provider, Hdump_page_row rv, int page_id) {
|
||||
if (stmt_select == null) stmt_select = Db_stmt_.new_select_(provider, Tbl_name, String_.Ary(Fld_page_id), Flds_all);
|
||||
try {
|
||||
DataRdr rdr = stmt_select.Exec_select();
|
||||
rv.Ctor
|
||||
( rdr.ReadInt(Fld_page_id)
|
||||
, zip_mgr.Unzip(zip_tid, rdr.ReadBry(Fld_page_text))
|
||||
, rdr.ReadInt(Fld_frags_len)
|
||||
, rdr.ReadInt(Fld_make_id)
|
||||
);
|
||||
rdr.Rls();
|
||||
} finally {stmt_select.Rls();}
|
||||
}
|
||||
@gplx.Virtual public void Delete_all(Db_provider provider) {
|
||||
Db_qry_.delete_tbl_(Tbl_name).Exec_qry(provider);
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_select = stmt_insert = stmt_update = null;
|
||||
zip_mgr = null;
|
||||
}
|
||||
public static final String Tbl_name = "html_page"
|
||||
, Fld_page_id = "page_id", Fld_page_text = "page_text", Fld_frags_len = "frags_len", Fld_make_id= "make_id";
|
||||
private static final String[] Flds_all = new String[] {Fld_page_id, Fld_page_text, Fld_frags_len, Fld_make_id};
|
||||
public static final String Tbl_sql = String_.Concat_lines_nl
|
||||
( "CREATE TABLE IF NOT EXISTS html_page"
|
||||
, "( page_id integer NOT NULL PRIMARY KEY"
|
||||
, ", page_text mediumblob NOT NULL"
|
||||
, ", frags_len integer NOT NULL"
|
||||
, ", make_id integer NOT NULL"
|
||||
, ");"
|
||||
);
|
||||
}
|
||||
class Hdump_page_tbl_mem extends Hdump_page_tbl { private OrderedHash hash = OrderedHash_.new_();
|
||||
@Override public void Insert(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
Hdump_page_row row = new Hdump_page_row().Ctor(page_id, html, frags_len, make_id);
|
||||
hash.Add(page_id, row);
|
||||
}
|
||||
@Override public void Update(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id);
|
||||
row.Ctor(page_id, html, frags_len, make_id);
|
||||
}
|
||||
@Override public void Select(Db_provider provider, Hdump_page_row rv, int page_id) {
|
||||
Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id);
|
||||
rv.Ctor(row.Id(), row.Html(), row.Frags_len(), row.Make_id());
|
||||
}
|
||||
@Override public void Delete_all(Db_provider provider) {
|
||||
hash.Clear();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
|
||||
import gplx.dbs.*; import gplx.ios.*;
|
||||
public class Xodb_text_tbl {
|
||||
public Xodb_text_tbl(Xodb_mgr_sql db_mgr) {this.db_mgr = db_mgr; zip_mgr = db_mgr.Wiki().App().Zip_mgr();} private Xodb_mgr_sql db_mgr; Io_stream_zip_mgr zip_mgr;
|
||||
public Xodb_text_tbl(Xodb_mgr_sql db_mgr) {this.db_mgr = db_mgr; zip_mgr = db_mgr.Wiki().App().Zip_mgr();} private Xodb_mgr_sql db_mgr; private Io_stream_zip_mgr zip_mgr;
|
||||
public void Delete_all(Db_provider provider) {provider.Exec_qry(Db_qry_.delete_tbl_(Tbl_name));}
|
||||
public Db_stmt Insert_stmt(Db_provider prov) {return Db_stmt_.new_insert_(prov, Tbl_name, Fld_page_id, Fld_old_text);}
|
||||
public void Insert(Db_stmt stmt, int page_id, byte[] text, byte storage_type) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xodb_wdata_pids_tbl {
|
||||
String pid_str = (String)stmt.Val_str_by_bry_(src_lang).Val_str_by_bry_(src_ttl).Exec_select_val();
|
||||
if (pid_str == null) return Wdata_wiki_mgr.Pid_null; // occurs when pid exists, but does not have entry for language; see hu.w:Marco Polo argali; DATE: 2014-02-01
|
||||
byte[] pid_bry = Bry_.new_utf8_(pid_str);
|
||||
return pid_bry == null ? Wdata_wiki_mgr.Pid_null : Bry_.X_to_int_or(pid_bry, 1, pid_bry.length, Wdata_wiki_mgr.Pid_null);
|
||||
return pid_bry == null ? Wdata_wiki_mgr.Pid_null : Bry_.Xto_int_or(pid_bry, 1, pid_bry.length, Wdata_wiki_mgr.Pid_null);
|
||||
} finally {stmt.Rls();}
|
||||
}
|
||||
public static final String Tbl_name = "wdata_pids", Fld_wp_src_lang = "wp_src_lang", Fld_wp_src_ttl = "wp_src_ttl", Fld_wp_trg_ttl = "wp_trg_ttl";
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xodb_wdata_qids_tbl {
|
||||
Db_stmt stmt = Db_stmt_.Null;
|
||||
try {
|
||||
stmt = Db_stmt_.new_select_(p, Tbl_name, String_.Ary(Fld_wq_src_wiki, Fld_wq_src_ns, Fld_wq_src_ttl), Fld_wq_trg_ttl);
|
||||
String rv = (String)stmt.Val_str_by_bry_(src_wiki).Val_int_(Bry_.X_to_int(src_ns)).Val_str_by_bry_(src_ttl).Exec_select_val();
|
||||
String rv = (String)stmt.Val_str_by_bry_(src_wiki).Val_int_(Bry_.Xto_int(src_ns)).Val_str_by_bry_(src_ttl).Exec_select_val();
|
||||
return rv == null ? null : Bry_.new_utf8_(rv);
|
||||
} finally {stmt.Rls();}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user