Search in sources :

Example 1 with Delta

use of catdata.fql.decl.InstExp.Delta in project fql by CategoricalData.

the class JDBCBridge method maybeExecInstance.

private static List<PSM> maybeExecInstance(InstOps ops, FQLProgram prog, Statement Stmt, String k, InstExp v, PSMInterp interp, Map<String, Set<Map<Object, Object>>> ret) throws SQLException {
    List<PSM> psm = new LinkedList<>();
    psm.addAll(PSMGen.makeTables(k, v.type(prog).toSig(prog), false));
    switch(DefunctGlobalOptions.debug.fql.sqlKind) {
        case NATIVE:
            psm.addAll(v.accept(k, ops).first);
            interp.interpX(psm, ret);
            break;
        case H2:
        case JDBC:
        default:
            if (v instanceof InstExp.FullSigma) {
                List<PSM> xxx = v.accept(k, ops).first;
                if (xxx.size() != 1) {
                    throw new RuntimeException();
                }
                FullSigma yyy = (FullSigma) xxx.get(0);
                int theguid = getGuid(Stmt);
                interp.guid = theguid;
                yyy.exec(interp, ret);
                Stmt.execute("SET @guid = " + interp.guid);
                psm.addAll(makeInserts(k, ret, v.type(prog).toSig(prog), ((InstExp.FullSigma) v).F.toMap(prog).source));
            } else if (v instanceof Exp) {
                List<PSM> xxx = v.accept(k, ops).first;
                if (xxx.size() != 1) {
                    throw new RuntimeException();
                }
                ExpPSM yyy = (ExpPSM) xxx.get(0);
                int theguid = getGuid(Stmt);
                interp.guid = theguid;
                yyy.exec(interp, ret);
                Stmt.execute("SET @guid = " + interp.guid);
                psm.addAll(makeInserts(k, ret, v.type(prog).toSig(prog), null));
            } else if (v instanceof Two) {
                List<PSM> xxx = v.accept(k, ops).first;
                if (xxx.size() != 1) {
                    throw new RuntimeException();
                }
                PropPSM yyy = (PropPSM) xxx.get(0);
                int theguid = getGuid(Stmt);
                interp.guid = theguid;
                yyy.exec(interp, ret);
                Stmt.execute("SET @guid = " + interp.guid);
                psm.addAll(makeInserts(k, ret, v.type(prog).toSig(prog), null));
            } else if (v instanceof Kernel) {
                List<PSM> xxx = v.accept(k, ops).first;
                if (xxx.size() != 1) {
                    throw new RuntimeException();
                }
                PSMUnChi yyy = (PSMUnChi) xxx.get(0);
                int theguid = getGuid(Stmt);
                interp.guid = theguid;
                yyy.exec(interp, ret);
                Stmt.execute("SET @guid = " + interp.guid);
                psm.addAll(makeInserts(k, ret, v.type(prog).toSig(prog), null));
                Signature ooo = v.type(prog).toSig(prog);
                for (Node n : ooo.nodes) {
                    psm.add(new SimpleCreateTable(k + "_trans_" + n.string, PSM.VARCHAR(), false));
                }
                for (Edge n : ooo.edges) {
                    psm.add(new SimpleCreateTable(k + "_trans_" + n.name, PSM.VARCHAR(), false));
                }
                for (Attribute<Node> n : ooo.attrs) {
                    psm.add(new SimpleCreateTable(k + "_trans_" + n.name, n.target.psm(), false));
                }
                psm.addAll(makeInserts(k + "_trans", ret, v.type(prog).toSig(prog), null));
            } else if (v instanceof External && DefunctGlobalOptions.debug.fql.sqlKind == SQLKIND.H2) {
            } else {
                psm.addAll(v.accept(k, ops).first);
            }
            for (PSM sql : psm) {
                Stmt.execute(sql.toPSM());
            }
            if (!(v instanceof InstExp.FullSigma) && !(v instanceof Exp) && !(v instanceof Two) && !(v instanceof Kernel)) {
                gatherInstance(prog, ret, Stmt, k, v);
            }
            if (v instanceof Delta) {
                gatherSubstInv(prog, ret, Stmt, k, v);
            } else if (v instanceof Times) {
                gatherTransform(prog, ret, Stmt, k + "_fst", v.type(prog).toConst(prog));
                gatherTransform(prog, ret, Stmt, k + "_snd", v.type(prog).toConst(prog));
            } else if (v instanceof One) {
                gatherSubstInv2(prog, ret, Stmt, k, v);
            }
            break;
    }
    return psm;
}
Also used : ExpPSM(catdata.fql.sql.ExpPSM) Attribute(catdata.fql.decl.Attribute) Node(catdata.fql.decl.Node) One(catdata.fql.decl.InstExp.One) PSMUnChi(catdata.fql.sql.PSMUnChi) PSM(catdata.fql.sql.PSM) PropPSM(catdata.fql.sql.PropPSM) ExpPSM(catdata.fql.sql.ExpPSM) PropPSM(catdata.fql.sql.PropPSM) Two(catdata.fql.decl.InstExp.Two) LinkedList(java.util.LinkedList) InstExp(catdata.fql.decl.InstExp) SimpleCreateTable(catdata.fql.sql.SimpleCreateTable) Delta(catdata.fql.decl.InstExp.Delta) Signature(catdata.fql.decl.Signature) Times(catdata.fql.decl.InstExp.Times) External(catdata.fql.decl.InstExp.External) FullSigma(catdata.fql.sql.FullSigma) LinkedList(java.util.LinkedList) List(java.util.List) Exp(catdata.fql.decl.InstExp.Exp) InstExp(catdata.fql.decl.InstExp) TransExp(catdata.fql.decl.TransExp) Kernel(catdata.fql.decl.InstExp.Kernel) Edge(catdata.fql.decl.Edge)

Example 2 with Delta

use of catdata.fql.decl.InstExp.Delta in project fql by CategoricalData.

the class InstOps method visit.

@Override
public List<PSM> visit(String env, Return e) {
    // String xxx = "return_temp_xxx";
    List<PSM> ret = new LinkedList<>();
    InstExp i1 = prog.insts.get(e.inst);
    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 Sigma) {
            Sigma input0 = ((Sigma) i2);
            String input = input0.I;
            for (Node n : f.source.nodes) {
                ret.add(new InsertSQL(env + "_" + n.string, PSMGen.compose(input + "_" + n.string, middle + "_" + f.nm.get(n) + "_subst", e.inst + "_" + n.string + "_subst"), "c0", "c1"));
            }
        } else if (i2 instanceof FullSigma) {
            FullSigma input0 = ((FullSigma) i2);
            String input = input0.I;
            for (Node n : f.source.nodes) {
                ret.add(new InsertSQL(env + "_" + n.string, PSMGen.compose(input + "_" + n.string, middle + "_" + n.string + "_e", e.inst + "_" + n.string + "_subst"), "c0", "c1"));
            }
        } else {
            throw new RuntimeException();
        }
    } else if (i1 instanceof Pi) {
        String middle = ((Pi) i1).I;
        // can't be null
        InstExp i2 = prog.insts.get(middle);
        Mapping f = ((Pi) i1).F.toMap(prog);
        if (i2 instanceof Delta) {
            Delta input0 = ((Delta) i2);
            String input = input0.I;
            for (Node n : f.target.nodes) {
                try {
                    Map<String, Triple<Node, Node, Arr<Node, Path>>[]> colmap = PSMGen.pi(f, middle, e.inst).second;
                    Triple<Node, Node, Arr<Node, Path>>[] col = colmap.get(n.string);
                    if (col.length == 0) {
                        LinkedHashMap<String, Pair<String, String>> select = new LinkedHashMap<>();
                        Map<String, String> from = new HashMap<>();
                        List<Pair<Pair<String, String>, Pair<String, String>>> where = new LinkedList<>();
                        from.put("lim", e.inst + "_" + n.string + "_limit");
                        from.put("middle", input + "_" + n.string);
                        select.put("c0", new Pair<>("middle", "c0"));
                        select.put("c1", new Pair<>("lim", "guid"));
                        Flower flower = new Flower(select, from, where);
                        ret.add(new InsertSQL(env + "_" + n.string, flower, "c0", "c1"));
                        return ret;
                    }
                    // LinkedHashMap<String, String> attrs = new LinkedHashMap<>();
                    // attrs.put("guid", PSM.VARCHAR());
                    LinkedHashMap<String, Pair<String, String>> select = new LinkedHashMap<>();
                    Map<String, String> from = new HashMap<>();
                    from.put("lim", e.inst + "_" + n.string + "_limit");
                    List<Pair<Pair<String, String>, Pair<String, String>>> where = new LinkedList<>();
                    int i = 0;
                    for (Triple<Node, Node, Arr<Node, Path>> col0 : col) {
                        from.put("c" + i + "_subst_inv", middle + "_" + col0.second.string + "_subst_inv");
                        where.add(new Pair<>(new Pair<>("lim", "c" + i), new Pair<>("c" + i + "_subst_inv", "c0")));
                        // attrs.put("c" + i, PSM.VARCHAR());
                        i++;
                    }
                    // if (col.length > 1) {
                    for (int j = 0; j < col.length; j++) {
                        if (col[j].third.arr.equals(f.target.toCategory2().second.of(new Path(f.target, n)).arr)) {
                            where.add(new Pair<>(new Pair<>("c" + 0 + "_subst_inv", "c1"), new Pair<>("c" + j + "_subst_inv", "c1")));
                        }
                    }
                    select.put("c" + 0, new Pair<>("c" + 0 + "_subst_inv", "c1"));
                    select.put("c1", new Pair<>("lim", "guid"));
                    // }
                    // ret.add(new CreateTable(xxx, attrs, false));
                    Flower flower = new Flower(select, from, where);
                    ret.add(new InsertSQL(env + "_" + n.string, flower, "c0", "c1"));
                } 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) FullSigma(catdata.fql.decl.InstExp.FullSigma) Sigma(catdata.fql.decl.InstExp.Sigma) LinkedHashMap(java.util.LinkedHashMap) FQLException(catdata.fql.FQLException) Pi(catdata.fql.decl.InstExp.Pi) 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) Triple(catdata.Triple) InsertSQL(catdata.fql.sql.InsertSQL) Delta(catdata.fql.decl.InstExp.Delta) FullSigma(catdata.fql.decl.InstExp.FullSigma) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Delta

use of catdata.fql.decl.InstExp.Delta in project fql by CategoricalData.

the class FqlDisplay method handleInstanceFlowEdge.

private void handleInstanceFlowEdge(Object o) {
    InstExp i = (InstExp) o;
    Object f = i.accept(new Unit(), new InstExpVisitor<Object, Unit>() {

        @Override
        public MapExp visit(Unit env, Zero e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, One e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Two e) {
            throw new RuntimeException();
        }

        @Override
        public MapExp visit(Unit env, Plus e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Times e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Exp e) {
            throw new RuntimeException();
        }

        @Override
        public MapExp visit(Unit env, Const e) {
            return null;
        }

        @Override
        public MapExp visit(Unit env, Delta e) {
            return e.F;
        }

        @Override
        public MapExp visit(Unit env, Sigma e) {
            return e.F;
        }

        @Override
        public MapExp visit(Unit env, Pi e) {
            return e.F;
        }

        @Override
        public MapExp visit(Unit env, FullSigma e) {
            return e.F;
        }

        @Override
        public Unit visit(Unit env, Relationalize e) {
            return null;
        }

        @Override
        public Unit visit(Unit env, External e) {
            return null;
        }

        @Override
        public Object visit(Unit env, Eval e) {
            return e.q;
        }

        @Override
        public Object visit(Unit env, FullEval e) {
            return e.q;
        }

        @Override
        public Object visit(Unit env, Kernel e) {
            return null;
        }

        @Override
        public Object visit(Unit env, Step e) {
            // (Step) this should return a pair
            return null;
        }
    });
    if (f == null) {
        return;
    }
    if (f instanceof QueryExp) {
        QueryExp q = (QueryExp) f;
        if (q instanceof QueryExp.Var) {
            QueryExp.Var qq = (QueryExp.Var) q;
            yyy.setSelectedValue(indices.get(qq.v), true);
            return;
        }
        String k = FQLProgram.revLookup(prog.queries, q);
        if (k != null) {
            yyy.setSelectedValue(indices.get(k), true);
            return;
        }
        String str = q.toString();
        if (!extraInsts.contains(str)) {
            Query view = q.toQuery(prog);
            JPanel p = showQuery(prog, env, view);
            x.add(p, str);
            extraInsts.add(str);
        }
        yyy.clearSelection();
        cl.show(x, str);
    } else if (f instanceof FullQueryExp) {
        FullQueryExp q = (FullQueryExp) f;
        if (q instanceof FullQueryExp.Var) {
            FullQueryExp.Var qq = (FullQueryExp.Var) q;
            yyy.setSelectedValue(indices.get(qq.v), true);
            return;
        }
        String k = FQLProgram.revLookup(prog.full_queries, q);
        if (k != null) {
            yyy.setSelectedValue(indices.get(k), true);
            return;
        }
        String str = q.toString();
        if (!extraInsts.contains(str)) {
            FullQuery view = q.toFullQuery(prog);
            JPanel p = showFullQuery(prog, env, view, q);
            x.add(p, str);
            extraInsts.add(str);
        }
        yyy.clearSelection();
        cl.show(x, str);
    } else if (f instanceof MapExp) {
        MapExp q = (MapExp) f;
        if (q instanceof MapExp.Var) {
            MapExp.Var qq = (MapExp.Var) q;
            yyy.setSelectedValue(indices.get(qq.v), true);
            return;
        }
        String k = FQLProgram.revLookup(prog.maps, q);
        if (k != null) {
            yyy.setSelectedValue(indices.get(k), true);
            return;
        }
        String str = q.toString();
        if (!extraInsts.contains(str)) {
            Mapping view = q.toMap(prog);
            JPanel p = showMapping(env, prog.smap(view.source.toConst()), prog.smap(view.target.toConst()), view);
            x.add(p, str);
            extraInsts.add(str);
        }
        yyy.clearSelection();
        cl.show(x, str);
    } else {
        throw new RuntimeException();
    }
}
Also used : JPanel(javax.swing.JPanel) FullEval(catdata.fql.decl.InstExp.FullEval) FullQuery(catdata.fql.decl.FullQuery) Query(catdata.fql.decl.Query) FullQueryExp(catdata.fql.decl.FullQueryExp) QueryExp(catdata.fql.decl.QueryExp) Var(catdata.fql.decl.SigExp.Var) One(catdata.fql.decl.InstExp.One) FullSigma(catdata.fql.decl.InstExp.FullSigma) Sigma(catdata.fql.decl.InstExp.Sigma) FullQueryExp(catdata.fql.decl.FullQueryExp) Mapping(catdata.fql.decl.Mapping) Step(catdata.fql.decl.InstExp.Step) Unit(catdata.Unit) Pi(catdata.fql.decl.InstExp.Pi) Plus(catdata.fql.decl.InstExp.Plus) FullEval(catdata.fql.decl.InstExp.FullEval) Eval(catdata.fql.decl.InstExp.Eval) Kernel(catdata.fql.decl.InstExp.Kernel) Relationalize(catdata.fql.decl.InstExp.Relationalize) FullQuery(catdata.fql.decl.FullQuery) Zero(catdata.fql.decl.InstExp.Zero) Const(catdata.fql.decl.InstExp.Const) Two(catdata.fql.decl.InstExp.Two) InstExp(catdata.fql.decl.InstExp) MapExp(catdata.fql.decl.MapExp) Delta(catdata.fql.decl.InstExp.Delta) Times(catdata.fql.decl.InstExp.Times) External(catdata.fql.decl.InstExp.External) FullSigma(catdata.fql.decl.InstExp.FullSigma) FullQueryExp(catdata.fql.decl.FullQueryExp) Exp(catdata.fql.decl.InstExp.Exp) MapExp(catdata.fql.decl.MapExp) QueryExp(catdata.fql.decl.QueryExp) SigExp(catdata.fql.decl.SigExp) InstExp(catdata.fql.decl.InstExp)

Example 4 with Delta

use of catdata.fql.decl.InstExp.Delta 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)

Example 5 with Delta

use of catdata.fql.decl.InstExp.Delta in project fql by CategoricalData.

the class FQLProgram method build.

private Graph<String, Object> build() {
    // Graph<V, E> where V is the type of the vertices
    Graph<String, Object> g2 = new DirectedSparseMultigraph<>();
    Ref<Integer> guid = new Ref<>(0);
    for (String k : insts.keySet()) {
        InstExp i = insts.get(k);
        i.type(this).toConst(this);
        g2.addVertex(k);
        i.accept(new Unit(), new InstExpVisitor<Unit, Unit>() {

            @Override
            public Unit visit(Unit env, Zero e) {
                return null;
            }

            @Override
            public Unit visit(Unit env, One e) {
                return null;
            }

            @Override
            public Unit visit(Unit env, Two e) {
                return null;
            }

            @Override
            public Unit visit(Unit env, Plus e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.a, k);
                g2.addEdge(new Pair<>(pp(guid), e), e.b, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, Times e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.a, k);
                g2.addEdge(new Pair<>(pp(guid), e), e.b, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, Exp e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.a, k);
                g2.addEdge(new Pair<>(pp(guid), e), e.b, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, Const e) {
                return null;
            }

            @Override
            public Unit visit(Unit env, Delta e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, Sigma e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, Pi e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, FullSigma e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, Relationalize e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.I, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, External e) {
                return null;
            }

            @Override
            public Unit visit(Unit env, Eval e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.e, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, FullEval e) {
                g2.addEdge(new Pair<>(pp(guid), e), e.e, k);
                return null;
            }

            @Override
            public Unit visit(Unit env, Kernel e) {
                TransExp t = transforms.get(e.trans);
                Pair<String, String> p = t.type(FQLProgram.this);
                g2.addEdge(new Pair<>(pp(guid), e), p.first, k);
                g2.addEdge(new Pair<>(pp(guid), e), p.second, k);
                return null;
            }

            private Integer pp(Ref<Integer> ref) {
                int ret = ref.x;
                ref.x = ret + 1;
                return ref.x;
            }

            @Override
            public Unit visit(Unit env, Step e) {
                // (Step) this should add an edge
                return null;
            }
        });
    }
    return g2;
}
Also used : FullEval(catdata.fql.decl.InstExp.FullEval) One(catdata.fql.decl.InstExp.One) FullSigma(catdata.fql.decl.InstExp.FullSigma) Sigma(catdata.fql.decl.InstExp.Sigma) Step(catdata.fql.decl.InstExp.Step) Unit(catdata.Unit) Pi(catdata.fql.decl.InstExp.Pi) Plus(catdata.fql.decl.InstExp.Plus) FullEval(catdata.fql.decl.InstExp.FullEval) Eval(catdata.fql.decl.InstExp.Eval) Kernel(catdata.fql.decl.InstExp.Kernel) Pair(catdata.Pair) Relationalize(catdata.fql.decl.InstExp.Relationalize) Zero(catdata.fql.decl.InstExp.Zero) Const(catdata.fql.decl.InstExp.Const) Two(catdata.fql.decl.InstExp.Two) Ref(catdata.Ref) Delta(catdata.fql.decl.InstExp.Delta) DirectedSparseMultigraph(edu.uci.ics.jung.graph.DirectedSparseMultigraph) Times(catdata.fql.decl.InstExp.Times) External(catdata.fql.decl.InstExp.External) FullSigma(catdata.fql.decl.InstExp.FullSigma) Exp(catdata.fql.decl.InstExp.Exp)

Aggregations

Delta (catdata.fql.decl.InstExp.Delta)5 FullSigma (catdata.fql.decl.InstExp.FullSigma)4 Pi (catdata.fql.decl.InstExp.Pi)4 Sigma (catdata.fql.decl.InstExp.Sigma)4 Pair (catdata.Pair)3 Exp (catdata.fql.decl.InstExp.Exp)3 External (catdata.fql.decl.InstExp.External)3 Kernel (catdata.fql.decl.InstExp.Kernel)3 One (catdata.fql.decl.InstExp.One)3 Times (catdata.fql.decl.InstExp.Times)3 Two (catdata.fql.decl.InstExp.Two)3 ExpPSM (catdata.fql.sql.ExpPSM)3 PSM (catdata.fql.sql.PSM)3 PropPSM (catdata.fql.sql.PropPSM)3 Triple (catdata.Triple)2 Unit (catdata.Unit)2 FQLException (catdata.fql.FQLException)2 Arr (catdata.fql.cat.Arr)2 InstExp (catdata.fql.decl.InstExp)2 Const (catdata.fql.decl.InstExp.Const)2