use of catdata.fql.sql.InsertValues in project fql by CategoricalData.
the class InstOps method visit.
@Override
public List<PSM> visit(String dst, TransExp.Const e) {
List<PSM> ret = new LinkedList<>();
Signature s = prog.insts.get(e.src).type(prog).toConst(prog).toSig(prog);
List<String> attrs = new LinkedList<>();
attrs.add("c0");
attrs.add("c1");
ret.addAll(PSMGen.makeTables("pre_" + dst, s, false));
for (Node k : s.nodes) {
Set<Map<Object, Object>> values = convert(lookup(k.string, e.objs));
if (!values.isEmpty()) {
ret.add(new InsertValues("pre_" + dst + "_" + k.string, attrs, values));
}
SQL f = PSMGen.compose(e.src + "_" + k.string + "_subst_inv", "pre_" + dst + "_" + k.string, e.dst + "_" + k.string + "_subst");
ret.add(new InsertSQL(dst + "_" + k.string, f, "c0", "c1"));
}
ret.addAll(PSMGen.dropTables("pre_" + dst, s));
return ret;
}
use of catdata.fql.sql.InsertValues 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