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;
}
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;
}
Aggregations