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:
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_fld_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Len() {return hash.Count();}
|
||||
public void Clear() {hash.Clear();}
|
||||
public void Add(Dbmeta_fld_itm itm) {hash.Add(itm.Name(), itm);}
|
||||
@@ -26,7 +26,7 @@ public class Dbmeta_fld_mgr {
|
||||
public Dbmeta_fld_itm Get_by(String name) {return (Dbmeta_fld_itm)hash.Get_by(name);}
|
||||
public Dbmeta_fld_itm[] To_ary() {return hash.Count() == 0 ? Dbmeta_fld_itm.Ary_empty : (Dbmeta_fld_itm[])hash.To_ary(Dbmeta_fld_itm.class);}
|
||||
public Dbmeta_fld_list To_fld_list() {
|
||||
Dbmeta_fld_list rv = Dbmeta_fld_list.new_();
|
||||
Dbmeta_fld_list rv = new Dbmeta_fld_list();
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i)
|
||||
rv.Add(Get_at(i));
|
||||
|
||||
@@ -17,17 +17,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_idx_fld {
|
||||
public Dbmeta_idx_fld(int order, String name, int sort_tid) {this.Name = name; this.Order = order; this.Sort_tid = sort_tid;}
|
||||
public int Order;
|
||||
public Dbmeta_idx_fld(String name, int sort_tid) {this.Name = name; this.Sort_tid = sort_tid;}
|
||||
public String Name;
|
||||
public int Sort_tid;
|
||||
public boolean Eq(Dbmeta_idx_fld comp) {
|
||||
return String_.Eq(Name, comp.Name)
|
||||
&& Order == comp.Order
|
||||
&& Sort_tid == comp.Sort_tid;
|
||||
}
|
||||
|
||||
public static final Dbmeta_idx_fld[] Ary_empty = new Dbmeta_idx_fld[0];
|
||||
public static final Dbmeta_idx_fld[] Ary_empty = new Dbmeta_idx_fld[0];
|
||||
public static final int Sort_tid__none = 0, Sort_tid__asc = 1, Sort_tid__desc = 2;
|
||||
public static boolean Ary_eq(Dbmeta_idx_fld[] lhs_ary, Dbmeta_idx_fld[] rhs_ary) {
|
||||
int lhs_len = lhs_ary.length, rhs_len = rhs_ary.length;
|
||||
@@ -36,4 +34,6 @@ public class Dbmeta_idx_fld {
|
||||
if (!lhs_ary[i].Eq(rhs_ary[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Dbmeta_idx_fld Dsc(String name) {return new Dbmeta_idx_fld(name, Sort_tid__desc);}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*;
|
||||
public class Dbmeta_parser__idx {
|
||||
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
|
||||
private final List_adp tmp_list = List_adp_.new_();
|
||||
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
|
||||
private final List_adp tmp_list = List_adp_.New();
|
||||
public Dbmeta_idx_itm Parse(byte[] src) {
|
||||
rdr.Init_by_page(Bry_.Empty, src, src.length);
|
||||
rdr.Skip_ws().Chk_trie_val(trie, Tid__create);
|
||||
@@ -34,11 +34,10 @@ public class Dbmeta_parser__idx {
|
||||
rdr.Skip_ws().Chk_trie_val(trie, Tid__on);
|
||||
byte[] tbl_name = rdr.Read_sql_identifier();
|
||||
rdr.Skip_ws().Chk(Byte_ascii.Paren_bgn);
|
||||
int order = -1;
|
||||
while (true) {
|
||||
byte[] fld_bry = rdr.Read_sql_identifier(); if (fld_bry == null) throw Err_.new_("db", "index parse failed; index field is not an identifier", "src", src);
|
||||
// TODO: check for ASC / DESC
|
||||
Dbmeta_idx_fld fld_itm = new Dbmeta_idx_fld(++order, String_.new_u8(fld_bry), Dbmeta_idx_fld.Sort_tid__none);
|
||||
// TODO_OLD: check for ASC / DESC
|
||||
Dbmeta_idx_fld fld_itm = new Dbmeta_idx_fld(String_.new_u8(fld_bry), Dbmeta_idx_fld.Sort_tid__none);
|
||||
tmp_list.Add(fld_itm);
|
||||
byte sym = rdr.Skip_ws().Read_byte();
|
||||
if (sym == Byte_ascii.Paren_end) break;
|
||||
@@ -46,12 +45,12 @@ public class Dbmeta_parser__idx {
|
||||
return new Dbmeta_idx_itm(unique, String_.new_u8(tbl_name), String_.new_u8(idx_name), (Dbmeta_idx_fld[])tmp_list.To_ary_and_clear(Dbmeta_idx_fld.class));
|
||||
}
|
||||
private static final byte Tid__create = 0, Tid__unique = 1, Tid__index = 2, Tid__on = 3;
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Bry__create = Bry_.new_a7("create")
|
||||
, Bry__unique = Bry_.new_a7("unique")
|
||||
, Bry__index = Bry_.new_a7("index")
|
||||
, Bry__on = Bry_.new_a7("on");
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
|
||||
.Add_bry_byte(Bry__create , Tid__create)
|
||||
.Add_bry_byte(Bry__unique , Tid__unique)
|
||||
.Add_bry_byte(Bry__index , Tid__index)
|
||||
|
||||
Reference in New Issue
Block a user