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:
@@ -33,16 +33,16 @@ public class Fsdb_db_mgr_ {
|
||||
}
|
||||
String domain_str = wiki.Domain_str();
|
||||
Fsdb_db_mgr rv = null;
|
||||
rv = load_or_null(Xowd_db_layout.Itm_few, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
|
||||
rv = load_or_null(Xowd_db_layout.Itm_lot, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
|
||||
rv = load_or_null(Xowd_db_layout.Itm_all, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
|
||||
rv = load_or_null(Xow_db_layout.Itm_few, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
|
||||
rv = load_or_null(Xow_db_layout.Itm_lot, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
|
||||
rv = load_or_null(Xow_db_layout.Itm_all, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
|
||||
usr_dlg.Log_many("", "", "fsdb.db_core.none: wiki_dir=~{0} file_dir=~{1}", wiki_dir.Raw(), file_dir.Raw());
|
||||
return null;
|
||||
}
|
||||
private static Fsdb_db_mgr load_or_null(Xowd_db_layout layout, Gfo_usr_dlg usr_dlg, Io_url wiki_dir, Xow_wiki wiki, String domain_str) {
|
||||
private static Fsdb_db_mgr load_or_null(Xow_db_layout layout, Gfo_usr_dlg usr_dlg, Io_url wiki_dir, Xow_wiki wiki, String domain_str) {
|
||||
Io_url main_core_url = wiki_dir.GenSubFil(Fsdb_db_mgr__v2_bldr.Main_core_name(layout, domain_str));
|
||||
if (!Db_conn_bldr.Instance.Exists(main_core_url)) return null;
|
||||
usr_dlg.Log_many("", "", "fsdb.db_core.v2: type=~{0} url=~{1}", layout.Name(), main_core_url.Raw());
|
||||
usr_dlg.Log_many("", "", "fsdb.db_core.v2: type=~{0} url=~{1}", layout.Key(), main_core_url.Raw());
|
||||
Db_conn main_core_conn = Db_conn_bldr.Instance.Get(main_core_url);
|
||||
if (wiki.Data__core_mgr().Props().Layout_file().Tid_is_all()) {
|
||||
return new Fsdb_db_mgr__v2(Fsdb_db_mgr__v2.Cfg__layout_file__get(main_core_conn), wiki_dir, new Fsdb_db_file(main_core_url, main_core_conn), new Fsdb_db_file(main_core_url, main_core_conn));
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb; import gplx.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.fsdb.meta.*; import gplx.xowa.files.origs.*; import gplx.xowa.wikis.data.*;
|
||||
public class Fsdb_db_mgr__v2 implements Fsdb_db_mgr {
|
||||
private final Xowd_db_layout layout; private final Io_url wiki_dir;
|
||||
private final Xow_db_layout layout; private final Io_url wiki_dir;
|
||||
private final Fsdb_db_file file_main_core, file_user_core;
|
||||
private final Xof_orig_tbl[] orig_tbl_ary;
|
||||
public Fsdb_db_mgr__v2(Xowd_db_layout layout, Io_url wiki_dir, Fsdb_db_file file_main_core, Fsdb_db_file file_user_core) {
|
||||
public Fsdb_db_mgr__v2(Xow_db_layout layout, Io_url wiki_dir, Fsdb_db_file file_main_core, Fsdb_db_file file_user_core) {
|
||||
this.layout = layout; this.wiki_dir = wiki_dir;
|
||||
this.file_main_core = file_main_core; this.file_user_core = file_user_core;
|
||||
this.orig_tbl_ary = new Xof_orig_tbl[]
|
||||
@@ -55,12 +55,12 @@ public class Fsdb_db_mgr__v2 implements Fsdb_db_mgr {
|
||||
gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn).Create_tbl();
|
||||
return Fsdb_db_mgr__v2_bldr.Make_bin_tbl(new Fsdb_db_file(url, conn));
|
||||
}
|
||||
public static Xowd_db_layout Cfg__layout_file__get(Db_conn main_core_conn) {
|
||||
public static Xow_db_layout Cfg__layout_file__get(Db_conn main_core_conn) {
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(main_core_conn);
|
||||
return Xowd_db_layout.get_(cfg_tbl.Select_str_or(gplx.xowa.wikis.Xow_cfg_consts.Grp__bldr_fsdb, Cfg_key__layout_file, Xowd_db_layout.Name_few));
|
||||
return Xow_db_layout.Get_by_name(cfg_tbl.Select_str_or(gplx.xowa.wikis.Xow_cfg_consts.Grp__bldr_fsdb, Cfg_key__layout_file, Xow_db_layout.Key__few));
|
||||
}
|
||||
public static void Cfg__layout_file__set(Db_cfg_tbl cfg_tbl, Xowd_db_layout v) {
|
||||
cfg_tbl.Insert_str(gplx.xowa.wikis.Xow_cfg_consts.Grp__bldr_fsdb, Cfg_key__layout_file, v.Name());
|
||||
public static void Cfg__layout_file__set(Db_cfg_tbl cfg_tbl, Xow_db_layout v) {
|
||||
cfg_tbl.Insert_str(gplx.xowa.wikis.Xow_cfg_consts.Grp__bldr_fsdb, Cfg_key__layout_file, v.Key());
|
||||
}
|
||||
private static final String Cfg_key__layout_file = "layout_file";
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.fsdb.meta.*; import gplx.
|
||||
import gplx.xowa.*; import gplx.xowa.wikis.data.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Fsdb_db_mgr__v2_bldr {
|
||||
public static Fsdb_db_mgr__v2 Get_or_make(Xow_wiki wiki, boolean delete_if_exists) { // NOTE: must check if file exists else imports with existing v2 dbs will fail; DATE:2015-05-23
|
||||
Xowd_db_layout layout = wiki.Data__core_mgr().Props().Layout_file();
|
||||
Xow_db_layout layout = wiki.Data__core_mgr().Props().Layout_file();
|
||||
String domain_str = wiki.Domain_str();
|
||||
Io_url wiki_dir = wiki.Fsys_mgr().Root_dir();
|
||||
String main_core_name = Main_core_name(layout, domain_str);
|
||||
@@ -38,7 +38,7 @@ public class Fsdb_db_mgr__v2_bldr {
|
||||
return new Fsdb_db_mgr__v2(layout, wiki_dir, main_core_file, user_core_file);
|
||||
}
|
||||
private static Fsdb_db_file Load_core_file(Io_url url) {return new Fsdb_db_file(url, Db_conn_bldr.Instance.Get(url));}
|
||||
private static Fsdb_db_file Make_core_file_main(Xow_wiki wiki, Io_url main_core_url, String main_core_name, Xowd_db_layout layout) {
|
||||
private static Fsdb_db_file Make_core_file_main(Xow_wiki wiki, Io_url main_core_url, String main_core_name, Xow_db_layout layout) {
|
||||
Db_conn conn = layout.Tid_is_all() ? Db_conn_bldr.Instance.Get(main_core_url) : Db_conn_bldr.Instance.New(main_core_url); // if all, use existing (assumes same file name); else, create new
|
||||
conn.Txn_bgn("fsdb__core_file");
|
||||
Fsdb_db_file rv = Make_core_file(main_core_url, conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_main);
|
||||
@@ -54,7 +54,7 @@ public class Fsdb_db_mgr__v2_bldr {
|
||||
Fsdb_db_file rv = Make_core_file(user_core_url, conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_user);
|
||||
Fsm_bin_tbl dbb_tbl = new Fsm_bin_tbl(conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_user); dbb_tbl.Insert(0, user_file_name);
|
||||
Make_bin_tbl(rv);
|
||||
Make_cfg_data(wiki, main_core_name, rv, Xowd_db_file_.Tid_file_user, -1);
|
||||
Make_cfg_data(wiki, main_core_name, rv, Xow_db_file_.Tid__file_user, -1);
|
||||
conn.Txn_end();
|
||||
return rv;
|
||||
}
|
||||
@@ -81,27 +81,27 @@ public class Fsdb_db_mgr__v2_bldr {
|
||||
Fsd_bin_tbl bin_tbl = new Fsd_bin_tbl(file.Conn(), schema_is_1); bin_tbl.Create_tbl();
|
||||
return file;
|
||||
}
|
||||
public static String Main_core_name(Xowd_db_layout layout, String wiki_domain) {
|
||||
public static String Main_core_name(Xow_db_layout layout, String wiki_domain) {
|
||||
switch (layout.Tid()) {
|
||||
case Xowd_db_layout.Const_all: return Main_core_name_all(wiki_domain);
|
||||
case Xowd_db_layout.Const_few: return Main_core_name_few(wiki_domain);
|
||||
case Xowd_db_layout.Const_lot: return Main_core_name_lot(wiki_domain);
|
||||
case Xow_db_layout.Tid__all: return Main_core_name_all(wiki_domain);
|
||||
case Xow_db_layout.Tid__few: return Main_core_name_few(wiki_domain);
|
||||
case Xow_db_layout.Tid__lot: return Main_core_name_lot(wiki_domain);
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
private static byte Main_core_tid(Xowd_db_layout layout) {
|
||||
private static byte Main_core_tid(Xow_db_layout layout) {
|
||||
switch (layout.Tid()) {
|
||||
case Xowd_db_layout.Const_all: return Xowd_db_file_.Tid_core;
|
||||
case Xowd_db_layout.Const_few: return Xowd_db_file_.Tid_file_solo;
|
||||
case Xowd_db_layout.Const_lot: return Xowd_db_file_.Tid_file_core;
|
||||
case Xow_db_layout.Tid__all: return Xow_db_file_.Tid__core;
|
||||
case Xow_db_layout.Tid__few: return Xow_db_file_.Tid__file_solo;
|
||||
case Xow_db_layout.Tid__lot: return Xow_db_file_.Tid__file_core;
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static void Make_cfg_data(Xow_wiki wiki, String file_core_name, Fsdb_db_file file, byte file_tid, int part_id) {
|
||||
Db_cfg_tbl cfg_tbl = file.Tbl__cfg();
|
||||
Xowd_db_file core_db = wiki.Data__core_mgr().Db__core();
|
||||
Xow_db_file core_db = wiki.Data__core_mgr().Db__core();
|
||||
core_db.Info_session().Save(cfg_tbl);
|
||||
Xob_info_file info_file = new Xob_info_file(-1, Xowd_db_file_.To_key(file_tid), Xob_info_file.Ns_ids_empty, part_id, Guid_adp_.new_(), 2, file_core_name, file.Url().NameAndExt());
|
||||
Xob_info_file info_file = new Xob_info_file(-1, Xow_db_file_.To_key(file_tid), Xob_info_file.Ns_ids_empty, part_id, Guid_adp_.New(), 2, file_core_name, file.Url().NameAndExt());
|
||||
info_file.Save(cfg_tbl);
|
||||
}
|
||||
private static String Main_core_name_all(String wiki_domain) {return wiki_domain + ".xowa";} // EX: en.wikipedia.org.xowa
|
||||
|
||||
34
400_xowa/src/gplx/fsdb/data/Fsd_bin_itm.java
Normal file
34
400_xowa/src/gplx/fsdb/data/Fsd_bin_itm.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
public class Fsd_bin_itm {
|
||||
public Fsd_bin_itm(int bin_owner_id, byte bin_owner_tid, int bin_part_id, String bin_data_url, byte[] bin_data) {
|
||||
this.bin_owner_id = bin_owner_id;
|
||||
this.bin_owner_tid = bin_owner_tid;
|
||||
this.bin_part_id = bin_part_id;
|
||||
this.bin_data_url = bin_data_url;
|
||||
this.bin_data = bin_data;
|
||||
}
|
||||
public int Bin_owner_id() {return bin_owner_id;} private final int bin_owner_id;
|
||||
public byte Bin_owner_tid() {return bin_owner_tid;} private final byte bin_owner_tid;
|
||||
public int Bin_part_id() {return bin_part_id;} private final int bin_part_id;
|
||||
public String Bin_data_url() {return bin_data_url;} private final String bin_data_url;
|
||||
public byte[] Bin_data() {return bin_data;} private final byte[] bin_data;
|
||||
|
||||
public static final int Db_row_size_fixed = (3 * 4); // bin_owner_id, bin_part_id, bin_owner_tid (assume byte saved as int in SQLITE)
|
||||
}
|
||||
@@ -17,13 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.primitives.*; import gplx.core.envs.*;
|
||||
import gplx.dbs.*; import gplx.core.ios.*;
|
||||
import gplx.dbs.*; import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.dbs.engines.sqlite.*;
|
||||
public class Fsd_bin_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_bin"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_owner_id, fld_owner_tid, fld_part_id, fld_data_url, fld_data;
|
||||
private Db_conn conn; private Db_stmt stmt_insert, stmt_select; private Bry_bfr tmp_bfr;
|
||||
private final Bool_obj_ref saved_in_parts = Bool_obj_ref.n_();
|
||||
public class Fsd_bin_tbl implements Rls_able {
|
||||
private final String fld_owner_id, fld_owner_tid, fld_part_id, fld_data_url, fld_data;
|
||||
private Db_conn conn; private Db_stmt stmt_insert, stmt_select, stmt_select_itm; private Bry_bfr tmp_bfr;
|
||||
private final Bool_obj_ref saved_in_parts = Bool_obj_ref.n_();
|
||||
public Fsd_bin_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
fld_owner_id = flds.Add_int_pkey ("bin_owner_id");
|
||||
@@ -33,9 +32,12 @@ public class Fsd_bin_tbl implements Rls_able {
|
||||
fld_data = flds.Add_bry ("bin_data"); // mediumblob
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name = "fsdb_bin";
|
||||
public Dbmeta_fld_list Flds() {return flds;} private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
stmt_select = Db_stmt_.Rls(stmt_select);
|
||||
stmt_select_itm = Db_stmt_.Rls(stmt_select_itm);
|
||||
}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("fsdb_bin__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
@@ -44,7 +46,7 @@ public class Fsd_bin_tbl implements Rls_able {
|
||||
public void Insert_rdr(int id, byte tid, long bin_len, Io_stream_rdr bin_rdr) {
|
||||
if (stmt_insert == null) {
|
||||
stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
tmp_bfr = Bry_bfr.reset_(Io_mgr.Len_kb);
|
||||
tmp_bfr = Bry_bfr_.Reset(Io_mgr.Len_kb);
|
||||
}
|
||||
byte[] bin_ary = null;
|
||||
bin_ary = Io_stream_rdr_.Load_all_as_bry(tmp_bfr, bin_rdr);
|
||||
@@ -78,7 +80,7 @@ public class Fsd_bin_tbl implements Rls_able {
|
||||
byte[] rv = null;
|
||||
try {rv = rdr.Read_bry(fld_data);}
|
||||
catch (Exception e) {
|
||||
if ( Op_sys.Cur().Tid_is_drd()
|
||||
if ( Op_sys.Cur().Tid_is_drd() // drd error when selecting large blobs (> 4 MB?)
|
||||
&& url != null // called by Select_to_url
|
||||
&& String_.Has(Err_.Message_lang(e), "get field slot from row") // get field slot from row 0 col 0 failed
|
||||
) {
|
||||
@@ -93,6 +95,24 @@ public class Fsd_bin_tbl implements Rls_able {
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public Fsd_bin_itm Select_as_itm(int owner_id) {
|
||||
if (stmt_select_itm == null) stmt_select_itm = conn.Stmt_select(tbl_name, flds, fld_owner_id);
|
||||
Db_rdr rdr = stmt_select_itm.Clear().Crt_int(fld_owner_id, owner_id).Exec_select__rls_manual();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
return new Fsd_bin_itm
|
||||
( rdr.Read_int(fld_owner_id)
|
||||
, rdr.Read_byte(fld_owner_tid)
|
||||
, rdr.Read_int(fld_part_id)
|
||||
, rdr.Read_str(fld_data_url)
|
||||
, rdr.Read_bry(fld_data)
|
||||
);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public static final byte Owner_tid_fil = 1, Owner_tid_thm = 2;
|
||||
public static final int Bin_db_id_null = -1, Size_null = -1;
|
||||
private static final int Part_id_null = -1;
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
public class Fsd_dir_itm {
|
||||
public Fsd_dir_itm(int dir_id, int owner, byte[] name) {this.dir_id = dir_id; this.owner = owner; this.name = name;}
|
||||
public int Dir_id() {return dir_id;} private final int dir_id;
|
||||
public int Owner() {return owner;} private final int owner;
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
public int Dir_id() {return dir_id;} private final int dir_id;
|
||||
public int Owner() {return owner;} private final int owner;
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
public static final int Owner_root = 0;
|
||||
public static final Fsd_dir_itm Null = null;
|
||||
public static final Fsd_dir_itm Null = null;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*;
|
||||
public class Fsd_dir_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_dir"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_name;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name;
|
||||
private final String tbl_name = "fsdb_dir"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_id, fld_owner_id, fld_name;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name;
|
||||
public Fsd_dir_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
this.fld_id = flds.Add_int_pkey ("dir_id");
|
||||
|
||||
@@ -17,17 +17,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
public class Fsd_fil_itm {
|
||||
public int Mnt_id() {return mnt_id;} private int mnt_id;
|
||||
public int Fil_id() {return fil_id;} private int fil_id;
|
||||
public int Dir_id() {return dir_id;} private int dir_id;
|
||||
public int Xtn_id() {return xtn_id;} private int xtn_id;
|
||||
public int Ext_id() {return ext_id;} private int ext_id;
|
||||
public byte[] Name() {return name;} private byte[] name;
|
||||
public int Bin_db_id() {return bin_db_id;} private int bin_db_id;
|
||||
public long Size() {return size;} private long size;
|
||||
public String Modified_on() {return modified_on;} private String modified_on;
|
||||
public String Hash_md5() {return hash_md5;} private String hash_md5;
|
||||
|
||||
public Fsd_fil_itm Ctor(int mnt_id, int dir_id, int fil_id, int bin_db_id, byte[] name, int ext_id) {
|
||||
this.mnt_id = mnt_id; this.dir_id = dir_id; this.fil_id = fil_id; this.bin_db_id = bin_db_id; this.name = name; this.ext_id = ext_id;
|
||||
return this;
|
||||
}
|
||||
public int Mnt_id() {return mnt_id;} private int mnt_id;
|
||||
public int Fil_id() {return fil_id;} private int fil_id;
|
||||
public int Dir_id() {return dir_id;} private int dir_id;
|
||||
public int Bin_db_id() {return bin_db_id;} private int bin_db_id;
|
||||
public byte[] Name() {return name;} private byte[] name;
|
||||
public int Ext_id() {return ext_id;} private int ext_id;
|
||||
public static final Fsd_fil_itm Null = null;
|
||||
public Fsd_fil_itm Load_by_rdr__full(int mnt_id, int dir_id, int fil_id, int xtn_id, int ext_id, byte[] name, long size, String modified_on, String hash_md5, int bin_db_id) {
|
||||
this.mnt_id = mnt_id; this.dir_id = dir_id; this.fil_id = fil_id; this.xtn_id = xtn_id; this.ext_id = ext_id;
|
||||
this.name = name; this.size = size; this.modified_on = modified_on; this.hash_md5 = hash_md5; this.bin_db_id = bin_db_id;
|
||||
return this;
|
||||
}
|
||||
public int Db_row_size() {return Db_row_size_fixed + name.length;}
|
||||
private static final int Db_row_size_fixed =
|
||||
(7 * 4) // 6 int fields + 1 byte field
|
||||
+ 8 // 1 long field
|
||||
+ 32 // hash_md5
|
||||
+ 14 // modified_on
|
||||
;
|
||||
|
||||
public static final Fsd_fil_itm Null = null;
|
||||
public static byte[] Gen_cache_key(Bry_bfr bfr, int dir_id, byte[] name) {
|
||||
return bfr.Add_int_variable(dir_id).Add_byte_pipe().Add(name).To_bry_and_clear();
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Fsd_fil_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_fil"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_name, fld_xtn_id, fld_ext_id, fld_size, fld_modified, fld_hash, fld_bin_db_id;
|
||||
private final String idx_owner;
|
||||
private Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name; private int mnt_id;
|
||||
public final String tbl_name = "fsdb_fil"; public final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
public final String fld_id, fld_owner_id, fld_name, fld_xtn_id, fld_ext_id, fld_size, fld_modified, fld_hash, fld_bin_db_id;
|
||||
private final String idx_owner;
|
||||
public final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name; private int mnt_id;
|
||||
public Fsd_fil_tbl(Db_conn conn, boolean schema_is_1, int mnt_id) {
|
||||
this.conn = conn; this.mnt_id = mnt_id;
|
||||
this.fld_id = flds.Add_int_pkey ("fil_id");
|
||||
@@ -48,7 +48,10 @@ public class Fsd_fil_tbl implements Rls_able {
|
||||
}
|
||||
public void Insert(int id, int owner_id, byte[] name, int xtn_id, int ext_id, long size, int bin_db_id) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
Insert(stmt_insert, id, owner_id, name, xtn_id, ext_id, size, bin_db_id, String_.Empty, String_.Empty);
|
||||
}
|
||||
public void Insert(Db_stmt stmt, int id, int owner_id, byte[] name, int xtn_id, int ext_id, long size, int bin_db_id, String modified_on, String hash_md5) {
|
||||
stmt.Clear()
|
||||
.Val_int(fld_id, id)
|
||||
.Val_int(fld_owner_id, owner_id)
|
||||
.Val_int(fld_xtn_id, xtn_id)
|
||||
@@ -56,8 +59,8 @@ public class Fsd_fil_tbl implements Rls_able {
|
||||
.Val_int(fld_bin_db_id, bin_db_id)
|
||||
.Val_bry_as_str(fld_name, name)
|
||||
.Val_long(fld_size, size)
|
||||
.Val_str(fld_modified, String_.Empty)
|
||||
.Val_str(fld_hash, String_.Empty)
|
||||
.Val_str(fld_modified, modified_on)
|
||||
.Val_str(fld_hash, hash_md5)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Update(int id, int owner_id, byte[] name, int xtn_id, int ext_id, long size, int bin_db_id) {
|
||||
@@ -84,7 +87,7 @@ public class Fsd_fil_tbl implements Rls_able {
|
||||
.Crt_bry_as_str(fld_name, fil_name)
|
||||
.Exec_select__rls_manual();
|
||||
try {
|
||||
return rdr.Move_next() ? new_(mnt_id, rdr) : Fsd_fil_itm.Null;
|
||||
return rdr.Move_next() ? Load_by_rdr(mnt_id, rdr) : Fsd_fil_itm.Null;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
@@ -92,14 +95,28 @@ public class Fsd_fil_tbl implements Rls_able {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, Dbmeta_fld_itm.Str_ary_empty).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Fsd_fil_itm fil = new_(mnt_id, rdr);
|
||||
Fsd_fil_itm fil = Load_by_rdr(mnt_id, rdr);
|
||||
byte[] cache_key = Fsd_fil_itm.Gen_cache_key(key_bfr, fil.Dir_id(), fil.Name());
|
||||
cache.Add(cache_key, fil);
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Fsd_fil_itm new_(int mnt_id, Db_rdr rdr) {
|
||||
public Fsd_fil_itm Load_by_rdr(int mnt_id, Db_rdr rdr) {
|
||||
return new Fsd_fil_itm().Ctor(mnt_id, rdr.Read_int(fld_owner_id), rdr.Read_int(fld_id), rdr.Read_int(fld_bin_db_id), rdr.Read_bry_by_str(fld_name), rdr.Read_int(fld_ext_id));
|
||||
}
|
||||
public Fsd_fil_itm Load_by_rdr__full(int mnt_id, Db_rdr rdr) {
|
||||
return new Fsd_fil_itm()
|
||||
.Load_by_rdr__full(mnt_id
|
||||
, rdr.Read_int(fld_owner_id)
|
||||
, rdr.Read_int(fld_id)
|
||||
, rdr.Read_int(fld_xtn_id)
|
||||
, rdr.Read_int(fld_ext_id)
|
||||
, rdr.Read_bry_by_str(fld_name)
|
||||
, rdr.Read_long(fld_size)
|
||||
, rdr.Read_str(fld_modified)
|
||||
, rdr.Read_str(fld_hash)
|
||||
, rdr.Read_int(fld_bin_db_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,16 @@ public class Fsd_thm_itm {
|
||||
this.w = comp.w; this.h = comp.h; this.time = comp.time; this.page = comp.page;
|
||||
this.size = comp.size; this.modified = comp.modified; this.hash = comp.hash;
|
||||
}
|
||||
public static final Fsd_thm_itm Null = null;
|
||||
public static final Fsd_thm_itm[] Ary_empty = new Fsd_thm_itm[0];
|
||||
public int Db_row_size() {return Db_row_size_fixed;}
|
||||
private static final int Db_row_size_fixed =
|
||||
(7 * 4) // 7 ints
|
||||
+ (2 * 8) // 1 long; 1 double
|
||||
+ 32 // hash_md5
|
||||
+ 14 // modified_on
|
||||
;
|
||||
|
||||
public static final Fsd_thm_itm Null = null;
|
||||
public static final Fsd_thm_itm[] Ary_empty = new Fsd_thm_itm[0];
|
||||
public static Fsd_thm_itm new_() {return new Fsd_thm_itm();} Fsd_thm_itm() {}
|
||||
}
|
||||
class Fsdb_thm_itm_sorter implements gplx.core.lists.ComparerAble {
|
||||
@@ -56,5 +64,5 @@ class Fsdb_thm_itm_sorter implements gplx.core.lists.ComparerAble {
|
||||
comp = Double_.Compare (lhs.Time() , rhs.Time()); if (comp != CompareAble_.Same) return comp; // sort by increasing time
|
||||
return Int_.Compare (lhs.Page() , rhs.Page()); // sort by increasing page
|
||||
}
|
||||
public static final Fsdb_thm_itm_sorter Instance = new Fsdb_thm_itm_sorter(); Fsdb_thm_itm_sorter() {}
|
||||
public static final Fsdb_thm_itm_sorter Instance = new Fsdb_thm_itm_sorter(); Fsdb_thm_itm_sorter() {}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.fsdb.meta.*; import gplx.xowa.files.*;
|
||||
public class Fsd_thm_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_w, fld_h, fld_time, fld_page, fld_bin_db_id, fld_size, fld_modified, fld_hash;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_by_fil_exact, stmt_select_by_fil_near; private int mnt_id; private boolean schema_thm_page;
|
||||
public final String tbl_name; public final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
public final String fld_id, fld_owner_id, fld_w, fld_h, fld_time, fld_page, fld_bin_db_id, fld_size, fld_modified, fld_hash;
|
||||
public final Db_conn conn; private Db_stmt stmt_insert, stmt_select_by_fil_exact, stmt_select_by_fil_near; private int mnt_id; private boolean schema_thm_page;
|
||||
public Fsd_thm_tbl(Db_conn conn, boolean schema_is_1, int mnt_id, boolean schema_thm_page) {
|
||||
this.conn = conn; this.mnt_id = mnt_id; this.schema_thm_page = schema_thm_page;
|
||||
this.tbl_name = schema_is_1 ? "fsdb_xtn_thm" : "fsdb_thm";
|
||||
@@ -54,22 +54,25 @@ public class Fsd_thm_tbl implements Rls_able {
|
||||
}
|
||||
public void Insert(int id, int thm_owner_id, int width, int height, double thumbtime, int page, int bin_db_id, long size) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
this.Insert(stmt_insert, id, thm_owner_id, width, height, thumbtime, page, bin_db_id, size, Modified_null_str, Hash_null);
|
||||
}
|
||||
public void Insert(Db_stmt stmt, int id, int thm_owner_id, int width, int height, double thumbtime, int page, int bin_db_id, long size, String modified, String hash_md5) {
|
||||
stmt.Clear()
|
||||
.Val_int(fld_id, id)
|
||||
.Val_int(fld_owner_id, thm_owner_id)
|
||||
.Val_int(fld_w, width)
|
||||
.Val_int(fld_h, height);
|
||||
if (schema_thm_page) {
|
||||
stmt_insert.Val_double (fld_time, Xof_lnki_time.Db_save_double(thumbtime));
|
||||
stmt_insert.Val_int (fld_page, Xof_lnki_page.Db_save_int(page));
|
||||
stmt.Val_double (fld_time, Xof_lnki_time.Db_save_double(thumbtime));
|
||||
stmt.Val_int (fld_page, Xof_lnki_page.Db_save_int(page));
|
||||
}
|
||||
else
|
||||
stmt_insert.Val_int (fld_time, Xof_lnki_time.Db_save_int(thumbtime));
|
||||
stmt_insert
|
||||
stmt.Val_int (fld_time, Xof_lnki_time.Db_save_int(thumbtime));
|
||||
stmt
|
||||
.Val_int(fld_bin_db_id, bin_db_id)
|
||||
.Val_long(fld_size, size)
|
||||
.Val_str(fld_modified, Modified_null_str)
|
||||
.Val_str(fld_hash, Hash_null)
|
||||
.Val_str(fld_modified, modified)
|
||||
.Val_str(fld_hash, hash_md5)
|
||||
.Exec_insert();
|
||||
}
|
||||
public boolean Select_itm_by_w_exact(int dir_id, int fil_id, Fsd_thm_itm thm) {
|
||||
@@ -92,7 +95,7 @@ public class Fsd_thm_tbl implements Rls_able {
|
||||
}
|
||||
public boolean Select_itm_by_w_near(int dir_id, int fil_id, Fsd_thm_itm thm) {
|
||||
if (stmt_select_by_fil_near == null) stmt_select_by_fil_near = conn.Stmt_select(tbl_name, flds, fld_owner_id);
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
Db_rdr rdr = stmt_select_by_fil_near.Clear().Crt_int(fld_owner_id, fil_id).Exec_select__rls_manual();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
@@ -104,7 +107,7 @@ public class Fsd_thm_tbl implements Rls_able {
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private boolean Ctor_by_load(Fsd_thm_itm itm, Db_rdr rdr, int dir_id) {
|
||||
public boolean Ctor_by_load(Fsd_thm_itm itm, Db_rdr rdr, int dir_id) {
|
||||
int thm_id = rdr.Read_int(fld_id);
|
||||
int fil_id = rdr.Read_int(fld_owner_id);
|
||||
int w = rdr.Read_int(fld_w);
|
||||
@@ -126,7 +129,7 @@ public class Fsd_thm_tbl implements Rls_able {
|
||||
itm.Ctor(mnt_id, dir_id, fil_id, thm_id, bin_db_id, w, h, time, page, size, modified, hash);
|
||||
return true;
|
||||
}
|
||||
public static final DateAdp Modified_null = null;
|
||||
public static final DateAdp Modified_null = null;
|
||||
public static final String Hash_null = "", Modified_null_str = "";
|
||||
public static boolean Match_nearest(List_adp list, Fsd_thm_itm thm, boolean schema_thm_page) {
|
||||
int len = list.Count(); if (len == 0) return Bool_.N;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Fsd_thm_tbl_tst {
|
||||
}
|
||||
}
|
||||
class Fsd_thm_tbl_fxt {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private final List_adp list = List_adp_.New();
|
||||
public void Clear() {list.Clear();}
|
||||
public Fsd_thm_itm Make(int w) {
|
||||
double time = gplx.xowa.files.Xof_lnki_time.Null;
|
||||
|
||||
@@ -16,12 +16,12 @@ 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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.primitives.*; import gplx.core.caches.*; import gplx.core.ios.*;
|
||||
import gplx.core.primitives.*; import gplx.core.caches.*; import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.fsdb.data.*;
|
||||
public class Fsm_atr_fil {
|
||||
private final Fsm_mnt_itm mnt_itm; private final int mnt_id;
|
||||
private final Fsm_mnt_itm mnt_itm; private final int mnt_id;
|
||||
private Fsd_dir_tbl tbl_dir; private Fsd_fil_tbl tbl_fil; private Fsd_thm_tbl tbl_thm;
|
||||
private final Gfo_cache_mgr_bry dir_cache = new Gfo_cache_mgr_bry(); private Gfo_cache_mgr_bry fil_cache; private Bry_bfr fil_cache_key_bfr;
|
||||
private final Gfo_cache_mgr_bry dir_cache = new Gfo_cache_mgr_bry(); private Gfo_cache_mgr_bry fil_cache; private Bry_bfr fil_cache_key_bfr;
|
||||
public Fsm_atr_fil(Fsm_mnt_itm mnt_itm, int id, String url_rel, Db_conn conn, boolean schema_is_1, boolean schema_thm_page) {
|
||||
this.mnt_itm = mnt_itm; this.mnt_id = mnt_itm.Id();
|
||||
this.id = id; this.url_rel = url_rel; this.conn = conn;
|
||||
@@ -29,9 +29,9 @@ public class Fsm_atr_fil {
|
||||
this.tbl_fil = new Fsd_fil_tbl(conn, schema_is_1, mnt_id);
|
||||
this.tbl_thm = new Fsd_thm_tbl(conn, schema_is_1, mnt_id, schema_thm_page);
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public Fsd_fil_itm Select_fil_or_null(byte[] dir, byte[] fil) {
|
||||
int dir_id = Get_dir_id_or_neg1(dir);
|
||||
return dir_id == Int_.Neg1 ? Fsd_fil_itm.Null : tbl_fil.Select_or_null(dir_id, fil);
|
||||
@@ -61,7 +61,7 @@ public class Fsm_atr_fil {
|
||||
}
|
||||
public void Fil_cache_enabled_y_() {
|
||||
fil_cache = new Gfo_cache_mgr_bry();
|
||||
fil_cache_key_bfr = Bry_bfr.reset_(255);
|
||||
fil_cache_key_bfr = Bry_bfr_.Reset(255);
|
||||
tbl_fil.Select_all(fil_cache_key_bfr, fil_cache);
|
||||
}
|
||||
private int Get_dir_id_or_neg1(byte[] dir_bry) {
|
||||
@@ -70,7 +70,7 @@ public class Fsm_atr_fil {
|
||||
Fsd_dir_itm itm = tbl_dir.Select_or_null(dir_bry); // try db
|
||||
if (itm == Fsd_dir_itm.Null) return -1; // not in db
|
||||
int dir_id = itm.Dir_id();
|
||||
dir_cache.Add(dir_bry, Int_obj_ref.new_(dir_id)); // add to mem
|
||||
dir_cache.Add(dir_bry, Int_obj_ref.New(dir_id)); // add to mem
|
||||
return dir_id;
|
||||
}
|
||||
else
|
||||
@@ -81,7 +81,7 @@ public class Fsm_atr_fil {
|
||||
if (rv == -1) {
|
||||
rv = mnt_itm.Next_id();
|
||||
tbl_dir.Insert(rv, dir_bry, Fsd_dir_itm.Owner_root);
|
||||
dir_cache.Add(dir_bry, Int_obj_ref.new_(rv));
|
||||
dir_cache.Add(dir_bry, Int_obj_ref.New(rv));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
public class Fsm_atr_tbl {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_uid, fld_url;
|
||||
private final Db_conn conn;
|
||||
public final String tbl_name; public final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_uid, fld_url;
|
||||
private final Db_conn conn;
|
||||
public Fsm_atr_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
String fld_prefix = "";
|
||||
|
||||
@@ -16,25 +16,26 @@ 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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*; import gplx.dbs.*;
|
||||
import gplx.fsdb.data.*;
|
||||
public class Fsm_bin_fil {
|
||||
private final Fsd_bin_tbl tbl;
|
||||
private final Fsd_bin_tbl tbl;
|
||||
public Fsm_bin_fil(boolean schema_is_1, int id, Io_url url, String url_rel, Db_conn conn, long bin_len) {
|
||||
this.id = id; this.url = url; this.url_rel = url_rel; this.conn = conn; this.bin_len = bin_len;
|
||||
this.tbl = new Fsd_bin_tbl(conn, schema_is_1);
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public int Id() {return id;} private final int id;
|
||||
public Io_url Url() {return url;} private Io_url url;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public long Bin_len() {return bin_len;} public void Bin_len_(long v) {bin_len = v;} private long bin_len;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public boolean Select_to_url(int id, Io_url url) {return tbl.Select_to_url(id, url);}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public boolean Select_to_url(int id, Io_url url) {return tbl.Select_to_url(id, url);}
|
||||
public Io_stream_rdr Select_as_rdr(int id) {return tbl.Select_as_rdr(id);}
|
||||
public void Insert(int bin_id, byte owner_tid, long rdr_len, gplx.core.ios.Io_stream_rdr rdr) {
|
||||
public Fsd_bin_itm Select_as_itm(int id) {return tbl.Select_as_itm(id);}
|
||||
public void Insert(int bin_id, byte owner_tid, long rdr_len, gplx.core.ios.streams.Io_stream_rdr rdr) {
|
||||
tbl.Insert_rdr(bin_id, owner_tid, rdr_len, rdr);
|
||||
Bin_len_(bin_len + rdr_len);
|
||||
}
|
||||
public static final Fsm_bin_fil[] Ary_empty = new Fsm_bin_fil[0];
|
||||
public static final Fsm_bin_fil[] Ary_empty = new Fsm_bin_fil[0];
|
||||
public static final long Bin_len_null = 0;
|
||||
}
|
||||
|
||||
@@ -16,45 +16,50 @@ 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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*; import gplx.dbs.*;
|
||||
public class Fsm_bin_mgr {
|
||||
private final Fsdb_db_mgr core_mgr; private final int mnt_id; private final Fsm_bin_tbl tbl;
|
||||
private Fsm_bin_fil[] dbs__ary = Fsm_bin_fil.Ary_empty; private int dbs__ary_len = 0; private Fsm_bin_fil nth_db;
|
||||
private final Fsdb_db_mgr core_mgr; private final int mnt_id; private final Fsm_bin_tbl tbl;
|
||||
private final Ordered_hash db_hash = Ordered_hash_.New();
|
||||
private Fsm_bin_fil nth_db;
|
||||
public Fsm_bin_mgr(Fsdb_db_mgr core_mgr, Db_conn conn, int mnt_id) {
|
||||
this.core_mgr = core_mgr; this.mnt_id = mnt_id;
|
||||
this.tbl = new Fsm_bin_tbl(conn, core_mgr.File__schema_is_1(), mnt_id);
|
||||
}
|
||||
public void Ctor_by_load() {
|
||||
this.dbs__ary = tbl.Select_all(core_mgr);
|
||||
this.dbs__ary_len = dbs__ary.length;
|
||||
if (dbs__ary_len > 0) this.nth_db = dbs__ary[dbs__ary_len - 1];
|
||||
Fsm_bin_fil[] db_ary = tbl.Select_all(core_mgr);
|
||||
int len = db_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Fsm_bin_fil db_fil = db_ary[i];
|
||||
db_hash.Add(db_fil.Id(), db_fil);
|
||||
}
|
||||
if (len > 0) this.nth_db = db_ary[len - 1];
|
||||
}
|
||||
public int Dbs__len() {return dbs__ary_len;}
|
||||
public Fsm_bin_fil Dbs__get_nth() {return nth_db;}
|
||||
public Fsm_bin_fil Dbs__get_at(int i) {return dbs__ary[i];}
|
||||
public Fsm_bin_fil Dbs__make(String file_name) {
|
||||
public int Dbs__len() {return db_hash.Len();}
|
||||
public Fsm_bin_fil Dbs__get_nth() {return nth_db;}
|
||||
public Fsm_bin_fil Dbs__get_at(int i) {return (Fsm_bin_fil)db_hash.Get_at(i);}
|
||||
public Fsm_bin_fil Dbs__get_by_or_null(int i) {return (Fsm_bin_fil)db_hash.Get_by(i);}
|
||||
public Fsm_bin_fil Dbs__make(String file_name) {return Dbs__make(db_hash.Len(), file_name);}
|
||||
public Fsm_bin_fil Dbs__make(int id, String file_name) {
|
||||
Fsdb_db_file db = core_mgr.File__bin_file__new(mnt_id, file_name);
|
||||
Fsm_bin_fil rv = new Fsm_bin_fil(core_mgr.File__schema_is_1(), dbs__ary_len, db.Url(), db.Url().NameAndExt(), db.Conn(), Fsm_bin_fil.Bin_len_null);
|
||||
tbl.Insert(rv.Id(), rv.Url_rel());
|
||||
Dbs__add(rv);
|
||||
Fsm_bin_fil rv = new Fsm_bin_fil(core_mgr.File__schema_is_1(), id, db.Url(), db.Url().NameAndExt(), db.Conn(), Fsm_bin_fil.Bin_len_null);
|
||||
tbl.Insert(id, rv.Url_rel());
|
||||
db_hash.Add(id, rv);
|
||||
this.nth_db = rv;
|
||||
return rv;
|
||||
}
|
||||
public void Insert(int db_id, int bin_id, byte owner_tid, long bin_len, Io_stream_rdr bin_rdr) {
|
||||
Fsm_bin_fil fil = dbs__ary[db_id];
|
||||
Fsm_bin_fil fil = (Fsm_bin_fil)db_hash.Get_by(db_id);
|
||||
fil.Insert(bin_id, owner_tid, bin_len, bin_rdr);
|
||||
fil.Insert(bin_id, owner_tid, bin_len, bin_rdr);
|
||||
dbs__ary[db_id].Insert(bin_id, owner_tid, bin_len, bin_rdr);
|
||||
}
|
||||
public void Txn_bgn() {
|
||||
for (int i = 0; i < dbs__ary_len; ++i)
|
||||
dbs__ary[i].Conn().Txn_bgn("fsdb__meta__bin");
|
||||
int len = db_hash.Len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
this.Dbs__get_at(i).Conn().Txn_bgn("fsdb__meta__bin");
|
||||
}
|
||||
public void Txn_end() {
|
||||
for (int i = 0; i < dbs__ary_len; ++i)
|
||||
dbs__ary[i].Conn().Txn_end();
|
||||
}
|
||||
private void Dbs__add(Fsm_bin_fil fil) {
|
||||
this.dbs__ary = (Fsm_bin_fil[])Array_.Resize(dbs__ary, dbs__ary_len + 1);
|
||||
this.dbs__ary[dbs__ary_len++] = fil;
|
||||
this.nth_db = fil;
|
||||
int len = db_hash.Len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
this.Dbs__get_at(i).Conn().Txn_end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
public class Fsm_bin_tbl {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_uid, fld_url, fld_bin_len, fld_bin_max;
|
||||
private final Db_conn conn; private int mnt_id;
|
||||
public Fsm_bin_tbl(Db_conn conn, boolean schema_is_1, int mnt_id) {
|
||||
@@ -42,7 +42,7 @@ public class Fsm_bin_tbl {
|
||||
conn.Stmt_insert(tbl_name, flds).Crt_int(fld_uid, id).Val_str(fld_url, url_rel).Val_long(fld_bin_len, 0).Val_long(fld_bin_max, 0).Exec_insert();
|
||||
}
|
||||
public Fsm_bin_fil[] Select_all(Fsdb_db_mgr db_conn_mgr) {
|
||||
List_adp rv = List_adp_.new_();
|
||||
List_adp rv = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select_order(tbl_name, flds, Dbmeta_fld_itm.Str_ary_empty, fld_uid).Clear().Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.fsdb.meta.*;
|
||||
public class Fsm_cfg_mgr {
|
||||
private final Db_cfg_tbl tbl; private final Hash_adp grp_hash = Hash_adp_.new_();
|
||||
private final Db_cfg_tbl tbl; private final Hash_adp grp_hash = Hash_adp_.New();
|
||||
public Fsm_cfg_mgr(Fsdb_db_mgr db_conn_mgr, Db_conn conn) {
|
||||
this.tbl = new Db_cfg_tbl(conn, db_conn_mgr.File__cfg_tbl_name());
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ 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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.fsdb.data.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*; import gplx.dbs.*; import gplx.fsdb.data.*;
|
||||
public class Fsm_mnt_itm {
|
||||
public Fsm_mnt_itm(int id, String name, String url_rel) {this.id = id; this.name = name; this.url_rel = url_rel;}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Name() {return name;} private final String name;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Name() {return name;} private final String name;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public Fsm_atr_mgr Atr_mgr() {return atr_mgr;} private Fsm_atr_mgr atr_mgr;
|
||||
public Fsm_bin_mgr Bin_mgr() {return bin_mgr;} private Fsm_bin_mgr bin_mgr;
|
||||
public Fsm_cfg_mgr Cfg_mgr() {return cfg_mgr;} private Fsm_cfg_mgr cfg_mgr;
|
||||
@@ -47,7 +47,7 @@ public class Fsm_mnt_itm {
|
||||
int fil_id = atr_fil.Insert_img(rv, dir, fil, ext_id, img_w, img_h, bin_fil.Id(), bin_len, bin_rdr);
|
||||
bin_fil.Insert(fil_id, Fsd_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
|
||||
}
|
||||
public void Insert_fil(Fsd_fil_itm rv, Fsm_atr_fil atr_fil, Fsm_bin_fil bin_fil, byte[] dir, byte[] fil, int ext_id, long bin_len, gplx.core.ios.Io_stream_rdr bin_rdr) {
|
||||
public void Insert_fil(Fsd_fil_itm rv, Fsm_atr_fil atr_fil, Fsm_bin_fil bin_fil, byte[] dir, byte[] fil, int ext_id, long bin_len, gplx.core.ios.streams.Io_stream_rdr bin_rdr) {
|
||||
int fil_id = atr_fil.Insert_fil(rv, dir, fil, ext_id, bin_fil.Id(), bin_len, bin_rdr);
|
||||
bin_fil.Insert(fil_id, Fsd_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
|
||||
public class Fsm_mnt_mgr implements GfoInvkAble {
|
||||
public class Fsm_mnt_mgr implements Gfo_invk {
|
||||
private Db_cfg_tbl cfg_tbl; private Fsm_mnt_tbl mnt_tbl;
|
||||
private Fsm_mnt_itm[] mnt_ary; private int mnt_ary_len = 0;
|
||||
public void Ctor_by_load(Fsdb_db_mgr db_core) {
|
||||
@@ -39,9 +39,9 @@ public class Fsm_mnt_mgr implements GfoInvkAble {
|
||||
public Fsm_mnt_itm Mnts__get_at(int i) {return mnt_ary[i];}
|
||||
public Fsm_mnt_itm Mnts__get_main() {return mnt_ary[Mnt_idx_main];}
|
||||
public Fsm_mnt_itm Mnts__get_insert() {return mnt_ary[insert_idx];} public void Mnts__get_insert_idx_(int v) {insert_idx = v;} private int insert_idx = Mnt_idx_user;
|
||||
public Fsm_bin_fil Bins__at(int mnt_id, int bin_db_id) {return mnt_ary[mnt_id].Bin_mgr().Dbs__get_at(bin_db_id);}
|
||||
public Fsm_bin_fil Bins__at(int mnt_id, int bin_db_id) {return mnt_ary[mnt_id].Bin_mgr().Dbs__get_by_or_null(bin_db_id);}
|
||||
public int Patch_upright() {return patch_upright_tid;} private int patch_upright_tid = Xof_patch_upright_tid_.Tid_all;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return GfoInvkAble_.Rv_unhandled;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return Gfo_invk_.Rv_unhandled;}
|
||||
public static final int Mnt_idx_main = 0, Mnt_idx_user = 1, Insert_to_bin_null = -1;
|
||||
public static void Patch(Db_cfg_tbl cfg_tbl) {
|
||||
cfg_tbl.Upsert_str(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_fix_defaults , "y");
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*;
|
||||
public class Fsm_mnt_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_mnt"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_name, fld_url;
|
||||
private final Db_conn conn;
|
||||
private final String tbl_name = "fsdb_mnt"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_id, fld_name, fld_url;
|
||||
private final Db_conn conn;
|
||||
public Fsm_mnt_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
fld_id = flds.Add_int_pkey ("mnt_id");
|
||||
@@ -44,7 +44,7 @@ public class Fsm_mnt_tbl implements Rls_able {
|
||||
stmt.Clear().Val_str(fld_name, name).Val_str(fld_url, url).Crt_int(fld_id, id).Exec_update();
|
||||
}
|
||||
public Fsm_mnt_itm[] Select_all() {
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, Dbmeta_fld_itm.Str_ary_empty).Clear().Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
|
||||
Reference in New Issue
Block a user