@Override protected ItrState itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { return iterate(q.getQuery(),context); }
@Override protected ItrState itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { return iterate(q.getQuery(),context); }
private static boolean isFieldQueried(Path field, UnaryLogicalExpression q, Path context) { return q.getQuery().isRequired(field, context); }
private DBObject translateUnaryLogicalExpression(FieldTreeNode context, UnaryLogicalExpression expr) { List<DBObject> l=new ArrayList<>(1); l.add(translate(context,expr.getQuery())); return new BasicDBObject(UNARY_LOGICAL_OPERATOR_MAP.get(expr.getOp()), l); }
private static boolean isFieldQueried(Path field, UnaryLogicalExpression q, Path context) { return q.getQuery().isRequired(field, context); }
private DBObject translateUnaryLogicalExpression(FieldTreeNode context, EntityMetadata md, UnaryLogicalExpression expr, EntityMetadata emd, MutablePath fullPath) { List<DBObject> l = new ArrayList<>(1); l.add(translate(context, expr.getQuery(), emd, fullPath)); return new BasicDBObject(UNARY_LOGICAL_OPERATOR_MAP.get(expr.getOp()), l); }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new unary logical expression using the new query * expression, and returns that. */ protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { QueryExpression newq = iterate(q.getQuery(), context); if (newq != q.getQuery()) { return new UnaryLogicalExpression(q.getOp(), newq); } else { return q; } }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new unary logical expression using the new query * expression, and returns that. */ protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { QueryExpression newq = iterate(q.getQuery(), context); if (newq != q.getQuery()) { return new UnaryLogicalExpression(q.getOp(), newq); } else { return q; } }
/** * If the enclosed query is a placeholder (TruePH or FalsePH), it * negates the placeholder, otherwise, the query remains as is */ @Override protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { UnaryLogicalExpression nq = (UnaryLogicalExpression) super.itrUnaryLogicalExpression(q, context); if (nq.getQuery() instanceof TruePH) { return new FalsePH(); } else if (nq.getQuery() instanceof FalsePH) { return new TruePH(); } else { return nq; } }
public UnaryLogicalExpressionEvaluator(UnaryLogicalExpression expr, FieldTreeNode context) { evaluator = QueryEvaluator.getInstance(expr.getQuery(), context); operator = expr.getOp(); }
@Override public QueryExpression rewrite(QueryExpression q) { UnaryLogicalExpression le = dyncast(UnaryLogicalExpression.class, q); if (le != null && le.getOp() == UnaryLogicalOperator._not) { UnaryLogicalExpression oreq = dyncast(UnaryLogicalExpression.class, le.getQuery()); if (oreq != null && oreq.getOp() == UnaryLogicalOperator._not) { return oreq.getQuery(); } } return q; } }
public UnaryLogicalExpressionEvaluator(UnaryLogicalExpression expr, FieldTreeNode context) { evaluator = QueryEvaluator.getInstance(expr.getQuery(), context); operator = expr.getOp(); }
public UnaryLogicalExpressionEvaluator(UnaryLogicalExpression expr, FieldTreeNode context) { evaluator = QueryEvaluator.getInstance(expr.getQuery(), context); operator = expr.getOp(); }
/** * If the enclosed query is a placeholder (TruePH or FalsePH), it * negates the placeholder, otherwise, the query remains as is */ @Override protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { UnaryLogicalExpression nq = (UnaryLogicalExpression) super.itrUnaryLogicalExpression(q, context); if (nq.getQuery() instanceof TruePH) { return new FalsePH(); } else if (nq.getQuery() instanceof FalsePH) { return new TruePH(); } else { return nq; } }
@Override public QueryExpression rewrite(QueryExpression q) { UnaryLogicalExpression le = dyncast(UnaryLogicalExpression.class, q); if (le != null && le.getOp() == UnaryLogicalOperator._not) { UnaryLogicalExpression oreq = dyncast(UnaryLogicalExpression.class, le.getQuery()); if (oreq != null && oreq.getOp() == UnaryLogicalOperator._not) { return oreq.getQuery(); } } return q; } }
@Override public QueryExpression rewrite(QueryExpression q) { UnaryLogicalExpression le=dyncast(UnaryLogicalExpression.class,q); if(le!=null&&le.getOp()==UnaryLogicalOperator._not) { UnaryLogicalExpression oreq=dyncast(UnaryLogicalExpression.class,le.getQuery()); if(oreq!=null&&oreq.getOp()==UnaryLogicalOperator._not) { return oreq.getQuery(); } } return q; } }
@Override public QueryExpression rewrite(QueryExpression q) { UnaryLogicalExpression le=dyncast(UnaryLogicalExpression.class,q); if(le!=null&&le.getOp()==UnaryLogicalOperator._not) { NaryLogicalExpression oreq=dyncast(NaryLogicalExpression.class,le.getQuery()); if(oreq!=null&&oreq.getOp()==NaryLogicalOperator._or) { List<QueryExpression> newList=new ArrayList<>(oreq.getQueries().size()); for(QueryExpression x:oreq.getQueries()) newList.add(new UnaryLogicalExpression(UnaryLogicalOperator._not,x)); return new NaryLogicalExpression(NaryLogicalOperator._and,newList); } } return q; } }
@Override public QueryExpression rewrite(QueryExpression q) { UnaryLogicalExpression le = dyncast(UnaryLogicalExpression.class, q); if (le != null && le.getOp() == UnaryLogicalOperator._not) { NaryLogicalExpression oreq = dyncast(NaryLogicalExpression.class, le.getQuery()); if (oreq != null && oreq.getOp() == NaryLogicalOperator._or) { List<QueryExpression> newList = new ArrayList<>(oreq.getQueries().size()); for (QueryExpression x : oreq.getQueries()) { newList.add(new UnaryLogicalExpression(UnaryLogicalOperator._not, x)); } return new NaryLogicalExpression(NaryLogicalOperator._and, newList); } } return q; } }
@Override public QueryExpression rewrite(QueryExpression q) { UnaryLogicalExpression le = dyncast(UnaryLogicalExpression.class, q); if (le != null && le.getOp() == UnaryLogicalOperator._not) { NaryLogicalExpression oreq = dyncast(NaryLogicalExpression.class, le.getQuery()); if (oreq != null && oreq.getOp() == NaryLogicalOperator._or) { List<QueryExpression> newList = new ArrayList<>(oreq.getQueries().size()); for (QueryExpression x : oreq.getQueries()) { newList.add(new UnaryLogicalExpression(UnaryLogicalOperator._not, x)); } return new NaryLogicalExpression(NaryLogicalOperator._and, newList); } } return q; } }
/** * <pre> * var r0=false; * q; * r0=!q * return r0; * </pre> */ private Block translateUnaryLogicalExpression(Context ctx,UnaryLogicalExpression query) { // Only NOT is a unary operator Block block=new Block(ctx.topLevel.newGlobalBoolean(ctx)); Block nested=translateQuery(ctx,query.getQuery()); block.add(nested); block.add(new SimpleStatement("%s=!%s",block.resultVar,nested.resultVar)); return block; }