1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2016-02-07 23:20:20 -05:00
parent 6d179ca59d
commit de67253a9c
215 changed files with 3387 additions and 2055 deletions

View File

@@ -0,0 +1,46 @@
/*
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.dbs.diffs; import gplx.*; import gplx.dbs.*;
import gplx.dbs.diffs.itms.*;
import gplx.dbs.diffs.builds.*;
public class Gdif_core {
private final Db_conn conn;
private final Gdif_job_tbl job_tbl;
private final Gdif_cmd_tbl cmd_tbl;
private final Gdif_txn_tbl txn_tbl;
public Gdif_core(Db_conn conn) {
this.conn = conn;
this.db = new Gdif_db(conn);
this.job_tbl = db.Job_tbl();
this.cmd_tbl = db.Cmd_tbl();
this.txn_tbl = db.Txn_tbl();
}
public Gdif_db Db() {return db;} private final Gdif_db db;
public Gdif_job_itm New_job(String name, String made_by) {
int job_id = conn.Sys_mgr().Autonum_next(job_tbl.Tbl_name(), job_tbl.Fld_job_id());
return job_tbl.Insert(job_id, name, made_by, DateAdp_.Now().XtoUtc(), "");
}
public Gdif_cmd_itm New_cmd(Gdif_bldr_ctx ctx, int tid) {
ctx.Cur_cmd_count++;
return cmd_tbl.Insert(ctx.Cur_job.Id, ctx.Cur_cmd_count, tid, "");
}
public Gdif_txn_itm New_txn(Gdif_bldr_ctx ctx, int cmd_id, int owner_txn) {
ctx.Cur_txn_count++;
return txn_tbl.Insert(ctx.Cur_job.Id, ctx.Cur_txn_count, cmd_id, owner_txn);
}
}

View File

@@ -0,0 +1,31 @@
/*
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.dbs.diffs; import gplx.*; import gplx.dbs.*;
import gplx.dbs.diffs.itms.*;
public class Gdif_db {
public Gdif_db(Db_conn conn) {
this.conn = conn;
this.job_tbl = new Gdif_job_tbl(conn);
this.cmd_tbl = new Gdif_cmd_tbl(conn);
this.txn_tbl = new Gdif_txn_tbl(conn);
}
public Db_conn Conn() {return conn;} private final Db_conn conn;
public Gdif_job_tbl Job_tbl() {return job_tbl;} private final Gdif_job_tbl job_tbl;
public Gdif_cmd_tbl Cmd_tbl() {return cmd_tbl;} private final Gdif_cmd_tbl cmd_tbl;
public Gdif_txn_tbl Txn_tbl() {return txn_tbl;} private final Gdif_txn_tbl txn_tbl;
}

View File

@@ -16,13 +16,13 @@ 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.dbs.diffs; import gplx.*; import gplx.dbs.*;
public class Gfdb_diff_db_ {
public class Gdif_db_ {
public static final String
Fld__dif_txn = "dif_txn" // 0+ where 0+ is defined in a tbl
, Fld__dif_uid = "dif_uid" // 0+
, Fld__dif_type = "dif_type" // I,U,D,M
, Fld__dif_db_trg = "dif_db_trg" // -1 for single-db tables; 0+ for multiple-db tables
, Fld__dif_db_src = "dff_db_src" // -1 for I,U,D; 0+ for M
, Fld__dif_db_src = "dif_db_src" // -1 for I,U,D; 0+ for M
;
public static final byte
Tid__insert = 0

View File

@@ -23,11 +23,11 @@ class Gfdb_diff_cmd {
public Gfdb_diff_cmd() {
diff_bldr.Init(diff_bldr_wkr);
}
public Gfdb_diff_job New_job(Gfdb_diff_db db, String guid, String name, String made_by, String desc) {
public Gfdb_diff_job New_job(Gdif_db db, String guid, String name, String made_by, String desc) {
return new Gfdb_diff_job(db);
}
public void Bld(Gfdb_diff_job job, Gfdb_diff_tbl_mgr lhs_mgr, Gfdb_diff_tbl_mgr rhs_mgr) {
diff_bldr_wkr.Init_conn(job.Db(), 1000);
diff_bldr_wkr.Init_conn(job.Db(), 1000);
int rhs_len = rhs_mgr.Len();
for (int i = 0; i < rhs_len; ++i) {
Gfdb_diff_tbl rhs_tbl = rhs_mgr.Get_at(i);
@@ -53,6 +53,6 @@ class Gfdb_diff_cmd {
}
}
class Gfdb_diff_job {
public Gfdb_diff_job(Gfdb_diff_db db) {this.db = db;}
public Gfdb_diff_db Db() {return db;} private Gfdb_diff_db db;
public Gfdb_diff_job(Gdif_db db) {this.db = db;}
public Gdif_db Db() {return db;} private Gdif_db db;
}

View File

@@ -0,0 +1,38 @@
/*
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.dbs.diffs.builds; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
import gplx.dbs.diffs.itms.*;
public class Gdif_bldr_ctx {
public Gdif_bldr_ctx() {}
public Gdif_core Core;
public Gdif_job_itm Cur_job;
public Gdif_cmd_itm Cur_cmd;
public Gdif_txn_itm Cur_txn;
public int Cur_cmd_count;
public int Cur_txn_count;
public Gdif_bldr_ctx Init(Gdif_core core, Gdif_job_itm cur_job) {
this.Core = core; this.Cur_job = cur_job;
return this;
}
public void Clear() {
Cur_cmd_count = 0; Cur_txn_count = 0;
Cur_job = null;
Cur_cmd = null;
Cur_txn = null;
}
}

View File

@@ -21,10 +21,10 @@ public class Gfdb_diff_bldr {
private Gfdb_diff_rdr_comparer rdr_comparer = new Gfdb_diff_rdr_comparer();
private Gfdb_diff_wkr diff_wkr;
public void Init(Gfdb_diff_wkr diff_wkr) {this.diff_wkr = diff_wkr;}
public void Compare(int txn, Gfdb_diff_tbl tbl, Db_conn old_conn, Db_conn new_conn) {
public void Compare(Gdif_bldr_ctx ctx, Gfdb_diff_tbl tbl, Db_conn old_conn, Db_conn new_conn) {
Db_rdr old_rdr = tbl.Make_rdr(old_conn), new_rdr = tbl.Make_rdr(new_conn);
rdr_comparer.Init_rdrs(tbl, old_rdr, new_rdr);
diff_wkr.Init_rdrs(txn, tbl, old_rdr, new_rdr);
diff_wkr.Init_rdrs(ctx, tbl, old_rdr, new_rdr);
boolean loop = true;
while (loop) {
int rslt = rdr_comparer.Compare();

View File

@@ -62,6 +62,7 @@ class Gfdb_diff_bldr_fxt {
private final Gfdb_diff_wkr__test wkr = new Gfdb_diff_wkr__test();
private final Dbmeta_fld_itm[] flds_ary;
private final String tbl_name = "tbl";
private final Gdif_bldr_ctx ctx = new Gdif_bldr_ctx();
public Gfdb_diff_bldr_fxt() {
old_conn = Db_conn_utl.Conn__new("old_db");
new_conn = Db_conn_utl.Conn__new("new_db");
@@ -70,13 +71,14 @@ class Gfdb_diff_bldr_fxt {
bldr.Init(wkr);
}
public void Clear() {
ctx.Clear();
Db_conn_utl.Tbl__delete(old_conn, "tbl");
Db_conn_utl.Tbl__delete(new_conn, "tbl");
}
public void Init__tbl__old(Object[]... rows) {Db_conn_utl.Tbl__new(old_conn, "tbl", flds_ary, rows);}
public void Init__tbl__cur(Object[]... rows) {Db_conn_utl.Tbl__new(new_conn, "tbl", flds_ary, rows);}
public void Test__bld(String... expd) {
bldr.Compare(-1, tbl, old_conn, new_conn);
bldr.Compare(ctx, tbl, old_conn, new_conn);
Tfds.Eq_ary_str(expd, wkr.To_str_ary());
}
}
@@ -84,7 +86,7 @@ class Gfdb_diff_wkr__test implements Gfdb_diff_wkr {
private final List_adp list = List_adp_.new_();
private final Bry_bfr bfr = Bry_bfr.new_();
private Db_rdr old_rdr, new_rdr;
public void Init_rdrs(int txn, Gfdb_diff_tbl tbl, Db_rdr old_rdr, Db_rdr new_rdr) {
public void Init_rdrs(Gdif_bldr_ctx ctx, Gfdb_diff_tbl tbl, Db_rdr old_rdr, Db_rdr new_rdr) {
this.old_rdr = old_rdr; this.new_rdr = new_rdr;
}
public void Term_tbls() {}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.diffs.builds; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
public interface Gfdb_diff_wkr {
void Init_rdrs(int txn, Gfdb_diff_tbl tbl, Db_rdr old_rdr, Db_rdr new_rdr);
void Init_rdrs(Gdif_bldr_ctx ctx, Gfdb_diff_tbl tbl, Db_rdr old_rdr, Db_rdr new_rdr);
void Term_tbls();
void Handle_same();
void Handle_old_missing();

View File

@@ -16,37 +16,47 @@ 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.dbs.diffs.builds; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
import gplx.dbs.metas.*;
import gplx.dbs.metas.*; import gplx.dbs.diffs.itms.*;
public class Gfdb_diff_wkr__db implements Gfdb_diff_wkr {
private Dbmeta_fld_itm[] val_flds; private int val_flds_len;
private Gfdb_diff_tbl tbl; private Db_rdr old_rdr, new_rdr;
private Db_conn dif_conn; private Db_stmt stmt;
private int txn, uid, prog_interval, prog_count;
public void Init_conn(Gfdb_diff_db diff_db, int prog_interval) {this.dif_conn = diff_db.Conn(); this.prog_interval = prog_interval;}
public void Init_rdrs(int txn, Gfdb_diff_tbl tbl, Db_rdr old_rdr, Db_rdr new_rdr) {
this.tbl = tbl; this.old_rdr = old_rdr; this.new_rdr = new_rdr;
private Gdif_bldr_ctx ctx;
private Db_conn dif_conn; private Db_stmt stmt;
private int uid, prog_interval, prog_count;
private boolean cmd_create;
public void Init_conn(Gdif_db dif_db, int prog_interval) {this.dif_conn = dif_db.Conn(); this.prog_interval = prog_interval;}
public void Init_rdrs(Gdif_bldr_ctx ctx, Gfdb_diff_tbl tbl, Db_rdr old_rdr, Db_rdr new_rdr) {
this.ctx = ctx; this.tbl = tbl; this.old_rdr = old_rdr; this.new_rdr = new_rdr;
this.val_flds = tbl.Vals; val_flds_len = val_flds.length;
this.txn = txn; this.uid = -1; this.prog_count = 0;
this.uid = 0; this.prog_count = 0;
String dif_tbl = tbl.Name; Dbmeta_fld_itm[] dif_flds = Gfdb_diff_wkr__db_.New_dif_flds(tbl.Flds);
if (!dif_conn.Meta_tbl_exists(dif_tbl)) dif_conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(dif_tbl, dif_flds));
this.stmt = dif_conn.Stmt_insert(dif_tbl, Gfdb_diff_wkr__db_.To_str_ary(dif_flds));
dif_conn.Txn_bgn("dif_db_tbl_" + dif_tbl);
cmd_create = true;
}
public void Term_tbls() {dif_conn.Txn_end();}
public void Handle_old_missing() {Insert(Gfdb_diff_db_.Tid__insert, ++uid, new_rdr, tbl.Flds);}
public void Handle_new_missing() {Insert(Gfdb_diff_db_.Tid__delete, ++uid, old_rdr, tbl.Flds);}
public void Term_tbls() {
dif_conn.Txn_end();
}
public void Handle_old_missing() {Insert(Gdif_db_.Tid__insert, ++uid, new_rdr, tbl.Flds);}
public void Handle_new_missing() {Insert(Gdif_db_.Tid__delete, ++uid, old_rdr, tbl.Flds);}
public void Handle_same() {
if (Gfdb_rdr_utl_.Compare(val_flds, val_flds_len, old_rdr, new_rdr) != CompareAble_.Same)
Insert(Gfdb_diff_db_.Tid__update, ++uid, new_rdr, tbl.Flds);
Insert(Gdif_db_.Tid__update, ++uid, new_rdr, tbl.Flds);
}
private void Insert(byte dif_type, int uid, Db_rdr rdr, Dbmeta_fld_itm[] flds) {
if (cmd_create) {
cmd_create = false;
ctx.Cur_cmd = ctx.Core.New_cmd(ctx, Gdif_cmd_itm.Tid__data);
ctx.Cur_txn = ctx.Core.New_txn(ctx, ctx.Cur_cmd.Cmd_id, Gdif_txn_itm.Owner_txn__null);
}
stmt.Clear();
stmt.Val_int (Gfdb_diff_db_.Fld__dif_txn , txn)
.Val_int (Gfdb_diff_db_.Fld__dif_uid , uid)
.Val_int (Gfdb_diff_db_.Fld__dif_type , dif_type)
.Val_int (Gfdb_diff_db_.Fld__dif_db_src , -1)
.Val_int (Gfdb_diff_db_.Fld__dif_db_trg , -1);
stmt.Val_int (Gdif_db_.Fld__dif_txn , ctx.Cur_txn.Txn_id)
.Val_int (Gdif_db_.Fld__dif_uid , uid)
.Val_int (Gdif_db_.Fld__dif_type , dif_type)
.Val_int (Gdif_db_.Fld__dif_db_src , -1)
.Val_int (Gdif_db_.Fld__dif_db_trg , -1);
Gfdb_rdr_utl_.Stmt_args(stmt, flds, flds.length, rdr);
stmt.Exec_insert();
if ((++prog_count % prog_interval) == 0) dif_conn.Txn_sav();
@@ -57,11 +67,11 @@ class Gfdb_diff_wkr__db_ {
int len = cur_flds.length;
int sys_flds = 5;
Dbmeta_fld_itm[] rv = new Dbmeta_fld_itm[len + sys_flds];
rv[0] = Dbmeta_fld_itm.new_int (Gfdb_diff_db_.Fld__dif_txn);
rv[1] = Dbmeta_fld_itm.new_int (Gfdb_diff_db_.Fld__dif_uid);
rv[2] = Dbmeta_fld_itm.new_byte (Gfdb_diff_db_.Fld__dif_type);
rv[3] = Dbmeta_fld_itm.new_int (Gfdb_diff_db_.Fld__dif_db_trg);
rv[4] = Dbmeta_fld_itm.new_int (Gfdb_diff_db_.Fld__dif_db_src);
rv[0] = Dbmeta_fld_itm.new_int (Gdif_db_.Fld__dif_txn);
rv[1] = Dbmeta_fld_itm.new_int (Gdif_db_.Fld__dif_uid);
rv[2] = Dbmeta_fld_itm.new_byte (Gdif_db_.Fld__dif_type);
rv[3] = Dbmeta_fld_itm.new_int (Gdif_db_.Fld__dif_db_trg);
rv[4] = Dbmeta_fld_itm.new_int (Gdif_db_.Fld__dif_db_src);
for (int i = 0; i < len; ++i) {
Dbmeta_fld_itm cur_fld = cur_flds[i];
Dbmeta_fld_itm dif_fld = new Dbmeta_fld_itm(cur_fld.Name(), cur_fld.Type());

View File

@@ -15,10 +15,15 @@ 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.dbs.diffs; import gplx.*; import gplx.dbs.*;
public class Gfdb_diff_db {
public Gfdb_diff_db(Db_conn conn) {
this.conn = conn;
package gplx.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
public class Gdif_cmd_itm {
public Gdif_cmd_itm(int grp_id, int cmd_id, int tid) {
this.Grp_id = grp_id; this.Cmd_id = cmd_id; this.Tid = tid;
}
public Db_conn Conn() {return conn;} private final Db_conn conn;
public final int Grp_id;
public final int Cmd_id;
public final int Tid;
public String Data;
public static final int Tid__data = 1;
}

View File

@@ -0,0 +1,43 @@
/*
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.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
public class Gdif_cmd_tbl implements Rls_able {
private String tbl_name = "gdif_cmd";
private String fld_grp_id, fld_cmd_id, fld_tid, fld_data;
private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
private final Db_conn conn; private Db_stmt stmt_insert;
public Gdif_cmd_tbl(Db_conn conn) {
this.conn = conn;
fld_grp_id = flds.Add_int("grp_id"); fld_cmd_id = flds.Add_int("cmd_id"); fld_tid = flds.Add_int("tid"); fld_data = flds.Add_text("data");
conn.Rls_reg(this);
}
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_grp_id, fld_cmd_id)));}
public Gdif_cmd_itm Insert(int grp_id, int cmd_id, int tid, String data) {
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
stmt_insert.Clear()
.Val_int(fld_grp_id , grp_id)
.Val_int(fld_cmd_id , cmd_id)
.Val_int(fld_tid , tid)
.Val_str(fld_data , data)
.Exec_insert();
return new Gdif_cmd_itm(grp_id, cmd_id, tid);
}
public void Rls() {
stmt_insert = Db_stmt_.Rls(stmt_insert);
}
}

View File

@@ -0,0 +1,28 @@
/*
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.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
public class Gdif_job_itm {
public Gdif_job_itm(int id, String name, String made_by, DateAdp made_on) {
this.Id = id; this.Name = name; this.Made_by = made_by; this.Made_on = made_on;
}
public final int Id;
public final String Name;
public final String Made_by;
public final DateAdp Made_on;
public String Data;
}

View File

@@ -0,0 +1,46 @@
/*
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.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
public class Gdif_job_tbl implements Rls_able {
private String tbl_name = "gdif_job";
private String fld_job_id, fld_name, fld_made_by, fld_made_on, fld_data;
private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
private final Db_conn conn; private Db_stmt stmt_insert;
public Gdif_job_tbl(Db_conn conn) {
this.conn = conn;
fld_job_id = flds.Add_int_pkey("job_id"); fld_name = flds.Add_str("name", 255); fld_made_by = flds.Add_str("made_by", 255); fld_made_on = flds.Add_date("made_on"); fld_data = flds.Add_text("data");
conn.Rls_reg(this);
}
public String Tbl_name() {return tbl_name;}
public String Fld_job_id() {return fld_job_id;}
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
public Gdif_job_itm Insert(int id, String name, String made_by, DateAdp made_on, String data) {
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
stmt_insert.Clear()
.Val_int(fld_job_id , id)
.Val_str(fld_name , name)
.Val_str(fld_made_by , made_by)
.Val_date(fld_made_on , made_on)
.Val_str(fld_data , data)
.Exec_insert();
return new Gdif_job_itm(id, name, made_by, made_on);
}
public void Rls() {
stmt_insert = Db_stmt_.Rls(stmt_insert);
}
}

View File

@@ -0,0 +1,29 @@
/*
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.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
public class Gdif_txn_itm {
public Gdif_txn_itm(int job_id, int txn_id, int cmd_id, int owner_txn) {
this.Job_id = job_id; this.Txn_id = txn_id; this.Cmd_id = cmd_id; this.Owner_txn = owner_txn;
}
public final int Job_id;
public final int Txn_id;
public final int Cmd_id;
public final int Owner_txn;
public static final int Owner_txn__null = 0;
}

View File

@@ -15,42 +15,27 @@ 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.dbs.diffs.tbls; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
import gplx.dbs.*;
/*
reg:
id,name,made_by,made_on,meta
0,'Diffs for Simple Wikipedia betwee 2015-11-16 and 2015-12-23',gnosygnu,2015-12-23'dif;simplewiki;20151223;20151116'
cmd:
owner,id,tid,meta
0,0,data_comp_tid,page
0,1,data_comp_tid,cat_core
0,2,data_comp_tid,cat_link
txn:
reg_id,txn_id,cmd_id,owner_txn
0,0,0,-1,page
0,1,-1,-1,cat
0,2,-1,1,mid
0,3,1,2,cat_core
0,4,2,2,cat_link
*/
class Gdif_txn_tbl implements Rls_able {
package gplx.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
public class Gdif_txn_tbl implements Rls_able {
private String tbl_name = "gdif_txn";
private String fld_owner, fld_id;
private String fld_job_id, fld_txn_id, fld_cmd_id, fld_owner_txn;
private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
private final Db_conn conn; private Db_stmt stmt_insert;
public Gdif_txn_tbl(Db_conn conn) {
this.conn = conn;
fld_owner = flds.Add_int("txn_owner"); fld_id = flds.Add_int("txn_id");
fld_job_id = flds.Add_int("job_id"); fld_txn_id = flds.Add_int("txn_id"); fld_cmd_id = flds.Add_int("cmd_id"); fld_owner_txn = flds.Add_int("owner_txn");
conn.Rls_reg(this);
}
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds.To_fld_ary(), Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_owner, fld_id)));}
public void Insert(int txn_owner, int txn_id) {
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_job_id, fld_txn_id)));}
public Gdif_txn_itm Insert(int job_id, int txn_id, int cmd_id, int owner_txn) {
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
stmt_insert.Clear()
.Val_int(fld_owner , txn_owner)
.Val_int(fld_id , txn_id)
.Val_int(fld_job_id , job_id)
.Val_int(fld_txn_id , txn_id)
.Val_int(fld_cmd_id , cmd_id)
.Val_int(fld_owner_txn , owner_txn)
.Exec_insert();
return new Gdif_txn_itm(job_id, txn_id, cmd_id, owner_txn);
}
public void Rls() {
stmt_insert = Db_stmt_.Rls(stmt_insert);