mirror of https://github.com/gnosygnu/xowa
parent
d5d3c68350
commit
06acdd7335
@ -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.addons.wikis.searchs.fulltexts.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||
public class Xosearch_cache_line {
|
||||
public Xosearch_cache_line(int line_seq, byte[] line_html) {
|
||||
this.line_seq = line_seq;
|
||||
this.line_html = line_html;
|
||||
}
|
||||
public int Line_seq() {return line_seq;} private final int line_seq;
|
||||
public byte[] Line_html() {return line_html;} private final byte[] line_html;
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
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.addons.wikis.searchs.fulltexts.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||
public class Xosearch_cache_mgr {
|
||||
private final Ordered_hash qry_hash = Ordered_hash_.New();
|
||||
public int Next_qry_id() {return next_qry_id++;} private int next_qry_id;
|
||||
public void Clear() {
|
||||
qry_hash.Clear();
|
||||
}
|
||||
public void Add(int query_id, byte[] query, byte[] wiki_bry, int page_seq, int page_id, int line_seq, byte[] line_html) {
|
||||
// get qry
|
||||
Xosearch_cache_qry qry = (Xosearch_cache_qry)qry_hash.Get_by(query_id);
|
||||
if (qry == null) {
|
||||
qry = new Xosearch_cache_qry(query_id, query);
|
||||
qry_hash.Add(query_id, qry);
|
||||
}
|
||||
|
||||
// get wiki
|
||||
Xosearch_cache_wiki wiki = (Xosearch_cache_wiki)qry.Wikis().Get_by(wiki_bry);
|
||||
if (wiki == null) {
|
||||
wiki = new Xosearch_cache_wiki(wiki_bry);
|
||||
qry.Wikis().Add(wiki_bry, wiki);
|
||||
}
|
||||
|
||||
// get page
|
||||
Xosearch_cache_page page = (Xosearch_cache_page)wiki.Pages().Get_by(page_id);
|
||||
if (page == null) {
|
||||
page = new Xosearch_cache_page(page_id, page_seq);
|
||||
wiki.Pages().Add(page_id, page);
|
||||
}
|
||||
|
||||
// add line
|
||||
Xosearch_cache_line line = new Xosearch_cache_line(line_seq, line_html);
|
||||
page.Lines().Add(line);
|
||||
}
|
||||
public Object Get_pages_rng(int qry_id, byte[] wiki, int page_seq_bgn, int page_seq_end) {
|
||||
// List_adp list = List_adp_.New();
|
||||
// for (int i = page_seq_bgn; i < page_seq_end; i++) {
|
||||
// Xosearch_cache_qry page = (Xosearch_cache_qry)qry_hash.Get_at(i);
|
||||
// list.Add(page);
|
||||
// }
|
||||
// return list.To_ary_and_clear(typeof(Xosearch_cache_itm));
|
||||
return null;
|
||||
}
|
||||
public Xosearch_cache_line[] Get_lines_rest(int qry_id, byte[] wiki_bry, int page_id) {
|
||||
// get page
|
||||
Xosearch_cache_qry qry = (Xosearch_cache_qry)qry_hash.Get_by(qry_id);
|
||||
Xosearch_cache_wiki wiki = (Xosearch_cache_wiki)qry.Wikis().Get_by(wiki_bry);
|
||||
Xosearch_cache_page page = (Xosearch_cache_page)wiki.Pages().Get_by(page_id);
|
||||
|
||||
// loop lines from 1 to n
|
||||
List_adp list = List_adp_.New();
|
||||
int lines_len = page.Lines().Len();
|
||||
for (int i = 1; i < lines_len; i++) {
|
||||
Xosearch_cache_line line = (Xosearch_cache_line)page.Lines().Get_at(i);
|
||||
list.Add(line);
|
||||
}
|
||||
return (Xosearch_cache_line[])list.To_ary_and_clear(Xosearch_cache_line.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
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.addons.wikis.searchs.fulltexts.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||
public class Xosearch_cache_page {
|
||||
public Xosearch_cache_page(int page_id, int page_seq) {
|
||||
this.page_id = page_id;
|
||||
this.page_seq = page_seq;
|
||||
}
|
||||
public int Page_id() {return page_id;} private final int page_id;
|
||||
public int Page_seq() {return page_seq;} private final int page_seq;
|
||||
public List_adp Lines() {return lines;} private final List_adp lines = List_adp_.New();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
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.addons.wikis.searchs.fulltexts.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||
public class Xosearch_cache_qry {
|
||||
public Xosearch_cache_qry(int id, byte[] qry) {
|
||||
this.id = id;
|
||||
this.qry = qry;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Qry() {return qry;} private final byte[] qry;
|
||||
public Hash_adp_bry Wikis() {return wikis;} private final Hash_adp_bry wikis = Hash_adp_bry.cs();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.addons.wikis.searchs.fulltexts.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||
public class Xosearch_cache_wiki {
|
||||
public Xosearch_cache_wiki(byte[] wiki) {
|
||||
this.wiki = wiki;
|
||||
}
|
||||
public byte[] Wiki() {return wiki;} private final byte[] wiki;
|
||||
public Ordered_hash Pages() {return pages;} private final Ordered_hash pages = Ordered_hash_.New();
|
||||
}
|
Loading…
Reference in new issue