Search in sources :

Example 36 with PSM

use of catdata.fql.sql.PSM in project fql by CategoricalData.

the class InstOps method visit.

@Override
public List<PSM> visit(String dst, Inr e) {
    List<PSM> ret = new LinkedList<>();
    InstExp k = prog.insts.get(e.obj);
    Signature t = k.type(prog).toSig(prog);
    for (Node n : t.nodes) {
        ret.add(new InsertSQL(dst + "_" + n.string, new CopyFlower(e.obj + "_inr_" + n.string, "c0", "c1"), "c0", "c1"));
    }
    return ret;
}
Also used : InsertSQL(catdata.fql.sql.InsertSQL) CopyFlower(catdata.fql.sql.CopyFlower) PropPSM(catdata.fql.sql.PropPSM) ExpPSM(catdata.fql.sql.ExpPSM) PSM(catdata.fql.sql.PSM) LinkedList(java.util.LinkedList)

Example 37 with PSM

use of catdata.fql.sql.PSM in project fql by CategoricalData.

the class JDBCBridge method makeInserts.

private static List<PSM> makeInserts(String k, Map<String, Set<Map<Object, Object>>> state, Signature sig, Signature src_sig) {
    List<PSM> ret = new LinkedList<>();
    List<String> attrs = new LinkedList<>();
    attrs.add("c0");
    attrs.add("c1");
    if (src_sig != null) {
        for (Node n : src_sig.nodes) {
            Set<Map<Object, Object>> v = state.get(k + "_" + n.string + "_e");
            ret.add(new SimpleCreateTable(k + "_" + n.string + "_e", PSM.VARCHAR(), false));
            if (v.isEmpty()) {
                continue;
            }
            ret.add(new InsertValues(k + "_" + n.string + "_e", attrs, v));
        }
        Set<Map<Object, Object>> v = state.get(k + "_lineage");
        Map<String, String> at = new LinkedHashMap<>();
        at.put("c0", PSM.VARCHAR());
        at.put("c1", PSM.VARCHAR());
        at.put("c2", PSM.VARCHAR());
        at.put("c3", PSM.VARCHAR());
        ret.add(new CreateTable(k + "_lineage", at, false));
        if (!v.isEmpty()) {
            ret.add(new InsertValues(k + "_lineage", new LinkedList<>(at.keySet()), v));
        }
    }
    for (Node n : sig.nodes) {
        Set<Map<Object, Object>> v = state.get(k + "_" + n.string);
        if (v.isEmpty()) {
            continue;
        }
        ret.add(new InsertValues(k + "_" + n.string, attrs, v));
    }
    for (Edge e : sig.edges) {
        Set<Map<Object, Object>> v = state.get(k + "_" + e.name);
        if (v.isEmpty()) {
            continue;
        }
        ret.add(new InsertValues(k + "_" + e.name, attrs, v));
    }
    for (Attribute<Node> a : sig.attrs) {
        Set<Map<Object, Object>> v = state.get(k + "_" + a.name);
        if (v.isEmpty()) {
            continue;
        }
        ret.add(new InsertValues(k + "_" + a.name, attrs, v));
    }
    return ret;
}
Also used : Node(catdata.fql.decl.Node) SimpleCreateTable(catdata.fql.sql.SimpleCreateTable) CreateTable(catdata.fql.sql.CreateTable) PSM(catdata.fql.sql.PSM) PropPSM(catdata.fql.sql.PropPSM) ExpPSM(catdata.fql.sql.ExpPSM) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) SimpleCreateTable(catdata.fql.sql.SimpleCreateTable) InsertValues(catdata.fql.sql.InsertValues) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Edge(catdata.fql.decl.Edge)

Aggregations

ExpPSM (catdata.fql.sql.ExpPSM)37 PSM (catdata.fql.sql.PSM)37 PropPSM (catdata.fql.sql.PropPSM)37 LinkedList (java.util.LinkedList)36 InsertSQL (catdata.fql.sql.InsertSQL)18 CopyFlower (catdata.fql.sql.CopyFlower)14 Pair (catdata.Pair)12 HashMap (java.util.HashMap)12 LinkedHashMap (java.util.LinkedHashMap)12 Flower (catdata.fql.sql.Flower)9 Times (catdata.fql.decl.InstExp.Times)8 Map (java.util.Map)7 FQLException (catdata.fql.FQLException)6 Arr (catdata.fql.cat.Arr)6 Triple (catdata.Triple)5 Delta (catdata.fql.decl.InstExp.Delta)5 PSMAnd (catdata.fql.sql.PSMAnd)5 SimpleCreateTable (catdata.fql.sql.SimpleCreateTable)5 Exp (catdata.fql.decl.InstExp.Exp)4 FullSigma (catdata.fql.decl.InstExp.FullSigma)4