mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.1'
This commit is contained in:
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class ByteAry_fil {
|
||||
public List_adp Itms() {return itms;} List_adp itms = List_adp_.new_();
|
||||
public List_adp Itms() {return itms;} List_adp itms = List_adp_.New();
|
||||
public Io_url Fil() {return fil;} Io_url fil;
|
||||
public byte[] Raw_bry() {return raw_bry;} private byte[] raw_bry = Bry_.Empty;
|
||||
public int Raw_len() {return raw_len.Val();} Int_obj_ref raw_len = Int_obj_ref.zero_();
|
||||
public int Raw_len() {return raw_len.Val();} Int_obj_ref raw_len = Int_obj_ref.New_zero();
|
||||
public int Raw_max() {return raw_max;} private int raw_max = Io_mgr.Len_mb;
|
||||
public ByteAry_fil Ini_file(Io_url fil) {
|
||||
this.fil = fil;
|
||||
@@ -35,5 +35,5 @@ public class ByteAry_fil {
|
||||
raw_len.Val_zero_();
|
||||
return rv;
|
||||
}
|
||||
public static final ByteAry_fil Instance = new ByteAry_fil(); ByteAry_fil() {}
|
||||
public static final ByteAry_fil Instance = new ByteAry_fil(); ByteAry_fil() {}
|
||||
}
|
||||
|
||||
@@ -30,24 +30,24 @@ public class Xotdb_dir_info {
|
||||
ext_bry = Wtr_ext(v);
|
||||
ext_str = String_.new_a7(ext_bry);
|
||||
return this;
|
||||
} byte ext_tid = gplx.core.ios.Io_stream_.Tid_raw;
|
||||
public static final String Wtr_xdat_str = ".xdat", Wtr_zip_str = ".zip", Wtr_gz_str = ".gz", Wtr_bz2_str = ".bz2";
|
||||
public static final byte[] Wtr_xdat_bry = Bry_.new_a7(Wtr_xdat_str), Wtr_zip_bry = Bry_.new_a7(Wtr_zip_str), Wtr_gz_bry = Bry_.new_a7(Wtr_gz_str), Wtr_bz2_bry = Bry_.new_a7(Wtr_bz2_str);
|
||||
} byte ext_tid = gplx.core.ios.streams.Io_stream_.Tid_raw;
|
||||
public static final String Wtr_xdat_str = ".xdat", Wtr_zip_str = ".zip", Wtr_gz_str = ".gz", Wtr_bz2_str = ".bz2";
|
||||
public static final byte[] Wtr_xdat_bry = Bry_.new_a7(Wtr_xdat_str), Wtr_zip_bry = Bry_.new_a7(Wtr_zip_str), Wtr_gz_bry = Bry_.new_a7(Wtr_gz_str), Wtr_bz2_bry = Bry_.new_a7(Wtr_bz2_str);
|
||||
public static String Wtr_dir(byte v) {
|
||||
switch (v) {
|
||||
case gplx.core.ios.Io_stream_.Tid_raw : return "";
|
||||
case gplx.core.ios.Io_stream_.Tid_zip : return "_zip";
|
||||
case gplx.core.ios.Io_stream_.Tid_gzip : return "_gz";
|
||||
case gplx.core.ios.Io_stream_.Tid_bzip2 : return "_bz2";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_raw : return "";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_zip : return "_zip";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_gzip : return "_gz";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_bzip2 : return "_bz2";
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
public static byte[] Wtr_ext(byte v) {
|
||||
switch (v) {
|
||||
case gplx.core.ios.Io_stream_.Tid_raw : return Wtr_xdat_bry;
|
||||
case gplx.core.ios.Io_stream_.Tid_zip : return Wtr_zip_bry;
|
||||
case gplx.core.ios.Io_stream_.Tid_gzip : return Wtr_gz_bry;
|
||||
case gplx.core.ios.Io_stream_.Tid_bzip2 : return Wtr_bz2_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_raw : return Wtr_xdat_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_zip : return Wtr_zip_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_gzip : return Wtr_gz_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_bzip2 : return Wtr_bz2_bry;
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,19 +20,19 @@ import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.tdbs.utils.*;
|
||||
public class Xotdb_fsys_mgr {
|
||||
private final Io_url root_dir; private final Xow_ns_mgr ns_mgr;
|
||||
private final Io_url root_dir; private final Xow_ns_mgr ns_mgr;
|
||||
public Xotdb_fsys_mgr(Io_url root_dir, Xow_ns_mgr ns_mgr) {
|
||||
this.root_dir = root_dir; this.ns_mgr = ns_mgr;
|
||||
this.tmp_dir = root_dir.GenSubDir("tmp");
|
||||
this.ns_dir = root_dir.GenSubDir(Xotdb_dir_info_.Name_ns);
|
||||
this.site_dir = root_dir.GenSubDir(Xotdb_dir_info_.Name_site);
|
||||
}
|
||||
public Io_url Tmp_dir() {return tmp_dir;} private final Io_url tmp_dir;
|
||||
public Io_url Ns_dir() {return ns_dir;} private final Io_url ns_dir;
|
||||
public Io_url Site_dir() {return site_dir;} private final Io_url site_dir;
|
||||
public Io_url Tmp_dir() {return tmp_dir;} private final Io_url tmp_dir;
|
||||
public Io_url Ns_dir() {return ns_dir;} private final Io_url ns_dir;
|
||||
public Io_url Site_dir() {return site_dir;} private final Io_url site_dir;
|
||||
public Io_url Cfg_wiki_core_fil() {return root_dir.GenSubFil_nest(Const_url_cfg, "wiki_core.gfs");}
|
||||
public Io_url Cfg_wiki_stats_fil() {return root_dir.GenSubFil_nest(Const_url_cfg, "wiki_stats.gfs");}
|
||||
public Xotdb_dir_info[] Tdb_dir_regy() {return dir_regy;} private final Xotdb_dir_info[] dir_regy = Xotdb_dir_info_.regy_();
|
||||
public Xotdb_dir_info[] Tdb_dir_regy() {return dir_regy;} private final Xotdb_dir_info[] dir_regy = Xotdb_dir_info_.regy_();
|
||||
public Io_url Url_ns_dir(String ns_num, byte tid) {return ns_dir.GenSubDir_nest(ns_num, Xotdb_dir_info_.Tid_name(tid));}
|
||||
public Io_url Url_ns_reg(String ns_num, byte tid) {return ns_dir.GenSubFil_nest(ns_num, Xotdb_dir_info_.Tid_name(tid), Xotdb_dir_info_.Name_reg_fil);}
|
||||
public Io_url Url_ns_fil(byte tid, int ns_id, int fil_idx) {
|
||||
@@ -56,21 +56,21 @@ public class Xotdb_fsys_mgr {
|
||||
private static void Scan_dirs_zip(Xotdb_fsys_mgr fsys_mgr, byte id) {
|
||||
Io_url[] dirs = Io_mgr.Instance.QueryDir_args(fsys_mgr.Ns_dir().GenSubDir_nest("000")).FilPath_("*page*").DirOnly_().Recur_(false).ExecAsUrlAry();
|
||||
int len = dirs.length;
|
||||
byte tid = gplx.core.ios.Io_stream_.Tid_raw; // needed for Xoa_xowa_exec_tst
|
||||
byte tid = gplx.core.ios.streams.Io_stream_.Tid_raw; // needed for Xoa_xowa_exec_tst
|
||||
for (int i = 0; i < len; i++) {
|
||||
Io_url dir = dirs[i];
|
||||
String dir_name = dir.NameOnly();
|
||||
if (String_.Eq(dir_name, "page")) {tid = gplx.core.ios.Io_stream_.Tid_raw; break;}
|
||||
else if (String_.Eq(dir_name, "page_zip")) tid = gplx.core.ios.Io_stream_.Tid_zip;
|
||||
else if (String_.Eq(dir_name, "page_gz")) tid = gplx.core.ios.Io_stream_.Tid_gzip;
|
||||
else if (String_.Eq(dir_name, "page_bz2")) tid = gplx.core.ios.Io_stream_.Tid_bzip2;
|
||||
if (String_.Eq(dir_name, "page")) {tid = gplx.core.ios.streams.Io_stream_.Tid_raw; break;}
|
||||
else if (String_.Eq(dir_name, "page_zip")) tid = gplx.core.ios.streams.Io_stream_.Tid_zip;
|
||||
else if (String_.Eq(dir_name, "page_gz")) tid = gplx.core.ios.streams.Io_stream_.Tid_gzip;
|
||||
else if (String_.Eq(dir_name, "page_bz2")) tid = gplx.core.ios.streams.Io_stream_.Tid_bzip2;
|
||||
}
|
||||
fsys_mgr.Tdb_dir_regy()[id].Ext_tid_(tid);
|
||||
}
|
||||
private static Hash_adp Scan_dirs_ns(Io_url ns_dir, Xow_ns_mgr ns_mgr) {
|
||||
Io_url[] ns_dirs = Io_mgr.Instance.QueryDir_args(ns_dir).Recur_(false).DirOnly_().ExecAsUrlAry();
|
||||
int len = ns_dirs.length;
|
||||
Hash_adp rv = Hash_adp_.new_();
|
||||
Hash_adp rv = Hash_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
int ns_int = Int_.parse_or(ns_dirs[i].NameOnly(), Int_.Min_value); if (ns_int == Int_.Min_value) continue;
|
||||
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_int); if (ns == null) continue;
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import org.junit.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xotdb_fsys_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_fsys_mgr_fxt fxt = new Xow_fsys_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();} private final Xow_fsys_mgr_fxt fxt = new Xow_fsys_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Zip_(Xotdb_dir_info_.Tid_page, Bool_.N).Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Tid__main, 123, "mem/xowa/wiki/en.wikipedia.org/ns/000/page/00/00/00/01/0000000123.xdat");
|
||||
fxt.Zip_(Xotdb_dir_info_.Tid_page, Bool_.Y).Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Tid__main, 123, "mem/xowa/wiki/en.wikipedia.org/ns/000/page_zip/00/00/00/01/0000000123.zip");
|
||||
@@ -31,7 +31,7 @@ class Xow_fsys_mgr_fxt {
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
Xoae_app app; Xowe_wiki wiki;
|
||||
public Xow_fsys_mgr_fxt Zip_(byte tid, boolean v) {wiki.Tdb_fsys_mgr().Tdb_dir_regy()[tid].Ext_tid_(v ? gplx.core.ios.Io_stream_.Tid_zip : gplx.core.ios.Io_stream_.Tid_raw); return this;}
|
||||
public Xow_fsys_mgr_fxt Zip_(byte tid, boolean v) {wiki.Tdb_fsys_mgr().Tdb_dir_regy()[tid].Ext_tid_(v ? gplx.core.ios.streams.Io_stream_.Tid_zip : gplx.core.ios.streams.Io_stream_.Tid_raw); return this;}
|
||||
public void Url_ns_fil(byte tid, int ns_id, int fil_idx, String expd) {
|
||||
Tfds.Eq(expd, wiki.Tdb_fsys_mgr().Url_ns_fil(tid, ns_id, fil_idx).Raw());
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xoa_hive_mgr {
|
||||
if (!hive_url.Eq(regy_mgr.Fil()))
|
||||
regy_mgr.Init(hive_url);
|
||||
return regy_mgr.Files_find(ttl);
|
||||
} private Xowd_regy_mgr regy_mgr = new Xowd_regy_mgr(); Int_obj_ref bry_len = Int_obj_ref.zero_(); Xob_xdat_file xdat_rdr = new Xob_xdat_file(); Xob_xdat_itm xdat_itm = new Xob_xdat_itm();
|
||||
} private Xowd_regy_mgr regy_mgr = new Xowd_regy_mgr(); Int_obj_ref bry_len = Int_obj_ref.New_zero(); Xob_xdat_file xdat_rdr = new Xob_xdat_file(); Xob_xdat_itm xdat_itm = new Xob_xdat_itm();
|
||||
public Xowd_regy_mgr Regy_mgr() {return regy_mgr;}
|
||||
public Xob_xdat_file Get_rdr(Io_url hive_root, byte[] fil_ext_bry, int fil_idx) {
|
||||
Bry_bfr tmp_bfr = app.Utl__bfr_mkr().Get_m001();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xob_hive_mgr {
|
||||
}
|
||||
Xob_xdat_file xdat_load_(Xob_xdat_file xdat, byte dir_tid, Xow_ns ns, int fil_idx) {
|
||||
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
return xdat;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class Xob_hive_mgr {
|
||||
byte dir_tid = Xotdb_dir_info_.Tid_ttl;
|
||||
int xdat_idx = Regy__find_file_ns(key, dir_tid, ns.Num_str());
|
||||
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), xdat_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
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());
|
||||
@@ -132,7 +132,7 @@ public class Xob_hive_mgr {
|
||||
// while (loop) {
|
||||
// if (fil_idx == -1) break;
|
||||
// Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
|
||||
// byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
// byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
// xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
// int row_idx = first && row_bgn != -1 ? row_bgn : xdat.Count() - 1;
|
||||
// first = false;
|
||||
@@ -155,7 +155,7 @@ public class Xob_hive_mgr {
|
||||
while (loop) {
|
||||
if (fil_idx == regy_len) break;
|
||||
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
int row_idx = first ? row_bgn : 0;
|
||||
int rows_len = xdat.Count();
|
||||
@@ -186,7 +186,7 @@ public class Xob_hive_mgr {
|
||||
int Regy__find_file_by_url(byte[] key, Io_url regy_url) {regy.Init(regy_url); return regy.Files_find(key);} private Xowd_regy_mgr regy = new Xowd_regy_mgr();
|
||||
private void Xdat__create_row(byte dir_tid, byte[] key, byte[] row, int xdat_idx) {
|
||||
Io_url xdat_url = fsys_mgr.Url_site_fil(dir_tid, xdat_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
Xob_xdat_file xdat_fil = new Xob_xdat_file();
|
||||
if (xdat_bry.length > 0) // if file is not empty, load it and parse it
|
||||
xdat_fil.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xow_hive_mgr_fxt {
|
||||
} private Xob_hive_mgr hive_mgr; Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public void Find_nearby(String key, int count, boolean include_redirects, String... expd) {
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
wiki.Hive_mgr().Find_bgn(list, wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), count, include_redirects);
|
||||
int actl_len = list.Count();
|
||||
String[] actl = new String[actl_len];
|
||||
@@ -47,7 +47,7 @@ public class Xow_hive_mgr_fxt {
|
||||
int id = 0;
|
||||
int ttl_bry_len = Int_.DigitCount(ttls_per_file);
|
||||
Xob_xdat_file_wtr xdat_wtr = Xob_xdat_file_wtr.new_file_(ttls_per_file * 8, wiki.Tdb_fsys_mgr().Url_ns_dir(ns.Num_str(), Xotdb_dir_info_.Tid_ttl));
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
byte ltr = Byte_ascii.Ltr_A; byte[] ttl_0 = Bry_.Empty, ttl_n = Bry_.Empty;
|
||||
for (int fil_idx = 0; fil_idx < files; fil_idx++) {
|
||||
for (int ttl_idx = 0; ttl_idx < ttls_per_file; ttl_idx++) {
|
||||
@@ -98,7 +98,7 @@ public class Xow_hive_mgr_fxt {
|
||||
}
|
||||
}
|
||||
class Xob_reg_wtr {
|
||||
Bry_bfr bfr = Bry_bfr.new_(); int fil_count = 0;
|
||||
Bry_bfr bfr = Bry_bfr_.New(); int fil_count = 0;
|
||||
public void Add(byte[] bgn, byte[] end, int itm_count) {
|
||||
bfr
|
||||
.Add_int_variable(fil_count++).Add_byte(Byte_ascii.Pipe)
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xowd_hive_regy_itm {// csv file with the format of "idx|bgn|end|cou
|
||||
List_adp rv = utl.Itms();
|
||||
byte[] ary = utl.Raw_bry();
|
||||
int ary_len = utl.Raw_len(); if (ary_len == 0) return Xowd_hive_regy_itm.Ary_empty; //throw Err_mgr.Instance.fmt_("xowa.wiki.data", "title_registry_file_not_found", "title_registry file not found: ~{0}", utl.Fil().Xto_api());
|
||||
Int_obj_ref pos = Int_obj_ref.zero_();
|
||||
Int_obj_ref pos = Int_obj_ref.New_zero();
|
||||
while (pos.Val() < ary_len) {
|
||||
Xowd_hive_regy_itm file = new Xowd_hive_regy_itm();
|
||||
file.idx = Bry_.ReadCsvInt(ary, pos, Bry_.Dlm_fld);
|
||||
@@ -49,5 +49,5 @@ public class Xowd_hive_regy_itm {// csv file with the format of "idx|bgn|end|cou
|
||||
.Add_int_variable(count).Add_byte_nl();
|
||||
}
|
||||
public static Xowd_hive_regy_itm tmp_() {return new Xowd_hive_regy_itm();}
|
||||
public static final Xowd_hive_regy_itm[] Ary_empty = new Xowd_hive_regy_itm[0];
|
||||
public static final Xowd_hive_regy_itm[] Ary_empty = new Xowd_hive_regy_itm[0];
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Xowd_regy_mgr {
|
||||
throw Err_.new_unimplemented(); // FUTURE: note that deletes are harder; rng ends could be deleted, so would need to open file and get new rng end
|
||||
}
|
||||
public void Save() {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int len = files_ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xowd_hive_regy_itm itm = files_ary[i];
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xof_meta_fil {
|
||||
private final Ordered_hash itms = Ordered_hash_.New_bry();
|
||||
private final Ordered_hash itms = Ordered_hash_.New_bry();
|
||||
public Xof_meta_fil(Xof_meta_mgr meta_mgr, byte[] md5) {this.meta_mgr = meta_mgr; this.md5 = md5;}
|
||||
public Xof_meta_mgr Owner_mgr() {return meta_mgr;} private final Xof_meta_mgr meta_mgr;
|
||||
public byte[] Md5() {return md5;} private final byte[] md5;
|
||||
public Xof_meta_mgr Owner_mgr() {return meta_mgr;} private final Xof_meta_mgr meta_mgr;
|
||||
public byte[] Md5() {return md5;} private final byte[] md5;
|
||||
public void Dirty_() {meta_mgr.Dirty_(this);}
|
||||
public Xof_meta_itm Get_or_new(byte[] ttl) {
|
||||
Xof_meta_itm rv = Get_or_null(ttl);
|
||||
@@ -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_(260); // 260 is max path of url
|
||||
} 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
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xof_meta_mgr implements GfoInvkAble {
|
||||
private Object[] root = new Object[16]; private final Ordered_hash dirty_fils = Ordered_hash_.New_bry();
|
||||
private final Gfo_fld_rdr rdr = Gfo_fld_rdr.xowa_(); private final Xof_meta_thumb_parser parser = new Xof_meta_thumb_parser();
|
||||
public class Xof_meta_mgr implements Gfo_invk {
|
||||
private Object[] root = new Object[16]; private final Ordered_hash dirty_fils = Ordered_hash_.New_bry();
|
||||
private final Gfo_fld_rdr rdr = Gfo_fld_rdr.xowa_(); private final Xof_meta_thumb_parser parser = new Xof_meta_thumb_parser();
|
||||
public Xof_meta_mgr(Xowe_wiki wiki) {this.wiki = wiki; this.root_dir = wiki.Appe().Fsys_mgr().File_dir().GenSubDir_nest("#meta", wiki.Domain_str());}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Io_url Root_dir() {return root_dir;} Io_url root_dir;
|
||||
@@ -51,7 +51,7 @@ public class Xof_meta_mgr implements GfoInvkAble {
|
||||
public void Save() {Save(false);}
|
||||
public void Save(boolean clear) {
|
||||
int dirty_len = dirty_fils.Count();
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
wtr.Bfr_(tmp_bfr);
|
||||
for (int i = 0; i < dirty_len; i++) {
|
||||
Xof_meta_fil fil = (Xof_meta_fil)dirty_fils.Get_at(i);
|
||||
@@ -75,7 +75,7 @@ public class Xof_meta_mgr implements GfoInvkAble {
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_regy_depth_)) depth = m.ReadInt("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_regy_depth_ = "depth_";
|
||||
static final String GRP_KEY = "xowa.file_regy.";
|
||||
|
||||
@@ -44,5 +44,5 @@ public class Xos_url_gen implements Io_url_gen {
|
||||
tmp_bfr.Add(ext);
|
||||
return Io_url_.new_fil_(tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
private static Bry_bfr tmp_bfr = Bry_bfr.reset_(256);
|
||||
private static Bry_bfr tmp_bfr = Bry_bfr_.Reset(256);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ 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.wikis.tdbs.xdats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.encoders.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.core.encoders.*;
|
||||
public class Xob_xdat_file {
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Src_len() {return src_len;} public Xob_xdat_file Src_len_(int v) {src_len = v; return this;} private int src_len; // NOTE: src_len can be different than src.length (occurs when reusing brys)
|
||||
@@ -98,9 +99,9 @@ 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;
|
||||
} 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_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Srl_save_bry(bfr);
|
||||
Io_stream_wtr wtr = Io_stream_wtr_.new_by_url_(url);
|
||||
try {
|
||||
@@ -179,7 +180,7 @@ public class Xob_xdat_file {
|
||||
public static byte[] Rebuid_header(byte[] orig, byte[] dlm) {
|
||||
byte[][] rows = Bry_split_.Split(orig, dlm);
|
||||
int rows_len = rows.length;
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int dlm_len = dlm.length;
|
||||
for (int i = 1; i < rows_len; i++) { // i=1; skip 1st row (which is empty header)
|
||||
byte[] row = rows[i];
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Xob_xdat_file_tst {
|
||||
private void Rebuild_header_tst(String orig, String expd) {
|
||||
Tfds.Eq_str_lines(expd, String_.new_a7(Xob_xdat_file.Rebuid_header(Bry_.new_a7(orig), Bry_.new_a7("\n"))));
|
||||
}
|
||||
Bry_bfr tmp = Bry_bfr.new_();
|
||||
Bry_bfr tmp = Bry_bfr_.New();
|
||||
private void tst_Sort(Xob_xdat_file rdr, gplx.core.lists.ComparerAble comparer, String expd) {
|
||||
rdr.Sort(tmp, comparer);
|
||||
Chk_file(rdr, expd);
|
||||
|
||||
@@ -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.wikis.tdbs.xdats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.encoders.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*; import gplx.core.encoders.*; import gplx.xowa.wikis.tdbs.*;
|
||||
public class Xob_xdat_file_wtr {
|
||||
public static Xob_xdat_file_wtr new_file_(int fil_max, Io_url root_dir) {return new Xob_xdat_file_wtr(fil_max, root_dir, Io_stream_.Tid_raw);}
|
||||
public static Xob_xdat_file_wtr new_by_tid_(int fil_max, Io_url root_dir, byte dir_tid, byte tid) {return new Xob_xdat_file_wtr(fil_max, root_dir.GenSubDir(Xotdb_dir_info_.Tid_name(dir_tid) + Xotdb_dir_info.Wtr_dir(tid)), tid);}
|
||||
@@ -24,7 +24,7 @@ public class Xob_xdat_file_wtr {
|
||||
this.fil_max = fil_max;
|
||||
this.root_dir = root_dir;
|
||||
fil_ext = Xotdb_dir_info.Wtr_ext(wtr_tid);
|
||||
bfr = Bry_bfr.new_(fil_max);
|
||||
bfr = Bry_bfr_.New_w_size(fil_max);
|
||||
idx = new int[fil_max / 8]; // ASSUME: any given row must at least be 8 bytes long
|
||||
Url_gen(fil_idx); // set 1st url
|
||||
wtr = Io_stream_wtr_.new_by_tid_(wtr_tid);
|
||||
@@ -143,6 +143,6 @@ class SortAlgo_quick {// quicksort
|
||||
if (lo < j) Sort_recurse(lo, j);
|
||||
if (i < hi) Sort_recurse(i, hi);
|
||||
}
|
||||
public static final SortAlgo_quick Instance = new SortAlgo_quick(); SortAlgo_quick() {}
|
||||
public static final SortAlgo_quick Instance = new SortAlgo_quick(); SortAlgo_quick() {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user