Search in sources :

Example 81 with Tuple3

use of org.jparsec.functors.Tuple3 in project fql by CategoricalData.

the class XParser method toMapping.

private static XMapConst toMapping(Object decl) {
    Tuple5 y = (Tuple5) decl;
    org.jparsec.functors.Pair x = (org.jparsec.functors.Pair) y.a;
    Tuple3 nodes = (Tuple3) x.a;
    Tuple3 arrows = (Tuple3) x.b;
    List nodes0 = (List) nodes.b;
    List arrows0 = (List) arrows.b;
    List<Pair<String, String>> nodesX = new LinkedList<>();
    for (Object o : nodes0) {
        Tuple3 u = (Tuple3) o;
        String n = (String) u.a;
        String l = (String) u.c;
        nodesX.add(new Pair<>(n, l));
    }
    List<Pair<String, List<String>>> eqsX = new LinkedList<>();
    for (Object o : arrows0) {
        Tuple3 u = (Tuple3) o;
        String n = (String) u.a;
        List<String> m = (List<String>) u.c;
        eqsX.add(new Pair<>(n, m));
    }
    XMapConst ret = new XMapConst(toExp(y.c), toExp(y.e), nodesX, eqsX);
    return ret;
}
Also used : LinkedList(java.util.LinkedList) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) List(java.util.List) LinkedList(java.util.LinkedList) Pair(catdata.Pair) XPair(catdata.fpql.XExp.XPair) XMapConst(catdata.fpql.XExp.XMapConst)

Example 82 with Tuple3

use of org.jparsec.functors.Tuple3 in project fql by CategoricalData.

the class RaToFql method toEInsertValues.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static EInsertValues toEInsertValues(Object decl) {
    Tuple5 t = (Tuple5) decl;
    String target = t.b.toString();
    List<Tuple3> x = (List<Tuple3>) t.d;
    List<List<String>> values = new LinkedList<>();
    for (Tuple3 y : x) {
        List<String> l = (List<String>) y.b;
        values.add(l);
    }
    return new EInsertValues(target, values);
}
Also used : Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3)

Example 83 with Tuple3

use of org.jparsec.functors.Tuple3 in project fql by CategoricalData.

the class RaToFql method toEd.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static EED toEd(Object decl) {
    Map<String, String> from1 = new LinkedHashMap<>();
    Map<String, String> from2 = new LinkedHashMap<>();
    List<Pair<Pair<String, String>, Pair<String, String>>> where1 = new LinkedList<>();
    List<Pair<Pair<String, String>, Pair<String, String>>> where2 = new LinkedList<>();
    Tuple4 o = (Tuple4) decl;
    org.jparsec.functors.Pair from10 = (org.jparsec.functors.Pair) o.a;
    org.jparsec.functors.Pair where10 = (org.jparsec.functors.Pair) o.b;
    org.jparsec.functors.Pair from11 = (org.jparsec.functors.Pair) o.c;
    org.jparsec.functors.Pair where11 = (org.jparsec.functors.Pair) o.d;
    List<Tuple3> from10x = (List<Tuple3>) from10.b;
    for (Tuple3 k : from10x) {
        from1.put(k.c.toString(), k.a.toString());
    }
    List<Tuple3> where10x = (List<Tuple3>) where10.b;
    for (Tuple3 k : where10x) {
        Tuple3 l = (Tuple3) k.a;
        Tuple3 r = (Tuple3) k.c;
        where1.add(new Pair<>(new Pair<>(l.a.toString(), l.c.toString()), new Pair<>(r.a.toString(), r.c.toString())));
    }
    List<Tuple3> from11x = (List<Tuple3>) from11.b;
    for (Tuple3 k : from11x) {
        from2.put(k.c.toString(), k.a.toString());
    }
    List<Tuple3> where11x = (List<Tuple3>) where11.b;
    for (Tuple3 k : where11x) {
        Tuple3 l = (Tuple3) k.a;
        Tuple3 r = (Tuple3) k.c;
        where2.add(new Pair<>(new Pair<>(l.a.toString(), l.c.toString()), new Pair<>(r.a.toString(), r.c.toString())));
    }
    return new EED(from1, from2, where1, where2);
}
Also used : Tuple4(org.jparsec.functors.Tuple4) Tuple3(org.jparsec.functors.Tuple3) Pair(catdata.Pair)

Example 84 with Tuple3

use of org.jparsec.functors.Tuple3 in project fql by CategoricalData.

the class SqlToFql method toEInsertValues.

@SuppressWarnings({ "rawtypes", "unchecked" })
private static EInsertValues toEInsertValues(Object decl) {
    Tuple5 t = (Tuple5) decl;
    String target = t.b.toString();
    List<Tuple3> x = (List<Tuple3>) t.d;
    List<List<String>> values = new LinkedList<>();
    for (Tuple3 y : x) {
        List<String> l = (List<String>) y.b;
        values.add(l);
    }
    return new EInsertValues(target, values);
}
Also used : Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 85 with Tuple3

use of org.jparsec.functors.Tuple3 in project fql by CategoricalData.

the class SqlToFql method toECreateTable.

@SuppressWarnings("rawtypes")
private static ECreateTable toECreateTable(Object decl) {
    Tuple4 t = (Tuple4) decl;
    String name = t.c.toString();
    Tuple3 t0 = (Tuple3) t.d;
    List t1 = (List) t0.b;
    List<Pair<String, String>> types = new LinkedList<>();
    List<Pair<String, String>> fks = new LinkedList<>();
    for (Object o : t1) {
        org.jparsec.functors.Pair p = (org.jparsec.functors.Pair) o;
        if (p.a.toString().equals("FOREIGN")) {
            Tuple5 x = (Tuple5) o;
            Tuple3 y = (Tuple3) x.b;
            fks.add(new Pair<>(y.b.toString(), x.d.toString()));
        } else {
            types.add(new Pair<>(p.a.toString(), p.b.toString()));
        }
    }
    return new ECreateTable(name, types, fks);
}
Also used : LinkedList(java.util.LinkedList) Tuple4(org.jparsec.functors.Tuple4) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) LinkedList(java.util.LinkedList) List(java.util.List) Pair(catdata.Pair)

Aggregations

Tuple3 (org.jparsec.functors.Tuple3)90 Pair (catdata.Pair)69 List (java.util.List)57 LinkedList (java.util.LinkedList)56 Tuple5 (org.jparsec.functors.Tuple5)41 HashMap (java.util.HashMap)33 Tuple4 (org.jparsec.functors.Tuple4)32 LinkedHashMap (java.util.LinkedHashMap)17 Triple (catdata.Triple)15 HashSet (java.util.HashSet)15 XPair (catdata.fpql.XExp.XPair)11 Map (java.util.Map)10 Set (java.util.Set)6 Chc (catdata.Chc)5 Var (catdata.fqlpp.FunctorExp.Var)5 Program (catdata.Program)4 Const (catdata.fql.decl.SigExp.Const)4 Plus (catdata.fqlpp.CatExp.Plus)4 Apply (catdata.fqlpp.FunctorExp.Apply)4 Zero (catdata.fqlpp.FunctorExp.Zero)4