Search in sources :

Example 1 with Agg

use of catdata.opl.OplQuery.Agg in project fql by CategoricalData.

the class OplParser method fromAgg.

@SuppressWarnings("unused")
private static Agg<String, String, String, String, String, String> fromAgg(Collection vars, Collection consts, Object o, boolean suppressError) {
    Tuple5<Tuple4<?, String, String, ?>, List<Tuple3<String, ?, String>>, List<Tuple3<?, ?, ?>>, org.jparsec.functors.Pair<?, ?>, ?> t = (Tuple5<Tuple4<?, String, String, ?>, List<Tuple3<String, ?, String>>, List<Tuple3<?, ?, ?>>, org.jparsec.functors.Pair<?, ?>, ?>) o;
    LinkedHashMap<String, String> from = new LinkedHashMap<>();
    Set<Pair<OplTerm<String, String>, OplTerm<String, String>>> where = new HashSet<>();
    for (Object x : t.b) {
        Tuple3 l = (Tuple3) x;
        if (from.containsKey(l.a.toString())) {
            throw new RuntimeException("Duplicate for: " + l.a);
        }
        from.put(l.a.toString(), l.c.toString());
    }
    Set<String> allVars = new HashSet<>();
    allVars.addAll(vars);
    allVars.addAll(from.keySet());
    for (Object x : t.c) {
        Tuple3 l = (Tuple3) x;
        where.add(new Pair(toTerm(allVars, null, l.a, true), toTerm(allVars, null, l.c, true)));
    }
    OplTerm<String, String> att = toTerm(allVars, null, t.d.b, true);
    return new Agg<>(t.a.b, t.a.c, from, where, att);
}
Also used : Agg(catdata.opl.OplQuery.Agg) LinkedHashMap(java.util.LinkedHashMap) Tuple4(org.jparsec.functors.Tuple4) Tuple5(org.jparsec.functors.Tuple5) Tuple3(org.jparsec.functors.Tuple3) List(java.util.List) LinkedList(java.util.LinkedList) Pair(catdata.Pair) HashSet(java.util.HashSet)

Aggregations

Pair (catdata.Pair)1 Agg (catdata.opl.OplQuery.Agg)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Tuple3 (org.jparsec.functors.Tuple3)1 Tuple4 (org.jparsec.functors.Tuple4)1 Tuple5 (org.jparsec.functors.Tuple5)1