public static boolean contains(ExprList exprList, Expr expr) { boolean result = false; for(Expr item : exprList) { result = item.equals(expr); if(result) { break; } } return result; }
public boolean equals(ExprList other, boolean bySyntax) { if ( this == other ) return true ; if (expressions.size() != other.expressions.size()) return false; for ( int i = 0 ; i < expressions.size() ; i++ ) { Expr e1 = expressions.get(i) ; Expr e2 = other.expressions.get(i) ; if ( ! e1.equals(e2, bySyntax) ) return false ; } return true ; }
public static CartesianProduct<Combination<Expr, Expr, Expr>> match(Set<Expr> cacheConjunction, Set<Expr> queryConjunction) { CartesianProduct<Combination<Expr, Expr, Expr>> result = CartesianProductUtils.createOnDemandCartesianProduct( cacheConjunction, queryConjunction, ExprMatcher::match, x -> x.equals(NodeValue.FALSE)); return result; }
private static void transformSortConditions(List<SortCondition> conditions, ExprTransform exprTransform) { for (int i = 0; i < conditions.size(); i++) { SortCondition s1 = conditions.get(i); Expr e = ExprTransformer.transform(exprTransform, s1.expression); if (e == null || s1.expression.equals(e)) continue; conditions.set(i, new SortCondition(e, s1.direction)); } }
@Override public boolean equals(Aggregator other, boolean bySyntax) { if ( other == null ) return false ; if ( this == other ) return true ; if ( ! ( other instanceof AggCountVar ) ) return false ; AggCountVar agg = (AggCountVar)other ; return agg.getExpr().equals(getExpr(), bySyntax) ; }
@Override public boolean match(Var var, Expr expr, MapResult resultMap) { if ( ! exprMatch.equals(expr) ) throw new NoExprMatch("ActionMatchExact: Do not match: Expected: "+exprMatch+" : Got: "+expr) ; // Assign is anyway : otherwise just write a constant return super.match(var, expr, resultMap) ; } }
@Override public boolean equals(Aggregator other, boolean bySyntax) { if ( other == null ) return false ; if ( this == other ) return true ; if ( ! ( other instanceof AggCountVarDistinct ) ) return false ; AggCountVarDistinct agg = (AggCountVarDistinct)other ; return agg.getExpr().equals(getExpr(), bySyntax) ; }
@Override public boolean equals(Aggregator other, boolean bySyntax) { if ( other == null ) return false ; if ( this == other ) return true ; if ( ! ( other instanceof AggSumDistinct ) ) return false ; AggSumDistinct agg = (AggSumDistinct)other ; return getExpr().equals(agg.getExpr(), bySyntax) ; }
@Override public boolean equals(Aggregator other, boolean bySyntax) { if ( other == null ) return false ; if ( this == other ) return true ; if ( ! ( other instanceof AggSum ) ) return false ; AggSum agg = (AggSum)other ; return getExpr().equals(agg.getExpr(), bySyntax) ; }
public Expr transformHelper(Expr a, Expr b) { // No match found - create a new helper variable if(a.equals(b)) { return a; } Var var = Var.alloc(generator.next()); ExprVar result = new ExprVar(var); mapA.put(var, a); mapB.put(var, b); return result; }
@Override public boolean equals(Aggregator other, boolean bySyntax) { if ( other == null ) return false ; if ( this == other ) return true ; if ( ! ( other instanceof AggGroupConcat ) ) return false ; AggGroupConcat agg = (AggGroupConcat)other ; return Objects.equals(agg.getSeparator(), getSeparator()) && agg.getExpr().equals(getExpr(), bySyntax) ; }
@Override public boolean equals(Aggregator other, boolean bySyntax) { if ( other == null ) return false ; if ( this == other ) return true ; if ( ! ( other instanceof AggGroupConcatDistinct ) ) return false ; AggGroupConcatDistinct agg = (AggGroupConcatDistinct)other ; return Objects.equals(agg.getSeparator(),getSeparator()) && agg.getExpr().equals(getExpr(), bySyntax) ; }
@Override public boolean equalTo(Element el2, NodeIsomorphismMap isoMap) { if ( ! ( el2 instanceof ElementBind ) ) return false ; ElementBind f2 = (ElementBind)el2 ; if ( ! this.getVar().equals(f2.getVar() )) return false ; if ( ! this.getExpr().equals(f2.getExpr()) ) return false ; return true ; }
@Override public boolean equalTo(Element el2, NodeIsomorphismMap isoMap) { if ( ! ( el2 instanceof ElementAssign ) ) return false ; ElementAssign f2 = (ElementAssign)el2 ; if ( ! this.getVar().equals(f2.getVar() )) return false ; if ( ! this.getExpr().equals(f2.getExpr()) ) return false ; return true ; }
public Op toOp(Op result) { if(filter.getExpr().equals(NodeValue.TRUE)) { result = OpFilter.filter(filter.getExpr(), result); } result = OpUtils.applyExtendProject(result, preDistinctVarDefs); if(postDistinctVarDefs != null) { result = OpDistinct.create(result); result = OpUtils.applyExtendProject(result, postDistinctVarDefs); } return result; }
public Op toOp(Op result) { if(filter.getExpr().equals(NodeValue.TRUE)) { result = OpFilter.filter(filter.getExpr(), result); } result = OpUtils.applyExtendProject(result, preDistinctVarDefs); if(postDistinctVarDefs != null) { result = OpDistinct.create(result); result = OpUtils.applyExtendProject(result, postDistinctVarDefs); } return result; }
public Op toOp(Op result) { if(filter.getExpr().equals(NodeValue.TRUE)) { result = OpFilter.filter(filter.getExpr(), result); } result = OpUtils.applyExtendProject(result, preDistinctVarDefs); if(postDistinctVarDefs != null) { result = OpDistinct.create(result); result = OpUtils.applyExtendProject(result, postDistinctVarDefs); } return result; }
public Op toOp(Op result) { if(filter.getExpr().equals(NodeValue.TRUE)) { result = OpFilter.filter(filter.getExpr(), result); } result = OpUtils.applyExtendProject(result, preDistinctVarDefs); if(postDistinctVarDefs != null) { result = OpDistinct.create(result); result = OpUtils.applyExtendProject(result, postDistinctVarDefs); } return result; }
@Test public void test_function_expansion_01() { Expr e = new ExprVar("x"); UserDefinedFunctionFactory.getFactory().add("http://example/simple", e, new ArrayList<>(e.getVarsMentioned())); UserDefinedFunction f = (UserDefinedFunction) UserDefinedFunctionFactory.getFactory().create("http://example/simple"); f.build("http://example/simple", new ExprList(new NodeValueBoolean(true))); Expr actual = f.getActualExpr(); Assert.assertFalse(e.equals(actual)); Assert.assertEquals(0, actual.getVarsMentioned().size()); Assert.assertEquals(new NodeValueBoolean(true), actual); }
@Test public void test_function_expansion_02() { Expr e = new E_Multiply(new ExprVar("x"), new ExprVar("x")); UserDefinedFunctionFactory.getFactory().add("http://example/square", e, new ArrayList<>(e.getVarsMentioned())); UserDefinedFunction f = (UserDefinedFunction) UserDefinedFunctionFactory.getFactory().create("http://example/square"); f.build("http://example/square", new ExprList(new NodeValueInteger(3))); Expr actual = f.getActualExpr(); Assert.assertFalse(e.equals(actual)); Assert.assertEquals(0, actual.getVarsMentioned().size()); Assert.assertEquals(new E_Multiply(new NodeValueInteger(3), new NodeValueInteger(3)), actual); }