Search in sources :

Example 16 with Arr

use of catdata.fql.cat.Arr in project fql by CategoricalData.

the class PSMCurry method exec.

@Override
public void exec(PSMInterp interp, Map<String, Set<Map<Object, Object>>> state) {
    try {
        Instance IJ = new Instance(sig, PSMGen.gather(trans_src, sig, state));
        Instance K = new Instance(sig, PSMGen.gather(trans_dst, sig, state));
        Transform t = new Transform(IJ, K, PSMGen.gather(trans, sig, state));
        Instance I = new Instance(sig, PSMGen.gather(inst_src, sig, state));
        Instance J = new Instance(sig, PSMGen.gather(exp, sig, state));
        Instance JK = new Instance(sig, PSMGen.gather(inst_dst, sig, state));
        Transform trans_src0_fst = new Transform(IJ, I, PSMGen.gather(trans_src + "_fst", sig, state));
        Transform trans_src0_snd = new Transform(IJ, J, PSMGen.gather(trans_src + "_snd", sig, state));
        Map<Node, List<Pair<Arr<Node, Path>, Attribute<Node>>>> obs = I.thesig.obs();
        List<Pair<String, List<Pair<Object, Object>>>> l = new LinkedList<>();
        Quad<Instance, Map<Pair<Node, LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>>, Triple<Instance, Map<Node, Map<Object, Pair<Arr<Node, Path>, Object>>>, Map<Node, Map<Pair<Arr<Node, Path>, Object>, Object>>>>, Map<Node, Map<Object, Pair<LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>, Transform>>>, Map<Node, Map<Pair<LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>, Transform>, Object>>> kkk = interp.exps2.get(inst_dst);
        for (Node c : sig.nodes) {
            List<Pair<Object, Object>> s = new LinkedList<>();
            for (Pair<Object, Object> xx : I.data.get(c.string)) {
                Object x = xx.first;
                LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object> w = I.flag(c, x);
                Triple<Instance, Map<Node, Map<Object, Pair<Arr<Node, Path>, Object>>>, Map<Node, Map<Pair<Arr<Node, Path>, Object>, Object>>> HcJ = kkk.second.get(new Pair<>(c, w));
                // construct transform depending on x, lookup in kkk.second
                List<Pair<String, List<Pair<Object, Object>>>> tx = new LinkedList<>();
                for (Node d : sig.nodes) {
                    List<Pair<Object, Object>> tx0 = new LinkedList<>();
                    for (Arr<Node, Path> f : sig.toCategory2().first.hom(c, d)) {
                        for (Pair<Object, Object> y : J.data.get(d.string)) {
                            // only if y(p.a) = w(p.a)
                            if (!PropPSM.truncate2(I.thesig, w, f, obs.get(d)).equals(J.flag(d, y.first))) {
                                continue;
                            }
                            Object Ifx = lookup(I.evaluate(f.arr), x);
                            // Object Ifx = lookup(HcJ.first.evaluate(f.arr), x);
                            Object u = find(d, trans_src0_fst, trans_src0_snd, Ifx, y.first);
                            Object v = lookup(t.data.get(d.string), u);
                            Object iii = HcJ.third.get(d).get(new Pair<>(f, y.first));
                            tx0.add(new Pair<>(iii, v));
                        }
                    }
                    // I*J -> K
                    tx.add(new Pair<>(d.string, tx0));
                }
                Transform xxx = new Transform(HcJ.first, K, tx);
                Object yyy = kkk.fourth.get(c).get(new Pair<>(w, xxx));
                s.add(new Pair<>(x, yyy));
            }
            l.add(new Pair<>(c.string, s));
        }
        Transform zzz = new Transform(I, JK, l);
        PSMGen.shred(ret, zzz, state);
    } catch (FQLException fe) {
        fe.printStackTrace();
        throw new RuntimeException(fe.getMessage());
    }
}
Also used : Arr(catdata.fql.cat.Arr) Path(catdata.fql.decl.Path) Instance(catdata.fql.decl.Instance) Attribute(catdata.fql.decl.Attribute) Node(catdata.fql.decl.Node) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) FQLException(catdata.fql.FQLException) List(java.util.List) LinkedList(java.util.LinkedList) Transform(catdata.fql.decl.Transform) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Pair(catdata.Pair)

Example 17 with Arr

use of catdata.fql.cat.Arr in project fql by CategoricalData.

the class InstOps method visit.

@Override
public List<PSM> visit(String dst, TransExp.Pi e) {
    try {
        List<PSM> ret = new LinkedList<>();
        Pair<String, String> ht = e.h.type(prog);
        Signature sig = prog.insts.get(ht.first).type(prog).toSig(prog);
        Mapping F = ((Pi) prog.insts.get(e.src)).F.toMap(prog);
        Map<String, Triple<Node, Node, Arr<Node, Path>>[]> colmap1x = PSMGen.pi(F, e.h.type(prog).first, e.src).second;
        String next = next();
        ret.addAll(PSMGen.makeTables(next, sig, false));
        ret.addAll(e.h.accept(next, this));
        Signature sig2 = prog.insts.get(e.src).type(prog).toSig(prog);
        for (Node n : sig2.nodes) {
            List<Pair<Pair<String, String>, Pair<String, String>>> where = new LinkedList<>();
            Map<String, String> from = new HashMap<>();
            from.put("limit1", e.src + "_" + n.string + "_limit");
            from.put("limit2", e.dst + "_" + n.string + "_limit");
            LinkedHashMap<String, Pair<String, String>> select = new LinkedHashMap<>();
            int i = 0;
            for (Triple<Node, Node, Arr<Node, Path>> col : colmap1x.get(n.string)) {
                from.put("l" + i, next + "_" + col.second.string);
                where.add(new Pair<>(new Pair<>("l" + i, "c0"), new Pair<>("limit1", "c" + i)));
                where.add(new Pair<>(new Pair<>("l" + i, "c1"), new Pair<>("limit2", "c" + i)));
                i++;
            }
            // check
            for (@SuppressWarnings("unused") Attribute<Node> a : sig2.attrsFor(n)) {
                where.add(new Pair<>(new Pair<>("limit1", "c" + i), new Pair<>("limit2", "c" + i)));
                i++;
            }
            select.put("c0", new Pair<>("limit1", "guid"));
            select.put("c1", new Pair<>("limit2", "guid"));
            Flower f = new Flower(select, from, where);
            ret.add(new InsertSQL(dst + "_" + n.string, f, "c0", "c1"));
        }
        return ret;
    } catch (FQLException fe) {
        fe.printStackTrace();
        throw new RuntimeException(fe.getLocalizedMessage());
    }
}
Also used : Arr(catdata.fql.cat.Arr) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LinkedHashMap(java.util.LinkedHashMap) FQLException(catdata.fql.FQLException) Pair(catdata.Pair) CopyFlower(catdata.fql.sql.CopyFlower) Flower(catdata.fql.sql.Flower) PropPSM(catdata.fql.sql.PropPSM) ExpPSM(catdata.fql.sql.ExpPSM) PSM(catdata.fql.sql.PSM) LinkedList(java.util.LinkedList) InsertSQL(catdata.fql.sql.InsertSQL)

Example 18 with Arr

use of catdata.fql.cat.Arr in project fql by CategoricalData.

the class InstOps method visit.

@Override
public Pair<List<PSM>, Object> visit(String dst, Times e) {
    try {
        SigExp k = e.type(prog);
        Signature s = k.toSig(prog);
        List<PSM> ret = new LinkedList<>();
        ret.addAll(PSMGen.makeTables(dst + "_fst", s, false));
        ret.addAll(PSMGen.makeTables(dst + "_snd", s, false));
        Pair<Map<Node, List<Pair<Path, Attribute<Node>>>>, List<PSM>> l_obs = Relationalizer.observations(s, dst + "_l_obs", e.a, false);
        Pair<Map<Node, List<Pair<Path, Attribute<Node>>>>, List<PSM>> r_obs = Relationalizer.observations(s, dst + "_r_obs", e.b, false);
        if (!(l_obs.first.equals(r_obs.first))) {
            throw new RuntimeException("Internal error, please report.");
        }
        ret.addAll(PSMGen.makeTables(dst + "_l_obs", s, false));
        ret.addAll(l_obs.second);
        ret.addAll(PSMGen.dropTables(dst + "_l_obs", s));
        ret.addAll(PSMGen.makeTables(dst + "_r_obs", s, false));
        ret.addAll(r_obs.second);
        ret.addAll(PSMGen.dropTables(dst + "_r_obs", s));
        for (Node n : s.nodes) {
            List<Pair<Path, Attribute<Node>>> lats = l_obs.first.get(n);
            // List<Pair<Path, Attribute<Node>>> rats = r_obs.first.get(n);
            LinkedHashMap<String, Pair<String, String>> select = new LinkedHashMap<>();
            Map<String, String> from = new HashMap<>();
            List<String> attrs = new LinkedList<>();
            Map<String, String> attrsM = new HashMap<>();
            List<Pair<Pair<String, String>, Pair<String, String>>> where = new LinkedList<>();
            from.put("lft", dst + "_l_obs_" + n.string + "_observables");
            from.put("rght", dst + "_r_obs_" + n.string + "_observables");
            attrs.add("lft");
            attrs.add("rght");
            attrsM.put("lft", PSM.VARCHAR());
            attrsM.put("rght", PSM.VARCHAR());
            select.put("lft", new Pair<>("lft", "id"));
            select.put("rght", new Pair<>("rght", "id"));
            int idx = 0;
            for (Pair<Path, Attribute<Node>> aa : lats) {
                Attribute<Node> a = aa.second;
                where.add(new Pair<>(new Pair<>("lft", "c" + idx), new Pair<>("rght", "c" + idx)));
                select.put("c" + idx, new Pair<>("lft", "c" + idx));
                attrs.add("c" + idx);
                attrsM.put("c" + idx, a.target.psm());
                idx++;
            }
            Flower f = new Flower(select, from, where);
            ret.add(new CreateTable(dst + "_prod_temp_" + n.string, attrsM, false));
            ret.add(new InsertSQL2(dst + "_prod_temp_" + n.string, f, attrs));
            Map<String, String> attrsM0 = new HashMap<>(attrsM);
            attrsM0.put("gguid", PSM.VARCHAR());
            ret.add(new CreateTable(dst + "_prod_guid_" + n.string, attrsM0, false));
            ret.add(new InsertKeygen(dst + "_prod_guid_" + n.string, "gguid", dst + "_prod_temp_" + n.string, attrs));
            List<Pair<Pair<String, String>, Pair<String, String>>> where0 = new LinkedList<>();
            from = new HashMap<>();
            from.put("t", dst + "_prod_guid_" + n.string);
            select = new LinkedHashMap<>();
            select.put("c0", new Pair<>("t", "gguid"));
            select.put("c1", new Pair<>("t", "lft"));
            f = new Flower(select, from, where0);
            ret.add(new InsertSQL(dst + "_fst_" + n, f, "c0", "c1"));
            from = new HashMap<>();
            from.put("t", dst + "_prod_guid_" + n.string);
            select = new LinkedHashMap<>();
            select.put("c0", new Pair<>("t", "gguid"));
            select.put("c1", new Pair<>("t", "rght"));
            f = new Flower(select, from, where0);
            ret.add(new InsertSQL(dst + "_snd_" + n, f, "c0", "c1"));
            LinkedHashMap<String, Pair<String, String>> select0 = new LinkedHashMap<>();
            select0.put("c0", new Pair<>("t", "gguid"));
            select0.put("c1", new Pair<>("t", "gguid"));
            Map<String, String> from0 = new HashMap<>();
            from0.put("t", dst + "_prod_guid_" + n.string);
            Flower sql = new Flower(select0, from0, where0);
            ret.add(new InsertSQL(dst + "_" + n.string, sql, "c0", "c1"));
            for (Attribute<Node> a : s.attrsFor(n)) {
                select0 = new LinkedHashMap<>();
                select0.put("c0", new Pair<>("t", "gguid"));
                Arr<Node, Path> ppp = s.toCategory2().first.id(n);
                int ppp0 = lats.indexOf(new Pair<>(ppp.arr, a));
                select0.put("c1", new Pair<>("t", "c" + ppp0));
                from0 = new HashMap<>();
                from0.put("t", dst + "_prod_guid_" + n.string);
                sql = new Flower(select0, from0, where0);
                ret.add(new InsertSQL(dst + "_" + a.name, sql, "c0", "c1"));
            }
        // ret.add(new DropTable(dst + "_prod_temp_" + n));
        }
        for (Edge edge : s.edges) {
            Map<String, String> from = new HashMap<>();
            from.put("leftEdge", e.a + "_" + edge.name);
            from.put("rightEdge", e.b + "_" + edge.name);
            from.put("srcGuid", dst + "_prod_guid_" + edge.source);
            from.put("dstGuid", dst + "_prod_guid_" + edge.target);
            List<Pair<Pair<String, String>, Pair<String, String>>> where = new LinkedList<>();
            where.add(new Pair<>(new Pair<>("leftEdge", "c0"), new Pair<>("srcGuid", "lft")));
            where.add(new Pair<>(new Pair<>("rightEdge", "c0"), new Pair<>("srcGuid", "rght")));
            where.add(new Pair<>(new Pair<>("leftEdge", "c1"), new Pair<>("dstGuid", "lft")));
            where.add(new Pair<>(new Pair<>("rightEdge", "c1"), new Pair<>("dstGuid", "rght")));
            LinkedHashMap<String, Pair<String, String>> select = new LinkedHashMap<>();
            select.put("c0", new Pair<>("srcGuid", "gguid"));
            select.put("c1", new Pair<>("dstGuid", "gguid"));
            Flower f = new Flower(select, from, where);
            ret.add(new InsertSQL(dst + "_" + edge.name, f, "c0", "c1"));
        }
        Fn<Quad<String, String, String, String>, List<PSM>> fn = x -> {
            // x.third -> e.a
            String f = x.first;
            // x.third -> e.b
            String g = x.second;
            // String C = x.third;
            String dst0 = x.fourth;
            // must be a map x.third -> dst
            List<PSM> ret1 = new LinkedList<>();
            for (Node n : s.nodes) {
                List<Pair<Pair<String, String>, Pair<String, String>>> where = new LinkedList<>();
                Map<String, String> from = new HashMap<>();
                from.put("f", f + "_" + n.string);
                from.put("g", g + "_" + n.string);
                from.put("lim", dst + "_prod_guid_" + n.string);
                where.add(new Pair<>(new Pair<>("f", "c0"), new Pair<>("g", "c0")));
                where.add(new Pair<>(new Pair<>("lim", "lft"), new Pair<>("f", "c1")));
                where.add(new Pair<>(new Pair<>("lim", "rght"), new Pair<>("g", "c1")));
                LinkedHashMap<String, Pair<String, String>> select = new LinkedHashMap<>();
                select.put("c0", new Pair<>("f", "c0"));
                select.put("c1", new Pair<>("lim", "gguid"));
                Flower flower = new Flower(select, from, where);
                ret1.add(new InsertSQL(dst0 + "_" + n.string, flower, "c0", "c1"));
            }
            return ret1;
        };
        return new Pair<>(ret, fn);
    } catch (FQLException fe) {
        throw new RuntimeException(fe.getLocalizedMessage());
    }
}
Also used : Inr(catdata.fql.decl.TransExp.Inr) Case(catdata.fql.decl.TransExp.Case) TransEval(catdata.fql.decl.TransExp.TransEval) Snd(catdata.fql.decl.TransExp.Snd) TransIso(catdata.fql.decl.TransExp.TransIso) Kernel(catdata.fql.decl.InstExp.Kernel) TransCurry(catdata.fql.decl.TransExp.TransCurry) Inl(catdata.fql.decl.TransExp.Inl) Coreturn(catdata.fql.decl.TransExp.Coreturn) PSMStep(catdata.fql.sql.PSMStep) CopyFlower(catdata.fql.sql.CopyFlower) Map(java.util.Map) Or(catdata.fql.decl.TransExp.Or) Squash(catdata.fql.decl.TransExp.Squash) TT(catdata.fql.decl.TransExp.TT) And(catdata.fql.decl.TransExp.And) Exp(catdata.fql.decl.InstExp.Exp) Fn(catdata.fql.Fn) Pair(catdata.Pair) Not(catdata.fql.decl.TransExp.Not) FullSigma(catdata.fql.decl.InstExp.FullSigma) PSMAnd(catdata.fql.sql.PSMAnd) Plus(catdata.fql.decl.InstExp.Plus) Quad(catdata.Quad) FullSigmaCounit(catdata.fql.sql.FullSigmaCounit) PropPSM(catdata.fql.sql.PropPSM) FullEval(catdata.fql.decl.InstExp.FullEval) Set(java.util.Set) PSMGen(catdata.fql.sql.PSMGen) FullQueryVisitor(catdata.fql.decl.FullQuery.FullQueryVisitor) Eval(catdata.fql.decl.InstExp.Eval) InsertSQL2(catdata.fql.sql.InsertSQL2) PSMUnChi(catdata.fql.sql.PSMUnChi) Times(catdata.fql.decl.InstExp.Times) Fst(catdata.fql.decl.TransExp.Fst) PSMNot(catdata.fql.sql.PSMNot) List(java.util.List) Delta(catdata.fql.decl.InstExp.Delta) ExpPSM(catdata.fql.sql.ExpPSM) TransExpVisitor(catdata.fql.decl.TransExp.TransExpVisitor) PSMBool(catdata.fql.sql.PSMBool) Triple(catdata.Triple) Flower(catdata.fql.sql.Flower) Implies(catdata.fql.decl.TransExp.Implies) Id(catdata.fql.decl.TransExp.Id) External(catdata.fql.decl.InstExp.External) InsertKeygen(catdata.fql.sql.InsertKeygen) Chi(catdata.fql.decl.TransExp.Chi) FullSigmaTrans(catdata.fql.sql.FullSigmaTrans) HashMap(java.util.HashMap) Var(catdata.fql.decl.TransExp.Var) SQL(catdata.fql.sql.SQL) FQLException(catdata.fql.FQLException) Two(catdata.fql.decl.InstExp.Two) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) PSM(catdata.fql.sql.PSM) FF(catdata.fql.decl.TransExp.FF) LinkedList(java.util.LinkedList) UnChi(catdata.fql.decl.TransExp.UnChi) SimpleCreateTable(catdata.fql.sql.SimpleCreateTable) Comp(catdata.fql.decl.TransExp.Comp) PSMIso(catdata.fql.sql.PSMIso) CreateTable(catdata.fql.sql.CreateTable) InsertValues(catdata.fql.sql.InsertValues) Prod(catdata.fql.decl.TransExp.Prod) Const(catdata.fql.decl.InstExp.Const) Relationalize(catdata.fql.decl.InstExp.Relationalize) PSMCurry(catdata.fql.sql.PSMCurry) One(catdata.fql.decl.InstExp.One) Zero(catdata.fql.decl.InstExp.Zero) Pi(catdata.fql.decl.InstExp.Pi) DropTable(catdata.fql.sql.DropTable) InstExpVisitor(catdata.fql.decl.InstExp.InstExpVisitor) Step(catdata.fql.decl.InstExp.Step) Arr(catdata.fql.cat.Arr) Return(catdata.fql.decl.TransExp.Return) InsertSQL(catdata.fql.sql.InsertSQL) Union(catdata.fql.sql.Union) Sigma(catdata.fql.decl.InstExp.Sigma) Bool(catdata.fql.decl.TransExp.Bool) PSMEval(catdata.fql.sql.PSMEval) Relationalizer(catdata.fql.sql.Relationalizer) PSMChi(catdata.fql.sql.PSMChi) Quad(catdata.Quad) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SimpleCreateTable(catdata.fql.sql.SimpleCreateTable) CreateTable(catdata.fql.sql.CreateTable) InsertKeygen(catdata.fql.sql.InsertKeygen) LinkedHashMap(java.util.LinkedHashMap) FQLException(catdata.fql.FQLException) List(java.util.List) LinkedList(java.util.LinkedList) Pair(catdata.Pair) CopyFlower(catdata.fql.sql.CopyFlower) Flower(catdata.fql.sql.Flower) PropPSM(catdata.fql.sql.PropPSM) ExpPSM(catdata.fql.sql.ExpPSM) PSM(catdata.fql.sql.PSM) LinkedList(java.util.LinkedList) InsertSQL(catdata.fql.sql.InsertSQL) InsertSQL2(catdata.fql.sql.InsertSQL2) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 19 with Arr

use of catdata.fql.cat.Arr in project fql by CategoricalData.

the class InstOps method visit.

@Override
public List<PSM> visit(String env, Bool e) {
    List<PSM> ret = new LinkedList<>();
    // .toSig(prog);
    SigExp.Const sigX = prog.insts.get(e.unit).type(prog).toConst(prog);
    Signature sig = sigX.toSig(prog);
    Triple<Const, Map<Node, Map<Object, LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>>>, Map<Node, Map<LinkedHashMap<Pair<Arr<Node, Path>, Attribute<Node>>, Object>, Object>>> kkk = Relationalizer.terminal(prog, sigX);
    ret.add(new PSMBool(e.bool, e.unit, e.prop, sig, env, kkk.first, kkk.second, kkk.third));
    return ret;
}
Also used : Arr(catdata.fql.cat.Arr) PSMBool(catdata.fql.sql.PSMBool) Const(catdata.fql.decl.InstExp.Const) PropPSM(catdata.fql.sql.PropPSM) ExpPSM(catdata.fql.sql.ExpPSM) PSM(catdata.fql.sql.PSM) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 20 with Arr

use of catdata.fql.cat.Arr in project fql by CategoricalData.

the class InstOps method visit.

@Override
public List<PSM> visit(String env, Coreturn e) {
    String xxx = "coreturn_temp_xxx";
    List<PSM> ret = new LinkedList<>();
    InstExp i1 = prog.insts.get(e.inst);
    if (i1 instanceof Sigma) {
        String middle = ((Sigma) i1).I;
        // can't be null
        InstExp i2 = prog.insts.get(middle);
        Mapping f = ((Sigma) i1).F.toMap(prog);
        if (i2 instanceof Delta) {
            for (Node n : f.target.nodes) {
                List<Flower> u = new LinkedList<>();
                for (Node m : f.source.nodes) {
                    if (!f.nm.get(m).equals(n)) {
                        continue;
                    }
                    u.add(new CopyFlower(middle + "_" + m.string + "_subst_inv", "c0", "c1"));
                }
                ret.add(new SimpleCreateTable(xxx, PSM.VARCHAR(), false));
                ret.add(new InsertSQL(xxx, new Union(u), "c0", "c1"));
                ret.add(new InsertSQL(env + "_" + n.string, PSMGen.compose(e.inst + "_" + n.string + "_subst_inv", xxx), "c0", "c1"));
                ret.add(new DropTable(xxx));
            }
        }
    } else if (i1 instanceof FullSigma) {
        String middle = ((FullSigma) i1).I;
        // can't be null
        InstExp i2 = prog.insts.get(middle);
        Mapping f = ((FullSigma) i1).F.toMap(prog);
        if (i2 instanceof Delta) {
            ret.add(new FullSigmaCounit(f, ((Delta) i2).I, middle, e.inst, env));
        } else {
            throw new RuntimeException();
        }
    } else if (i1 instanceof Delta) {
        String middle = ((Delta) i1).I;
        // can't be null
        InstExp i2 = prog.insts.get(middle);
        Mapping f = ((Delta) i1).F.toMap(prog);
        if (i2 instanceof Pi) {
            Pi input0 = ((Pi) i2);
            String input = input0.I;
            try {
                Map<String, Triple<Node, Node, Arr<Node, Path>>[]> colmap = PSMGen.pi(f, input, middle).second;
                for (Node m : f.source.nodes) {
                    Node n = f.nm.get(m);
                    Triple<Node, Node, Arr<Node, Path>>[] col = colmap.get(n.string);
                    Triple<Node, Node, Arr<Node, Path>> toFind = new Triple<>(n, m, new Arr<>(new Path(f.target, n), n, n));
                    int i = 0;
                    boolean found = false;
                    for (Triple<Node, Node, Arr<Node, Path>> cand : col) {
                        if (cand.equals(toFind)) {
                            found = true;
                            Map<String, String> from = new HashMap<>();
                            from.put("lim", middle + "_" + n + "_limit");
                            LinkedHashMap<String, Pair<String, String>> select = new LinkedHashMap<>();
                            select.put("c0", new Pair<>("lim", "guid"));
                            select.put("c1", new Pair<>("lim", "c" + i));
                            List<Pair<Pair<String, String>, Pair<String, String>>> where = new LinkedList<>();
                            Flower flower = new Flower(select, from, where);
                            ret.add(new SimpleCreateTable(xxx, PSM.VARCHAR(), false));
                            ret.add(new InsertSQL(xxx, flower, "c0", "c1"));
                            ret.add(new InsertSQL(env + "_" + m, PSMGen.compose(e.inst + "_" + m + "_subst_inv", xxx), "c0", "c1"));
                            ret.add(new DropTable(xxx));
                            break;
                        }
                        i++;
                    }
                    if (!found) {
                        throw new RuntimeException();
                    }
                }
            } catch (FQLException fe) {
                fe.printStackTrace();
                throw new RuntimeException(fe.getMessage());
            }
        } else {
            throw new RuntimeException();
        }
    } else {
        throw new RuntimeException();
    }
    return ret;
}
Also used : Arr(catdata.fql.cat.Arr) CopyFlower(catdata.fql.sql.CopyFlower) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FullSigma(catdata.fql.decl.InstExp.FullSigma) Sigma(catdata.fql.decl.InstExp.Sigma) DropTable(catdata.fql.sql.DropTable) Union(catdata.fql.sql.Union) LinkedHashMap(java.util.LinkedHashMap) FQLException(catdata.fql.FQLException) SimpleCreateTable(catdata.fql.sql.SimpleCreateTable) Pi(catdata.fql.decl.InstExp.Pi) Pair(catdata.Pair) FullSigmaCounit(catdata.fql.sql.FullSigmaCounit) CopyFlower(catdata.fql.sql.CopyFlower) Flower(catdata.fql.sql.Flower) PropPSM(catdata.fql.sql.PropPSM) ExpPSM(catdata.fql.sql.ExpPSM) PSM(catdata.fql.sql.PSM) LinkedList(java.util.LinkedList) Triple(catdata.Triple) InsertSQL(catdata.fql.sql.InsertSQL) Delta(catdata.fql.decl.InstExp.Delta) FullSigma(catdata.fql.decl.InstExp.FullSigma)

Aggregations

Arr (catdata.fql.cat.Arr)24 Pair (catdata.Pair)21 LinkedHashMap (java.util.LinkedHashMap)20 HashMap (java.util.HashMap)19 FQLException (catdata.fql.FQLException)17 LinkedList (java.util.LinkedList)16 Map (java.util.Map)15 Node (catdata.fql.decl.Node)14 Triple (catdata.Triple)11 Path (catdata.fql.decl.Path)11 Attribute (catdata.fql.decl.Attribute)10 Instance (catdata.fql.decl.Instance)9 HashSet (java.util.HashSet)7 Set (java.util.Set)7 Fn (catdata.fql.Fn)6 Edge (catdata.fql.decl.Edge)6 Signature (catdata.fql.decl.Signature)6 Transform (catdata.fql.decl.Transform)6 PSM (catdata.fql.sql.PSM)6 List (java.util.List)6