use of catdata.fql.sql.PropPSM 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;
}
use of catdata.fql.sql.PropPSM in project fql by CategoricalData.
the class InstOps method visit.
@Override
public Pair<List<PSM>, Object> visit(String dst, Two e) {
List<PSM> ret = new LinkedList<>();
ret.add(new PropPSM(dst, e.sig.toSig(prog)));
return new Pair<>(ret, new Object());
}
Aggregations