use of catdata.fql.sql.PSM in project fql by CategoricalData.
the class InstOps method visit.
@Override
public List<PSM> visit(String env, TransIso e) {
List<PSM> ret = new LinkedList<>();
Signature sig = prog.insts.get(e.l).type(prog).toSig(prog);
ret.add(new PSMIso(e.lToR, env, e.l, e.r, sig));
return ret;
}
use of catdata.fql.sql.PSM in project fql by CategoricalData.
the class InstOps method visit.
@Override
public List<PSM> visit(String env, Or e) {
List<PSM> ret = new LinkedList<>();
Times pr = (Times) prog.insts.get(e.prop);
Signature sig = pr.type(prog).toSig(prog);
ret.add(new PSMAnd(sig, env, e.prop, pr.a, "or"));
return ret;
}
use of catdata.fql.sql.PSM in project fql by CategoricalData.
the class InstOps method visit.
@Override
public List<PSM> visit(String dst, TransExp.FullSigma e) {
List<PSM> ret = new LinkedList<>();
Mapping F0 = ((FullSigma) prog.insts.get(e.src)).F.toMap(prog);
Pair<String, String> t = prog.transforms.get(e.h).type(prog);
// String next = next();
// ret.addAll(PSMGen.makeTables(next, F0.source, false));
// ret.addAll(e.h.accept(next, this));
ret.add(new FullSigmaTrans(F0, t.first, e.src, t.second, e.dst, e.h, dst));
return ret;
}
use of catdata.fql.sql.PSM 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;
}
use of catdata.fql.sql.PSM in project fql by CategoricalData.
the class InstOps method visit.
@Override
public List<PSM> visit(String env, Not e) {
List<PSM> ret = new LinkedList<>();
InstExp p = prog.insts.get(e.prop);
Signature sig = p.type(prog).toSig(prog);
ret.add(new PSMNot(sig, env, e.prop));
return ret;
}
Aggregations