use of io.github.ihongs.dh.search.StatisHandle.TYPE in project HongsCORE by ihongs.
the class StatisHelper method getGraderFields.
private Field[] getGraderFields(Set<String> names, Map rd) {
if (names == null) {
return null;
}
List<Field> fields = new ArrayList(names.size());
Map<String, Map> items = that.getFields();
Map<String, String> types;
try {
types = FormSet.getInstance().getEnum("__types__");
} catch (HongsException e) {
throw e.toExemption();
}
for (String n : names) {
TYPE g;
String f = n;
Map c = items.get(f);
if (c == null) {
continue;
}
String t = (String) c.get("__type__");
Object k = (Object) c.get("type");
// 使用基准类型
if (types.containsKey(t)) {
t = types.get(t);
}
if (Synt.declare(c.get("__repeated__"), false) == false) {
f = "#" + f;
if (null != t)
switch(t) {
case "number":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INT;
} else if ("long".equals(k)) {
g = TYPE.LONG;
} else if ("float".equals(k)) {
g = TYPE.FLOAT;
} else {
g = TYPE.DOUBLE;
}
break;
case "hidden":
case "enum":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INT;
} else if ("long".equals(k)) {
g = TYPE.LONG;
} else if ("float".equals(k)) {
g = TYPE.FLOAT;
} else if ("double".equals(k) || "number".equals(k)) {
g = TYPE.DOUBLE;
} else {
g = TYPE.STRING;
}
break;
case "date":
g = TYPE.LONG;
break;
default:
g = TYPE.STRING;
}
else {
g = TYPE.STRING;
}
} else {
f = "%" + f;
if (null != t)
switch(t) {
case "number":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INTS;
} else if ("long".equals(k)) {
g = TYPE.LONGS;
} else if ("float".equals(k)) {
g = TYPE.FLOATS;
} else {
g = TYPE.DOUBLES;
}
break;
case "hidden":
case "enum":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INTS;
} else if ("long".equals(k)) {
g = TYPE.LONGS;
} else if ("float".equals(k)) {
g = TYPE.FLOATS;
} else if ("double".equals(k) || "number".equals(k)) {
g = TYPE.DOUBLES;
} else {
g = TYPE.STRINGS;
}
break;
case "date":
g = TYPE.LONGS;
break;
default:
g = TYPE.STRINGS;
}
else {
g = TYPE.STRINGS;
}
}
fields.add(new Field(g, f, n));
}
return fields.toArray(new Field[fields.size()]);
}
use of io.github.ihongs.dh.search.StatisHandle.TYPE in project HongsCORE by ihongs.
the class StatisHelper method getGatherFields.
private Fields getGatherFields(Set<String> names, Map rd) {
if (names == null) {
return null;
}
List<Diman> dimans = new ArrayList();
List<Index> indics = new ArrayList();
Map<String, Map> items = that.getFields();
Map<String, String> types;
try {
types = FormSet.getInstance().getEnum("__types__");
} catch (HongsException e) {
throw e.toExemption();
}
for (String n : names) {
TYPE g;
String f = n;
String m = null;
// 拆出统计方法
int j = n.indexOf('!');
if (j > -1) {
m = n.substring(1 + j);
f = n.substring(0, j);
// 统计行数
if (m.equals("count") && f.equals("*")) {
f = Cnst.ID_KEY;
}
}
Map c = items.get(f);
if (c == null) {
continue;
}
String t = (String) c.get("__type__");
Object k = (Object) c.get("type");
// 使用基准类型
if (types.containsKey(t)) {
t = types.get(t);
}
if (Synt.declare(c.get("__repeated__"), false) == false) {
f = "#" + f;
if (null != t)
switch(t) {
case "number":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INT;
} else if ("long".equals(k)) {
g = TYPE.LONG;
} else if ("float".equals(k)) {
g = TYPE.FLOAT;
} else {
g = TYPE.DOUBLE;
}
break;
case "hidden":
case "enum":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INT;
} else if ("long".equals(k)) {
g = TYPE.LONG;
} else if ("float".equals(k)) {
g = TYPE.FLOAT;
} else if ("double".equals(k) || "number".equals(k)) {
g = TYPE.DOUBLE;
} else {
g = TYPE.STRING;
}
break;
case "date":
g = TYPE.LONG;
break;
default:
g = TYPE.STRING;
}
else {
g = TYPE.STRING;
}
} else {
f = "%" + f;
if (null != t)
switch(t) {
case "number":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INTS;
} else if ("long".equals(k)) {
g = TYPE.LONGS;
} else if ("float".equals(k)) {
g = TYPE.FLOATS;
} else {
g = TYPE.DOUBLES;
}
break;
case "hidden":
case "enum":
if ("int".equals(k) || "byte".equals(k) || "short".equals(k)) {
g = TYPE.INTS;
} else if ("long".equals(k)) {
g = TYPE.LONGS;
} else if ("float".equals(k)) {
g = TYPE.FLOATS;
} else if ("double".equals(k) || "number".equals(k)) {
g = TYPE.DOUBLES;
} else {
g = TYPE.STRINGS;
}
break;
case "date":
g = TYPE.LONGS;
break;
default:
g = TYPE.STRINGS;
}
else {
g = TYPE.STRINGS;
}
}
Object o = getGatherField(g, f, n, m, rd);
if (o instanceof Index) {
indics.add((Index) o);
} else {
dimans.add((Diman) o);
}
}
return new Fields(dimans.toArray(new Diman[dimans.size()]), indics.toArray(new Index[indics.size()]));
}
Aggregations