use of catdata.fql.sql.ED in project fql by CategoricalData.
the class Chase method chaseEgd.
private static List<Pair<Object, Object>> chaseEgd(Map<String, Set<Pair<Object, Object>>> i, List<String> forall, List<Triple<String, String, String>> where, List<Pair<String, String>> t) {
List<Pair<Object, Object>> ret = new LinkedList<>();
EmbeddedDependency xxx0 = conv(forall, where, t);
ED xxx = ED.from(xxx0);
Flower front = xxx.front();
Flower back = xxx.back();
Set<Map<Object, Object>> frontX = front.eval(ED.conv(i));
Set<Map<Object, Object>> backX = back.eval(ED.conv(i));
if (frontX.equals(backX)) {
return ret;
}
for (Pair<String, String> eq : t) {
int a = getColNo(xxx0.forall, xxx0.where, eq.first);
int b = getColNo(xxx0.forall, xxx0.where, eq.second);
for (Map<Object, Object> row : frontX) {
if (row.get("c" + a).toString().startsWith("_")) {
ret.add(new Pair<>(row.get("c" + a), row.get("c" + b)));
} else {
ret.add(new Pair<>(row.get("c" + b), row.get("c" + a)));
}
}
}
return ret;
}
use of catdata.fql.sql.ED in project fql by CategoricalData.
the class Chase method chaseTgd.
private static Map<String, Set<Pair<Object, Object>>> chaseTgd(Map<String, Set<Pair<Object, Object>>> i, List<String> forall, List<Triple<String, String, String>> where, List<Triple<String, String, String>> t) {
Map<String, Set<Pair<Object, Object>>> ret = new HashMap<>();
for (String k : i.keySet()) {
ret.put(k, new HashSet<>());
}
EmbeddedDependency xxx0 = conv2(forall, where, t);
ED xxx = ED.from(xxx0);
Flower front = xxx.front();
Flower back = xxx.back();
Set<Map<Object, Object>> frontX = front.eval(ED.conv(i));
Set<Map<Object, Object>> backX = back.eval(ED.conv(i));
if (frontX.equals(backX)) {
return ret;
}
for (Map<Object, Object> eq : frontX) {
Map<String, String> map = new HashMap<>();
for (String v : xxx0.exists) {
String v0 = "_" + (fresh++);
map.put(v, v0);
}
for (Triple<String, String, String> fact : xxx0.tgd) {
Object a;
try {
a = eq.get("c" + getColNo(xxx0.forall, xxx0.where, fact.second));
} catch (Exception ee) {
a = map.get(fact.second);
}
Object b;
try {
b = eq.get("c" + getColNo(xxx0.forall, xxx0.where, fact.third));
} catch (Exception ee) {
b = map.get(fact.third);
}
ret.get(fact.first).add(new Pair<>(a, b));
}
}
return ret;
}
use of catdata.fql.sql.ED in project fql by CategoricalData.
the class Chase method obeys.
private static boolean obeys(Map<String, Set<Pair<Object, Object>>> i0, List<Triple<List<String>, List<Triple<String, String, String>>, List<Triple<String, String, String>>>> tgds, List<Triple<List<String>, List<Triple<String, String, String>>, List<Pair<String, String>>>> egds) {
for (Triple<List<String>, List<Triple<String, String, String>>, List<Pair<String, String>>> egd : egds) {
EmbeddedDependency xxx0 = conv(egd.first, egd.second, egd.third);
ED xxx = ED.from(xxx0);
Flower front = xxx.front();
Flower back = xxx.back();
Set<Map<Object, Object>> frontX = front.eval(ED.conv(i0));
Set<Map<Object, Object>> backX = back.eval(ED.conv(i0));
if (!frontX.equals(backX)) {
return false;
}
}
for (Triple<List<String>, List<Triple<String, String, String>>, List<Triple<String, String, String>>> tgd : tgds) {
EmbeddedDependency xxx0 = conv2(tgd.first, tgd.second, tgd.third);
ED xxx = ED.from(xxx0);
Flower front = xxx.front();
Flower back = xxx.back();
Set<Map<Object, Object>> frontX = front.eval(ED.conv(i0));
Set<Map<Object, Object>> backX = back.eval(ED.conv(i0));
if (!frontX.equals(backX)) {
return false;
}
}
return true;
}
Aggregations