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

Search: Add special page for full-text search

This commit is contained in:
gnosygnu
2017-02-27 17:26:49 -05:00
parent 27951c428d
commit 1feb2b9877
9 changed files with 275 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
public class Xowd_text_row {
public final int page_id;
public final byte[] text;
public Xowd_text_row(int page_id, byte[] text) {
this.page_id = page_id;
this.text = text;
}
}

View File

@@ -67,6 +67,20 @@ public class Xowd_text_tbl implements Db_tbl {
} finally {rdr.Rls();}
}
}
public Xowd_text_row[] Select_where(byte[] query) {
List_adp list = List_adp_.New();
Db_rdr rdr = conn.Stmt_sql(Db_sql_.Make_by_fmt(String_.Ary("SELECT * FROM text WHERE text_data LIKE '{0}'") , query)).Exec_select__rls_auto();
try {
while (rdr.Move_next()) {
int page_id = rdr.Read_int(fld_page_id);
byte[] text = rdr.Read_bry(fld_text_data);
if (text == null) text = Bry_.Empty; // NOTE: defect wherein blank page inserts null not ""; for now always convert null to empty String; DATE:2015-11-08
text = zip_mgr.Unzip(zip_tid, text);
list.Add(new Xowd_text_row(page_id, text));
}
} finally {rdr.Rls();}
return (Xowd_text_row[])list.To_ary_and_clear(Xowd_text_row.class);
}
public byte[] Zip(byte[] data) {return zip_mgr.Zip(zip_tid, data);}
public void Rls() {
synchronized (thread_lock) { // LOCK:stmt-rls; DATE:2016-07-06