gnu.trove.map.hash.THashMap Java Examples
The following examples show how to use
gnu.trove.map.hash.THashMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypingInversion.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@Override public <Gen, Sk, X, Y> TransExpSigmaDeltaUnit<Gen, Sk, X, Y> visitTransExpSigmaDeltaUnit(Unit params, AqlTyping exp) { SchExp s1 = new SchExpVar("s1"); SchExp s2 = new SchExpVar("s2"); TyExp t = new TyExpVar("t"); exp.defs.schs.put("s1", t); exp.defs.schs.put("s2", t); MapExp m = new MapExpVar("m"); exp.defs.maps.put("m", new Pair(s2, s1)); exp.defs.tys.put("t", Unit.unit); exp.defs.insts.put("i", s1); InstExp i = new InstExpVar("i"); exp.prog.exps.put("s1", new SchExpEmpty(t)); exp.prog.exps.put("s2", new SchExpEmpty(t)); exp.prog.exps.put("t", new TyExpEmpty()); exp.prog.exps.put("i", new InstExpEmpty(s1)); return new TransExpSigmaDeltaUnit(m, i, new THashMap()); }
Example #2
Source File: ApgInstExp.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected synchronized ApgInstance eval0(AqlEnv env, boolean isCompileTime) { ApgSchema<Object> ts = typeside.eval(env, isCompileTime); Map<Object, Pair<Object, ApgTerm<Object,Object>>> Es0 = new THashMap<>(); for (ApgInstExp w : imports) { ApgInstance x = w.eval(env, isCompileTime); Util.putAllSafely(Es0, x.Es); } for (Entry<String, Pair<String, ApgPreTerm>> eld : Es.entrySet()) { Pair<Object, ApgTerm<Object,Object>> p = new Pair<>(eld.getValue().first,eval0(eld.getValue().second, ts, ts.schema.get(eld.getValue().first), Es0)); Es0.put(eld.getKey(), p); } return new ApgInstance<>(ts, Es0); }
Example #3
Source File: Query.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
public static <Ty, En, Sym, Fk, Att> Query<Ty, En, Sym, Fk, Att, En, Fk, Att> id(AqlOptions options, Schema<Ty, En, Sym, Fk, Att> S, Schema<Ty, En, Sym, Fk, Att> T) { Var v = Var.Var("v"); Map<En, Triple<Map<Var, Chc<En, Ty>>, Collection<Eq<Ty, En, Sym, Fk, Att, Var, Var>>, AqlOptions>> ens0 = new THashMap<>(); Map<Att,Chc<Term<Ty, En, Sym, Fk, Att, Var, Var>,Agg<Ty, En, Sym, Fk, Att>>> atts0 = new THashMap<>(); Map<Fk, Pair<Map<Var, Term<Void, En, Void, Fk, Void, Var, Void>>, AqlOptions>> fks0 = new THashMap<>(); Map<Fk, Map<Var, Term<Ty, En, Sym, Fk, Att, Var, Var>>> sks0 = new THashMap<>(); for (En en : S.ens) { Map<Var, Chc<En, Ty>> from = new THashMap<>(); from.put(v, Chc.inLeft(en)); ens0.put(en, new Triple<>(from, (Collections.emptyList()), options)); for (Att att : S.attsFrom(en)) { atts0.put(att, Chc.inLeft(Term.Att(att, Term.Gen(v)))); } for (Fk fk : S.fksFrom(en)) { Map<Var, Term<Void, En, Void, Fk, Void, Var, Void>> h = new THashMap<>(); h.put(v, Term.Fk(fk, Term.Gen(v))); fks0.put(fk, new Pair<>(h, options)); sks0.put(fk, new THashMap<>()); } } return new Query<>(new THashMap<>(), new THashMap<>(), ens0, atts0, fks0, sks0, S, T, options); }
Example #4
Source File: Query.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings("hiding") public static <Ty, En, Sym, Fk, Att> Term<Ty, En, Sym, Fk, Att, Var, Var> freeze( Term<Ty, En, Sym, Fk, Att, Var, Var> term, Map<String, String> params, Set<Var> tyvars) { Map<Var, Term<Ty, En, Sym, Fk, Att, Var, Var>> m = new THashMap<>(); for (Var v : term.vars()) { if (params.keySet().contains(v.var) || tyvars.contains(v)) { m.put(v, Term.Sk(v)); } else { m.put(v, Term.Gen(v)); } } Term<Ty, En, Sym, Fk, Att, Var, Var> ret = term.subst(m); return ret; }
Example #5
Source File: Query.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
public static <Ty, En, Sym, Fk, Att> Term<Ty, En, Sym, Fk, Att, Var, Var> freezeAgg( Term<Ty, En, Sym, Fk, Att, Var, Var> term, Map<String, String> params, Set<Var> tyvars, String a, String b) { Map<Var, Term<Ty, En, Sym, Fk, Att, Var, Var>> m = new THashMap<>(); for (Var v : term.vars()) { if (v.var.equals(a) || v.var.equals(b)) { return term; } else if (params.keySet().contains(v.var) || tyvars.contains(v)) { m.put(v, Term.Sk(v)); } else { m.put(v, Term.Gen(v)); } } Term<Ty, En, Sym, Fk, Att, Var, Var> ret = term.subst(m); return ret; }
Example #6
Source File: SqlInstance.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
public Map<SqlColumn, Optional<Object>> follow(Map<SqlColumn, Optional<Object>> row, SqlForeignKey fk) { Map<SqlColumn, Optional<Object>> cand = new THashMap<>(); for (SqlColumn tcol : fk.target.pk) { SqlColumn scol = fk.map.get(tcol); cand.put(tcol, row.get(scol)); } Map<SqlColumn, Optional<Object>> ret = null; for (Map<SqlColumn, Optional<Object>> tuple : get(fk.target)) { for (SqlColumn col : fk.target.pk) { if (cand.get(col).equals(tuple.get(col))) { if (ret != null) { throw new RuntimeException(); } ret = tuple; } } } if (ret == null) { throw new RuntimeException(); } return ret; }
Example #7
Source File: Frozen.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private Map<Pair<Var, Var>, Float> estimateSelectivities() { Map<Pair<Var, Var>, Float> ret = new THashMap<>(); gens().keySet((v1) -> { gens().keySet((v2) -> { ret.put(new Pair<>(v1, v2), 1f); }); }); for (Pair<Term<Ty, En1, Sym, Fk1, Att1, Var, Var>, Term<Ty, En1, Sym, Fk1, Att1, Var, Var>> eq : eqs) { Set<Var> l = new THashSet<>(); Set<Var> r = new THashSet<>(); eq.first.gens(l); eq.second.gens(r); for (Var v : l) { for (Var u : r) { ret.put(new Pair<>(v, u), ret.get(new Pair<>(v, u)) * .5f); ret.put(new Pair<>(u, v), ret.get(new Pair<>(u, v)) * .5f); } } } return ret; }
Example #8
Source File: InstExpCsv.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@Override protected Map<En, List<String[]>> start(Schema<Ty, En, Sym, Fk, Att> sch) throws Exception { Map<String, Reader> m = new THashMap<>(); Boolean b = (Boolean) op.getOrDefault(AqlOption.csv_prepend_entity); for (En en : sch.ens) { String x = f + op.getOrDefault(AqlOption.csv_import_prefix) + "/" + en.toString() + "." + op.getOrDefault(AqlOption.csv_file_extension); InputStream is = makeURL(x); try { Reader r = new InputStreamReader(is); m.put(en.str, r); } catch (Exception ex) { ex.printStackTrace(); if (!(boolean) op.getOrDefault(AqlOption.import_missing_is_empty)) { throw new RuntimeException( "Missing: " + x + ". \n\nPossible options to consider: " + AqlOption.import_missing_is_empty + " and " + AqlOption.csv_import_prefix + " and " + AqlOption.csv_file_extension); } } } return start2(m, op, sch, false); }
Example #9
Source File: TalgSimplifier.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
public Step(Step s) { this.in = s.out; out = new TAlg<>(new THashMap<>(), new THashSet<>()); out.sks.putAll(this.in.sks); if (!talg_h1()) { changed = false; out = in; return; } changed = true; Iterator<Pair<Term<Ty, Void, Sym, Void, Void, Void, Chc<Sk, Pair<X, Att>>>,Term<Ty, Void, Sym, Void, Void, Void, Chc<Sk, Pair<X, Att>>>>> it = new Util.FilterTransfomIterator<>(in.eqs.iterator(), this::fn); while (it.hasNext()) { out.eqs.add(it.next()); } }
Example #10
Source File: JsPragma.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@Override public void execute() { List<String> ret = new LinkedList<>(); String e = (String) options.getOrDefault(AqlOption.js_env_name); Map<String, Object> m = new THashMap<>(); m.put(e, env); for (String js : jss) { try { @SuppressWarnings("deprecation") Object o = AqlJs.exec(js, m); ret.add(js + (o == null ? "" : " : " + o)); } catch (Exception ex) { ex.printStackTrace(); ret.add(js + " : " + ex.getMessage()); } } responses.add(Util.sep(ret, "\n")); }
Example #11
Source File: FilterAlgebra.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
public Map<En, Set<X>> getUnsatisfying() { Map<En, Set<X>> ret = new THashMap<>(); for (En en : schema.ens) { ret.put(en, new THashSet<>(I.algebra().size(en))); } for (Triple<Pair<Var, En>, Term<Ty, En, Sym, Fk, Att, Void, Void>, Term<Ty, En, Sym, Fk, Att, Void, Void>> eq : schema().eqs) { for (X x : I.algebra().en(eq.first.second)) { Term<Void, En, Void, Fk, Void, Gen, Void> xx = I.algebra().repr(eq.first.second, x); Map m = Collections.singletonMap(eq.first.first, xx); Term<Ty, En, Sym, Fk, Att, Gen, Sk> lhs = eq.second.subst(m); Term<Ty, En, Sym, Fk, Att, Gen, Sk> rhs = eq.third.subst(m); if (!I.dp().eq(null, lhs, rhs)) { ret.get(eq.first.second).add(x); } } } return ret; }
Example #12
Source File: LPOUKB.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private static <T, C, V> Pair<Map<V, KBExp<C, V>>, Map<V, KBExp<C, V>>> freshenMap(KBTheory<T, C, V> kb, Iterator<V> fresh, Pair<KBExp<C, V>, KBExp<C, V>> eq) { Set<V> vars = (new THashSet<>()); KBExp<C, V> lhs = eq.first; KBExp<C, V> rhs = eq.second; lhs.vars(vars); rhs.vars(vars); // vars.addAll(lhs.vars()); // vars.addAll(rhs.vars()); Map<V, KBExp<C, V>> subst = (new THashMap<>()); // Map<V, KBExp<C, V>> subst_inv = new THashMap<>(); for (V v : vars) { V fr = fresh.next(); subst.put(v, kb.factory.KBVar(fr)); // subst_inv.put(fr, kb.factory.KBVar(v)); } return new Pair<>(subst, null /* subst_inv */); }
Example #13
Source File: AqlTester.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private static Map<String, Throwable> runMany(Map<String, String> progs) { Map<String, Throwable> result = new THashMap<>(); // int i = 0; for (String k : Util.alphabetical(progs.keySet())) { try { System.out.println(k); Program<Exp<?>> prog = AqlParserFactory.getParser().parseProgram(progs.get(k)); AqlMultiDriver driver = new AqlMultiDriver(prog, null); driver.start(); // blocks AqlEnv env = driver.env; if (env.exn != null) { result.put(k, env.exn); } // Thread.sleep(3000); } catch (Throwable ex) { ex.printStackTrace(); result.put(k, ex); } } return result; }
Example #14
Source File: TypingInversion.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@Override public <Gen1, Sk1, Gen2, Sk2, X1, Y1, X2, Y2> TransExpPi<Gen1, Sk1, Gen2, Sk2, X1, Y1, X2, Y2> visitTransExpPi( Unit params, AqlTyping exp) { SchExp s1 = new SchExpVar("s1"); SchExp s2 = new SchExpVar("s2"); TyExp t = new TyExpVar("t"); InstExp j = new InstExpVar("j"); exp.defs.schs.put("s1", t); exp.defs.schs.put("s2", t); MapExp m = new MapExpVar("m"); exp.defs.maps.put("m", new Pair(s1, s2)); exp.defs.tys.put("t", Unit.unit); exp.defs.insts.put("i", s1); exp.defs.insts.put("j", s1); InstExp i = new InstExpVar("i"); TransExp<Object, Object, Object, Object, Object, Object, Object, Object> h = new TransExpVar("h"); exp.defs.trans.put("h", new Pair(i, j)); exp.prog.exps.put("s1", new SchExpEmpty(t)); exp.prog.exps.put("s2", new SchExpEmpty(t)); exp.prog.exps.put("t", new TyExpEmpty()); exp.prog.exps.put("i", new InstExpEmpty(s1)); exp.prog.exps.put("j", new InstExpEmpty(s2)); return new TransExpPi(m, h, new THashMap(), new THashMap()); }
Example #15
Source File: LPOUKB.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private Quad<Map<V, KBExp<C, V>>, Map<V, KBExp<C, V>>, Map<V, V>, Map<V, V>> freshenMap(Iterator<V> fresh, Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>> eq) { Set<V> vars = new THashSet<>(); KBExp<C, V> lhs = eq.first; KBExp<C, V> rhs = eq.second; vars.addAll(lhs.getVars()); vars.addAll(rhs.getVars()); Map<V, KBExp<C, V>> subst = (new THashMap<>()); Map<V, KBExp<C, V>> subst_inv = (new THashMap<>()); Map<V, V> subst1 = (new THashMap<>()); Map<V, V> subst_inv1 = (new THashMap<>()); for (V v : vars) { V fr = fresh.next(); subst.put(v, kb.factory.KBVar(fr)); subst_inv.put(fr, kb.factory.KBVar(v)); subst1.put(v, fr); subst_inv1.put(fr, v); } return new Quad<>(subst, subst_inv, subst1, subst_inv1); }
Example #16
Source File: TypingInversion.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@Override public <Gen, Sk, X, Y> TransExpCoEvalEvalUnit<Gen, Sk, X, Y> visitTransExpCoEvalEvalUnit(Unit params, AqlTyping exp) { SchExp s1 = new SchExpVar("s1"); SchExp s2 = new SchExpVar("s2"); TyExp t = new TyExpVar("t"); exp.defs.schs.put("s1", t); exp.defs.schs.put("s2", t); QueryExp q = new QueryExpVar("q"); exp.defs.qs.put("q", new Pair(s2, s1)); exp.defs.tys.put("t", Unit.unit); exp.defs.insts.put("i", s1); InstExp i = new InstExpVar("i"); exp.prog.exps.put("s1", new SchExpEmpty(t)); exp.prog.exps.put("s2", new SchExpEmpty(t)); exp.prog.exps.put("t", new TyExpEmpty()); exp.prog.exps.put("i", new InstExpEmpty(s1)); return new TransExpCoEvalEvalUnit(q, i, new THashMap()); }
Example #17
Source File: TypingInversion.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
@Override public <Gen, Sk, X, Y> TransExpSigmaDeltaCounit<Gen, Sk, X, Y> visitTransExpSigmaDeltaCounit(Unit params, AqlTyping exp) { SchExp s1 = new SchExpVar("s1"); SchExp s2 = new SchExpVar("s2"); TyExp t = new TyExpVar("t"); exp.defs.schs.put("s1", t); exp.defs.schs.put("s2", t); MapExp m = new MapExpVar("m"); exp.defs.maps.put("m", new Pair(s1, s2)); exp.defs.tys.put("t", Unit.unit); exp.defs.insts.put("i", s1); InstExp i = new InstExpVar("i"); exp.prog.exps.put("s1", new SchExpEmpty(t)); exp.prog.exps.put("s2", new SchExpEmpty(t)); exp.prog.exps.put("t", new TyExpEmpty()); exp.prog.exps.put("i", new InstExpEmpty(s1)); return new TransExpSigmaDeltaCounit(m, i, new THashMap()); }
Example #18
Source File: Util.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public static <K, X, V> Map<K, Chc<X, V>> inRight(Map<K, V> map) { if (map.isEmpty()) { return Collections.emptyMap(); } Map<K, Chc<X, V>> ret = new THashMap<>(map.size()); for (K k : map.keySet()) { ret.put(k, Chc.inRight(map.get(k))); } return ret; }
Example #19
Source File: Util.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public static <X, Y> Map<X, Y> convert(Set<Pair<X, Y>> t) { Map<X, Y> ret = new THashMap<>(t.size()); for (Pair<X, Y> p : t) { if (ret.containsKey(p.first)) { throw new RuntimeException("Cannot convert to map (not functional): " + t); } ret.put(p.first, p.second); } return ret; }
Example #20
Source File: Util.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public static <X, Y> Map<Y, Set<X>> revS(Map<X, Y> m) { Map<Y, Set<X>> ret = new THashMap<>(m.size()); for (X x : m.keySet()) { Y y = m.get(x); Set<X> s = ret.computeIfAbsent(y, k -> new THashSet<>()); s.add(x); } return ret; }
Example #21
Source File: Util.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public static <X, Y> Map<X, Y> reify(Function<X, Y> f, Set<X> set) { Map<X, Y> ret = new THashMap<>(set.size()); for (X x : set) { ret.put(x, f.apply(x)); } return ret; }
Example #22
Source File: Util.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public static <X, Y> Map<X, Set<Y>> newSetsFor(Collection<X> xs) { Map<X, Set<Y>> ret = (new THashMap<>(xs.size())); for (X x : xs) { ret.put(x, (new THashSet<>())); } return ret; }
Example #23
Source File: SqlTypeSide.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
private static Map<Ty, String> jps() { Map<Ty, String> m = (new THashMap<>(32)); m.put(Ty.Ty("Longvarbinary"), "return input[0]"); // TODO CQL m.put(Ty.Ty("Varbinary"), "return input[0]"); // TODO CQL m.put(Ty.Ty("Binary"), "return input[0]"); // TODO CQL m.put(Ty.Ty("Clob"), "return input[0]"); m.put(Ty.Ty("Date"), "return input[0]"); // java.sql.Date.valueOf(input[0])"); m.put(Ty.Ty("Time"), "return java.sql.Time.valueOf(input[0])"); m.put(Ty.Ty("Timestamp"), "return java.sql.Timestamp.valueOf(input[0])"); m.put(Ty.Ty("Bigint"), "return new java.lang.Long(input[0])"); m.put(Ty.Ty("Boolean"), "return new java.lang.Boolean(input[0])"); m.put(Ty.Ty("Char"), "return input[0]"); // TODO aql m.put(Ty.Ty("Bit"), "return new java.lang.Boolean(input[0])"); m.put(Ty.Ty("Double"), "return new java.lang.Double(input[0])"); m.put(Ty.Ty("Doubleprecision"), "return new java.lang.Double(input[0])"); m.put(Ty.Ty("Numeric"), "return new java.math.BigDecimal(input[0])"); m.put(Ty.Ty("Decimal"), "return new java.math.BigDecimal(input[0])"); m.put(Ty.Ty("Real"), "return new java.lang.Float(input[0])"); m.put(Ty.Ty("Float"), "return new java.lang.Float(input[0])"); m.put(Ty.Ty("Integer"), "return new java.lang.Integer(input[0])"); m.put(Ty.Ty("Tinyint"), "return new java.lang.Integer(input[0])"); m.put(Ty.Ty("Smallint"), "return new java.lang.Integer(input[0])"); m.put(Ty.Ty("Text"), "return input[0]"); m.put(Ty.Ty("String"), "return input[0]"); m.put(Ty.Ty("Nvarchar"), "return input[0]"); m.put(Ty.Ty("Varchar"), "return input[0]"); m.put(Ty.Ty("Longvarchar"), "return input[0]"); m.put(Ty.Ty("Custom"), "return input[0]"); m.put(Ty.Ty("Other"), "return input[0]"); m.put(Ty.Ty("Blob"), "return input[0]"); return m; }
Example #24
Source File: DMG.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public DMG(Collection<N> nodes, Set<Triple<E, N, N>> edges) { this.nodes = new THashSet<>(nodes); this.edges = new THashMap<>(); for (Triple<E, N, N> e : edges) { if (this.edges.containsKey(e.first)) { throw new RuntimeException("Duplicate element: " + e.first); } this.edges.put(e.first, new Pair<>(e.second, e.third)); } validate(); }
Example #25
Source File: SqlMapping.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public SqlMapping(SqlSchema source, SqlSchema target, String[][] ms) { this.source = source; this.target = target; tm = new THashMap<>(); am = new THashMap<>(); em = new THashMap<>(); for (String[] m : ms) { if (m.length == 0) { throw new RuntimeException("Empty row in " + Arrays.deepToString(ms)); } if (m.length == 1) { throw new RuntimeException("Row of length 1 in " + Arrays.deepToString(ms)); } String x = m[0]; if (source.isTable(x)) { addTM(m); } else if (source.isColumn(x)) { addAM(m); } else if (source.isForeignKey(x)) { addEM(m); } else { throw new RuntimeException(x + " is not a table, column, or foreign key"); } } validate(); }
Example #26
Source File: TyExpRaw.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
static Map<String, Chc<Ty, En>> yyy(List<Pair<String, String>> l) { Map<String, Chc<Ty, En>> ret = (new THashMap<>(l.size())); for (Pair<String, String> p : l) { if (ret.containsKey(p.first)) { throw new RuntimeException("Duplicate bound variable: " + p.first); } Chc<Ty, En> x = p.second == null ? null : Chc.inLeft(Ty.Ty(p.second)); ret.put(p.first, x); } return ret; }
Example #27
Source File: LPOUKB.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
private void initAC() { if (!options.semantic_ac) { return; } AC_symbols = new THashMap<>(); outer: for (C f : kb.syms.keySet()) { if (kb.syms.get(f).first.size() != 2) { continue; } T t1 = kb.syms.get(f).first.get(0); T t2 = kb.syms.get(f).first.get(1); T t3 = kb.syms.get(f).second; if (!(t1.equals(t2) && t2.equals(t3))) { continue; } boolean cand1_found = false; boolean cand2_found = false; List<Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>>> cands = AC_E(f); Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>> cand1 = cands.get(0); Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>> cand2 = cands.get(1); for (Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>> other : E) { if (subsumes(cand1, other) || subsumes(cand1, other.reverse12())) { cand1_found = true; } if (subsumes(cand2, other) || subsumes(cand2, other.reverse12())) { cand2_found = true; } if (cand1_found && cand2_found) { List<Triple<KBExp<C, V>, KBExp<C, V>, Map<V, T>>> l = Collections .synchronizedList(new LinkedList<>()); l.add(AC_E(f).get(1)); // assoc rewrite rule l.add(AC_E(f).get(0)); // comm eq l.addAll(AC_E0(f)); // perm eqs AC_symbols.put(f, l); continue outer; } } } }
Example #28
Source File: GraphExp.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
@Override public synchronized Graph<String, String> resolve(Program<Exp<?>> G) { Set<String> nodes = (new THashSet<>(this.nodes)); Map<String, Pair<String, String>> edges = (new THashMap<>(this.edges)); for (GraphExp s : imports) { Graph<String, String> g = s.resolve(G); nodes.addAll(g.dmg.nodes); edges.putAll(g.dmg.edges); } return new Graph<>(new DMG<>(nodes, edges)); }
Example #29
Source File: Fk.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
public synchronized static Fk Fk(En en, String str) { Map<String, Fk> m = SchExpRaw.fkCache.get(en); if (m == null) { m = new THashMap<>(); SchExpRaw.fkCache.put(en, m); } Fk fk = m.get(str); if (fk != null) { return fk; } fk = new Fk(en, str); m.put(str, fk); return fk; }
Example #30
Source File: TransExpFrozen.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
@Override public Transform<Ty, En, Sym, Fk, Att, Var, Var, Var, Var, ID, Chc<Var, Pair<ID, Att>>, ID, Chc<Var, Pair<ID, Att>>> eval0( AqlEnv env, boolean isC) { Query<Ty, En, Sym, Fk, Att, En, Fk, Att> q = Q.eval(env, isC); if (isC) { throw new IgnoreException(); } Map<String, Chc<Ty, En>> Map = new THashMap<>(); Map.put(var, Chc.inRight(En.En(src))); Chc<Ty, En> expected; if (!q.tys.keySet().contains(Ty.Ty(dst))) { expected = Chc.inRight(En.En(dst)); } else { expected = Chc.inLeft(Ty.Ty(dst)); } Collage<Ty, En, Sym, Fk, Att, Gen, Sk> col = new CCollage<>(q.dst.collage()); AqlJs<Ty, Sym> js = q.src.typeSide.js; Quad<Map<catdata.aql.Var, Chc<Ty, En>>, Term<Ty, En, Sym, Fk, Att, Gen, Sk>, Term<Ty, En, Sym, Fk, Att, Gen, Sk>, Chc<Ty, En>> result = RawTerm .infer1x(Map, term, term, expected, col, "", js); if (expected.left) { return q.composeT(result.second.convert(), En.En(src)); } return q.compose(q.transP(result.second.convert()), En.En(src)); }