Commit 29bdef17 authored by Ryan Wisnesky's avatar Ryan Wisnesky
Browse files

fixes in preparation for Mexico

parent e85fc22d
Loading
Loading
Loading
Loading
+1 −1
Changes for doc/aqlmanual/aqlmanual.tex: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ On some systems, especially windows systems, the colon in the classpath may need

The AQL IDE also supports command-line execution: an AQL program is passed to stdin, and an HTML view of the result is output on stdout:
\begin{verbatim}
java -cp "./aql.jar" catdata.aql.exp.AqlInACan.openCan
java -cp "./aql.jar" catdata.aql.exp.AqlInACan
\end{verbatim}

\section{HTML markup}
+1 −1
Changes for resources/cdide.properties: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -2,4 +2,4 @@ Name=Categorical Data IDE
Copyright=Patrick Schultz, David Spivak, and Ryan Wisnesky
URL=categoricaldata.net/aql.html
Version=alpha-snapshot
Packaged=January 19, 2018 or later
Packaged=August 9, 2018 or later
+10 −10
Changes for resources/examples/aql/Tutorial TSP.aql: 10 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -1039,7 +1039,7 @@ are listed using the `pShwTbls` pragma.
First clean out the target tables if present from a previous run.
" *) }
command pCleanUp = exec_jdbc "com.mysql.jdbc.Driver"
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" {
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC&serverTimezone=UTC" {
"DROP TABLE IF EXISTS sts_SkillNdFrTask"
"DROP TABLE IF EXISTS sts_Skill"
"DROP TABLE IF EXISTS sts_SkillClass"
@@ -1051,14 +1051,14 @@ Export the results of the above construction of the span and its representative
can be overridden using the varchar_length option.
" *) }
command eSTS = export_jdbc_instance iSTSpn "com.mysql.jdbc.Driver"
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" "sts_"
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" "sts_"
  { options varchar_length = 256 }

md { (* "
Display the contents of the `ci_test` schema in MySQL.
" *) }
command pShwTbls = exec_jdbc "com.mysql.jdbc.Driver"
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" {
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" {
"SHOW  TABLES"}
 
md { (* "
@@ -1070,7 +1070,7 @@ for this import but will return to import options in a later example. The import
a complete specification of all foreign key and attribute columns.
" *) }
instance iSTSpnImp = import_jdbc "com.mysql.jdbc.Driver"
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" : sSTSpn {
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" : sSTSpn {
   Skill -> "select id, fk_HasClass, SName, SCNameOnSkl from sts_Skill"
   SkillClass -> "select id, SCName from sts_SkillClass"
   Task -> "select id, TName from sts_Task"
@@ -1118,7 +1118,7 @@ We have already set up a set of tables and associated instance in our source RDB
that instance using a command analogous to the `iSTSpnImp` imported instance.
" *) }
instance iSPSpnImp = import_jdbc "com.mysql.jdbc.Driver"
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" : sSPSpn {
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" : sSPSpn {
   SpecificSkill -> "select id, fk_IsType, SSName, SSGSName, SSSCName from sps_SpecificSkill"
   GeneralSkill -> "select id, fk_HasClass, GSName, GSSCName from sps_GeneralSkill"
   SkillClass -> "select id, SCName from sps_SkillClass"
@@ -1252,7 +1252,7 @@ e.g. skill classification in this case.

// Set up the SkillMatch and SkillClassMatch tables based on the exports.
command pSetUpSkillMatch = exec_jdbc "com.mysql.jdbc.Driver"
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" {
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" {
"DROP TABLE IF EXISTS SkillMatch"
"DROP TABLE IF EXISTS SkillClassMatch"

@@ -1294,7 +1294,7 @@ to allow us to import an instance that essentially the same as the literal `iSkl
above.
" *) }
instance iSkillMatch = import_jdbc "com.mysql.jdbc.Driver"
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" : sSTSpn_SPSpn_CoLim {
"jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" : sSTSpn_SPSpn_CoLim {
    SpecificSkill -> "select * from SkillMatch"
    SkillClass -> "select * from SkillClassMatch"
options
@@ -1309,13 +1309,13 @@ ids. It may be instructive to compare the results of the `iSkillMatch` instance
created to merge skill class Skolem terms with skill class generators and labels.
" *) }
transform tSMToSTSpn = import_jdbc "com.mysql.jdbc.Driver"
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" : iSkillMatch -> iST_SP_Sum {
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" : iSkillMatch -> iST_SP_Sum {
    SpecificSkill -> "select sm_id, ts_id from SkillMatch"
    SkillClass -> "select scm_id, tsc_id from SkillClassMatch"
}

transform tSMToSPSpn = import_jdbc "com.mysql.jdbc.Driver"
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" : iSkillMatch -> iST_SP_Sum {
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" : iSkillMatch -> iST_SP_Sum {
    SpecificSkill -> "select sm_id, ps_id from SkillMatch"
    SkillClass -> "select scm_id, psc_id from SkillClassMatch"
}
@@ -1330,7 +1330,7 @@ It is important to note that this does require the construction of the `SkillMat
`SkillClassMatch` tables in the source RDBMS as a precondition.
" *) }
instance iSTSpn_SPSpn_Merge2 = quotient_jdbc "com.mysql.jdbc.Driver"
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr" iST_SP_Sum { 
    "jdbc:mysql://mysql.catinf.com:3306/ci_test?user=catinfcom&password=FDiUY!pr&serverTimezone=UTC" iST_SP_Sum { 
SpecificSkill->
"select
   ps_id as sp_id,
+43 −19
Changes for src/catdata/aql/Chase.java: 43 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
					ret.ens.get(en).add(n, n);
				}
			}
			// //System.out.println("yyy " + ret);
			//System.out.println("yyy " + ret);

			for (Fk2 fk : F.dst.fks.keySet()) {
				En2 a = F.dst.fks.get(fk).first;
@@ -188,10 +188,10 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
					Lineage<Void, En2, Void, Fk2, Void, Gen, Void> n1 = ufs.get(a).find(x.first);
					Lineage<Void, En2, Void, Fk2, Void, Gen, Void> n2 = ufs.get(b).find(x.second);
					ret.fks.get(fk).add(n1, n2);
					// //System.out.println("on " + fk + " doing " + x + " is " + n1 + "," + n2);
					//System.out.println("on " + fk + " doing " + x + " is " + n1 + "," + n2);
				}
			}
			// //System.out.println("xxx " + ret);
			//System.out.println("xxx " + ret);
			for (En1 en : us.keySet()) {
				for (X x : us.get(en).keySet()) {
					Lineage<Void, En2, Void, Fk2, Void, Gen, Void> n = us.get(en).get(x);
@@ -261,7 +261,7 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
					ret.tys.get(ty).add(n, n);
				}
			}
			// //System.out.println("yyy " + ret);
			//System.out.println("yyy2 " + ret);
			for (Att2 att : F.dst.atts.keySet()) {
				En2 a = F.dst.atts.get(att).first;
				Ty b = F.dst.atts.get(att).second;
@@ -271,17 +271,17 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
					Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> n2 = nf
							.apply(b, x.second);
					ret.atts.get(att).add(n1, n2);
					// //System.out.println("on " + fk + " doing " + x + " is " + n1 + "," + n2);
					// ////System.out.println("on " + fk + " doing " + x + " is " + n1 + "," + n2);
				}
			}
			// //System.out.println("xxx " + ret);
			//System.out.println("xxx2 " + ret);

			/*
			 * for (Ty ty : vs.keySet()) { for (Y x : vs.get(ty).keySet()) { Term<Ty, Void,
			 * Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> n =
			 * vs.get(ty).get(x); ret.vs.get(ty).put(x, nf.apply(ty, n)); } }
			 */
			//System.out.println("merged " + ret);
			////System.out.println("merged " + ret);
			// ret.iso = iso.map((k,x)->new Pair<>(k,x.map(y->ufs.get(k).find(y))));
			return ret;
		}
@@ -339,14 +339,18 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
		this.F = F;
		this.I = I;

		int i = 0;
		T = new Content(I);
		// //System.out.println(T.sizes());
		//System.out.println(T);
		for (;;) {
			boolean changed = step();
			if (!changed) {
				return;
			}
			// //System.out.println(T.sizes());
			//System.out.println(T);
			if (i++ > 2) {
				throw new RuntimeException();
			}
		}

	}
@@ -364,24 +368,29 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
		}
		Boolean[] changed = new Boolean[] { false };

		//System.out.println("A " + changed[0]);
		makeArrowsTotal(toAdd, changed);
		//System.out.println("B " + changed[0]);

		makeObjectsTotal(toAdd, changed);
		//System.out.println("C " + changed[0]);

		moveObjects(toAdd, changed);
		//System.out.println("D " + changed[0]);

		doEqs(toAdd, ufs, ufs2, changed);

		T.addAll(toAdd);
		//System.out.println("E " + changed[0]);

		makeFunctional(ufs, changed, ufs2);	

		T = T.merge(ufs, ufs2);
		
		if (!changed[0]) {
			return false;
		}
		
		T = T.merge(ufs, ufs2);

		return true;
	}

@@ -400,12 +409,12 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {

				for (Lineage<Void, En2, Void, Fk2, Void, Gen, Void> x : T_a.keySet()) {
					Collection<Lineage<Void, En2, Void, Fk2, Void, Gen, Void>> ys = T_a.get(x);
					// //System.out.println("collection is " + ys);
					// ////System.out.println("collection is " + ys);
					Lineage<Void, En2, Void, Fk2, Void, Gen, Void> y1 = Util.get0X(ys);
					for (Lineage<Void, En2, Void, Fk2, Void, Gen, Void> y2 : ys) {
						if (!y1.equals(y2)) {
							ufs.get(w).union(y1, y2);
							// //System.out.println("equating " + y1 + " = " + y2 + " at " + w);
							// ////System.out.println("equating " + y1 + " = " + y2 + " at " + w);

							changed[0] = true;
						}
@@ -422,13 +431,13 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
				for (Lineage<Void, En2, Void, Fk2, Void, Gen, Void> x : T_a.keySet()) {
					Collection<Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>>> ys = T_a
							.get(x);
					// //System.out.println("collection is " + ys);
					// ////System.out.println("collection is " + ys);
					Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> y1 = Util
							.get0X(ys);
					for (Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> y2 : ys) {
						if (!y1.equals(y2)) {
							ufs2.get(w).union(y1, y2);
							//System.out.println("3equating " + y1 + " = " + y2 + " at " + w);
							////System.out.println("3equating " + y1 + " = " + y2 + " at " + w);

							changed[0] = true;
						}
@@ -442,13 +451,22 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
			Ctx<Ty, UnionFind<Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>>>> ufs2,
			Boolean[] changed) {

		//System.out.println("P " + changed[0]);
		targetEqs(toAdd, ufs, changed);

		//System.out.println("Q " + changed[0]);

		collageEqs(toAdd, ufs, changed);

		//System.out.println("R " + changed[0]);

		targetEqsT(toAdd, ufs2, changed);

		//System.out.println("S " + changed[0]);

		collageEqsT(toAdd, ufs2, changed);
		//System.out.println("T " + changed[0]);

	}

	public void collageEqs(Content toAdd, Ctx<En2, UnionFind<Lineage<Void, En2, Void, Fk2, Void, Gen, Void>>> ufs,
@@ -493,7 +511,7 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
	public void collageEqsT(Content toAdd,
			Ctx<Ty, UnionFind<Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>>>> ufs,
			Boolean[] changed) {
		//System.out.println("is " + T);
	//	//System.out.println("is " + T);
		for (Att1 a : F.src.atts.keySet()) {
			En1 v = F.src.atts.get(a).first;
			Ty w = F.src.atts.get(a).second;
@@ -508,6 +526,8 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
				Set<Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>>> N = evalT(
						F.atts.get(a).third, Util.singSet(initial));
				//System.out.println("eval on " + x + " at " + a + " gives " + N + " with a lhs of " + lhs);
				
				
				 if (!N.contains(lhs)) {
					Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> m = populateT(
							toAdd, F.atts.get(a).third, initial);
@@ -516,9 +536,13 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
						changed[0] = true;
						ufs.get(w).union(m, lhs);
						
			//		System.out.println("2equating " + m + " and " + lhs + " at " + w );
						for (Term<Ty, Void, Sym, Void, Void, Void, Chc<Y, Lineage<Ty, En2, Sym, Fk2, Att2, Gen, Sk>>> xx : N) {
							ufs.get(w).union(xx, lhs);				
						}
						
			//		//System.out.println("2equating " + m + " and " + lhs + " at " + w );
				} else {
				//	System.out.println(" contains " + lhs + ", on " + x + " and " + a);
			//		//System.out.println(" contains " + lhs + ", on " + x + " and " + a);
				} 
			}
		}
@@ -594,7 +618,7 @@ public class Chase<Ty, En1, Sym, Fk1, Att1, En2, Fk2, Att2, Gen, Sk, X, Y> {
							toAdd, eq.second, initial), m2 = populateT(toAdd, eq.third, initial);

					ufs.get(dst).union(m, m2);
					//System.out.println("1equating " + m + " and " + m2 + " at " + dst);
					////System.out.println("1equating " + m + " and " + m2 + " at " + dst);
				}
			}
		}
+14 −0
Changes for src/catdata/aql/Schema.java: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -13,9 +13,11 @@ import java.util.stream.Collectors;

import catdata.Chc;
import catdata.Ctx;
import catdata.LineException;
import catdata.Pair;
import catdata.Triple;
import catdata.Util;
import catdata.graph.DAG;

public final class Schema<Ty, En, Sym, Fk, Att> implements Semantics {

@@ -101,6 +103,18 @@ public final class Schema<Ty, En, Sym, Fk, Att> implements Semantics {

	}
	
	public boolean acyclic() {
		DAG<En> dag = new DAG<>();
		for (Fk fk : fks.keySet()) {
			boolean ok = dag.addEdge(fks.get(fk).first, fks.get(fk).second);
			if (!ok) {
				return false;
				//throw new RuntimeException("Adding dependency on " + fk + " causes circularity " + dag);
			}
		}
		return true;
	}

	private String toString(
			Triple<Pair<Var, En>, Term<Ty, En, Sym, Fk, Att, Void, Void>, Term<Ty, En, Sym, Fk, Att, Void, Void>> eq) {
		return "forall " + eq.first.first + ":" + eq.first.second + ", " + eq.second + " = " + eq.third;
Loading