/** * Default behavior is to recursively iterate the nested quereies. If nested * processing returns objects different from the original nested queries, * this method creates a new n-ary logical expression using the new query * expressions and returns that. */ protected QueryExpression itrNaryLogicalExpression(NaryLogicalExpression q, Path context) { CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<>(q.getQueries()); while (itr.hasNext()) { QueryExpression nestedq = itr.next(); QueryExpression newq = iterate(nestedq, context); if (newq != nestedq) { itr.set(newq); } } if (itr.isCopied()) { return new NaryLogicalExpression(q.getOp(), itr.getCopiedList()); } else { return q; } }
/** * Creates a copy of the underlying list, and sets the element that was just * read in the new copy. Original list remains unchanged. Note that this * modifies the current element, that is, if next() is called once, set(x) * sets 0th element to x not the 1st element */ public void set(T object) { copy(); copiedList.set(ix, object); }
@Override public QueryExpression rewrite(QueryExpression q) { NaryLogicalExpression le = dyncast(NaryLogicalExpression.class, q); if (le != null) { if (le.getOp() == NaryLogicalOperator._and) { CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<>(le.getQueries()); while (itr.hasNext()) { QueryExpression x = itr.next(); NaryLogicalExpression nested = dyncast(NaryLogicalExpression.class, x); if (nested != null && nested.getOp() == NaryLogicalOperator._and) { // Remove this element, and add all its queries to the parent query itr.remove(); itr.getCopiedList().addAll(nested.getQueries()); } } if (itr.isCopied()) { return new NaryLogicalExpression(NaryLogicalOperator._and, itr.getCopiedList()); } } } return q; } }
@Override public QueryExpression rewrite(QueryExpression q) { NaryLogicalExpression le=dyncast(NaryLogicalExpression.class,q); if(le!=null) { if(le.getOp()==NaryLogicalOperator._and) { CopyOnWriteIterator<QueryExpression> itr=new CopyOnWriteIterator<>(le.getQueries()); while(itr.hasNext()) { QueryExpression x=itr.next(); NaryLogicalExpression nested=dyncast(NaryLogicalExpression.class,x); if(nested!=null&&nested.getOp()==NaryLogicalOperator._and) { // Remove this element, and add all its queries to the parent query itr.remove(); itr.getCopiedList().addAll(nested.getQueries()); } } if(itr.isCopied()) return new NaryLogicalExpression(NaryLogicalOperator._and,itr.getCopiedList()); } } return q; } }
/** * Default behavior is to recursively iterate the nested quereies. If nested * processing returns objects different from the original nested queries, * this method creates a new n-ary logical expression using the new query * expressions and returns that. */ protected QueryExpression itrNaryLogicalExpression(NaryLogicalExpression q, Path context) { CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<>(q.getQueries()); while (itr.hasNext()) { QueryExpression nestedq = itr.next(); QueryExpression newq = iterate(nestedq, context); if (newq != nestedq) { itr.set(newq); } } if (itr.isCopied()) { return new NaryLogicalExpression(q.getOp(), itr.getCopiedList()); } else { return q; } }
@Override public QueryExpression rewrite(QueryExpression q) { NaryLogicalExpression le = dyncast(NaryLogicalExpression.class, q); if (le != null) { if (le.getOp() == NaryLogicalOperator._and) { CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<>(le.getQueries()); while (itr.hasNext()) { QueryExpression x = itr.next(); NaryLogicalExpression nested = dyncast(NaryLogicalExpression.class, x); if (nested != null && nested.getOp() == NaryLogicalOperator._and) { // Remove this element, and add all its queries to the parent query itr.remove(); itr.getCopiedList().addAll(nested.getQueries()); } } if (itr.isCopied()) { return new NaryLogicalExpression(NaryLogicalOperator._and, itr.getCopiedList()); } } } return q; } }
/** * Creates a copy of the underlying list, and removes the element from the * new copy. Original list remains unchanged. */ @Override public void remove() { copy(); copiedList.remove(ix); }
} else if (q instanceof NaryLogicalExpression) { LOGGER.debug("q is a n-ary logical expression, rewriting nested terms"); CopyOnWriteIterator<QueryExpression> cowr=new CopyOnWriteIterator<>( ((NaryLogicalExpression)q).getQueries()); while(cowr.hasNext()) { QueryExpression nestedq=cowr.next(); QueryExpression newNestedq=rewriteIteration(nestedq); if(newNestedq!=nestedq) cowr.set(newNestedq); if(cowr.isCopied()) newq=new NaryLogicalExpression( ((NaryLogicalExpression)q).getOp(),cowr.getCopiedList()); } else if (q instanceof ArrayMatchExpression) { LOGGER.debug("q is an array match expression, rewriting nested query");
protected QueryExpression itrNaryLogicalExpression(NaryLogicalExpression q, Path context) { NaryLogicalExpression nq = (NaryLogicalExpression) super.itrNaryLogicalExpression(q, context); CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<QueryExpression>(nq.getQueries()); while (itr.hasNext()) { QueryExpression nestedq = itr.next(); if (q.getOp() == NaryLogicalOperator._and) { if (nestedq instanceof TruePH) { itr.remove(); } else if (nestedq instanceof FalsePH) { return new FalsePH(); return new TruePH(); } else if (nestedq instanceof FalsePH) { itr.remove(); if (itr.isCopied()) { List<QueryExpression> newList = itr.getCopiedList(); if (newList.size() == 0) { ret=new TruePH();
/** * Creates a copy of the underlying list, and sets the element that was just * read in the new copy. Original list remains unchanged. Note that this * modifies the current element, that is, if next() is called once, set(x) * sets 0th element to x not the 1st element */ public void set(T object) { if (deleted) { throw new NoSuchElementException(); } copy(); copiedList.set(ix, object); }
CopyOnWriteIterator<QueryExpression> cowr = new CopyOnWriteIterator<>(((NaryLogicalExpression) q).getQueries()); while (cowr.hasNext()) { QueryExpression nestedq = cowr.next(); QueryExpression newNestedq = rewriteIteration(nestedq); if (newNestedq != nestedq) { cowr.set(newNestedq); if (cowr.isCopied()) { newq = new NaryLogicalExpression(((NaryLogicalExpression) q).getOp(), cowr.getCopiedList());
protected QueryExpression itrNaryLogicalExpression(NaryLogicalExpression q, Path context) { NaryLogicalExpression nq = (NaryLogicalExpression) super.itrNaryLogicalExpression(q, context); CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<QueryExpression>(nq.getQueries()); while (itr.hasNext()) { QueryExpression nestedq = itr.next(); if (q.getOp() == NaryLogicalOperator._and) { if (nestedq instanceof TruePH) { itr.remove(); } else if (nestedq instanceof FalsePH) { return new FalsePH(); return new TruePH(); } else if (nestedq instanceof FalsePH) { itr.remove(); if (itr.isCopied()) { List<QueryExpression> newList = itr.getCopiedList(); if (newList.size() == 0) { ret=new TruePH();
/** * Creates a copy of the underlying list, and sets the element that was just * read in the new copy. Original list remains unchanged. Note that this * modifies the current element, that is, if next() is called once, set(x) * sets 0th element to x not the 1st element */ public void set(T object) { if (deleted) { throw new NoSuchElementException(); } copy(); copiedList.set(ix, object); }
CopyOnWriteIterator<QueryExpression> cowr = new CopyOnWriteIterator<>(((NaryLogicalExpression) q).getQueries()); while (cowr.hasNext()) { QueryExpression nestedq = cowr.next(); QueryExpression newNestedq = rewriteIteration(nestedq); if (newNestedq != nestedq) { cowr.set(newNestedq); if (cowr.isCopied()) { newq = new NaryLogicalExpression(((NaryLogicalExpression) q).getOp(), cowr.getCopiedList());
/** * Creates a copy of the underlying list, and removes the element from the * new copy. Original list remains unchanged. */ @Override public void remove() { // Removing an element makes the current pointer invalid. if (deleted) { throw new NoSuchElementException(); } copy(); copiedList.remove(ix); deleted = true; }
/** * Creates a copy of the underlying list, and removes the element from the * new copy. Original list remains unchanged. */ @Override public void remove() { // Removing an element makes the current pointer invalid. if (deleted) { throw new NoSuchElementException(); } copy(); copiedList.remove(ix); deleted = true; }