Search in sources :

Example 1 with ED

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;
}
Also used : Flower(catdata.fql.sql.Flower) LinkedList(java.util.LinkedList) HashMap(java.util.HashMap) Map(java.util.Map) EmbeddedDependency(catdata.fql.sql.EmbeddedDependency) Pair(catdata.Pair) ED(catdata.fql.sql.ED)

Example 2 with ED

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;
}
Also used : Flower(catdata.fql.sql.Flower) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) EmbeddedDependency(catdata.fql.sql.EmbeddedDependency) ED(catdata.fql.sql.ED)

Example 3 with ED

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;
}
Also used : Flower(catdata.fql.sql.Flower) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) EmbeddedDependency(catdata.fql.sql.EmbeddedDependency) ED(catdata.fql.sql.ED)

Aggregations

ED (catdata.fql.sql.ED)3 EmbeddedDependency (catdata.fql.sql.EmbeddedDependency)3 Flower (catdata.fql.sql.Flower)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 LinkedList (java.util.LinkedList)2 Pair (catdata.Pair)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1