@Override public boolean requiresFullTextIndex() { for (ConstraintImpl c : getConstraints()) { if (c.requiresFullTextIndex()) { return true; } } return false; }
/** * Calls accept on each of the attached constraints of the OR node. */ @Override public boolean visit(OrImpl node) { for (ConstraintImpl constraint : node.getConstraints()) { constraint.accept(this); } return true; }
@Override public boolean requiresFullTextIndex() { for (ConstraintImpl c : getConstraints()) { if (c.requiresFullTextIndex()) { return true; } } return false; }
/** * Calls accept on each of the attached constraints of the OR node. */ @Override public boolean visit(OrImpl node) { for (ConstraintImpl constraint : node.getConstraints()) { constraint.accept(this); } return true; }
@Override public boolean requiresFullTextIndex() { for (ConstraintImpl c : getConstraints()) { if (c.requiresFullTextIndex()) { return true; } } return false; }
/** * Calls accept on each of the attached constraints of the OR node. */ @Override public boolean visit(OrImpl node) { for (ConstraintImpl constraint : node.getConstraints()) { constraint.accept(this); } return true; }
@Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; }
@Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; }
@Override public Set<ConstraintImpl> convertToUnion() { Set<ConstraintImpl> result = Sets.newHashSet(); for (ConstraintImpl c : getConstraints()) { Set<ConstraintImpl> converted = c.convertToUnion(); if (converted.isEmpty()) { result.add(c); } else { result.addAll(converted); } } return result; }
@Override ConstraintImpl not() { // not (X or Y) == (not X) and (not Y) List<ConstraintImpl> list = newArrayList(); for (ConstraintImpl constraint : getConstraints()) { list.add(new NotImpl(constraint)); } return new AndImpl(list).simplify(); }
@Override ConstraintImpl not() { // not (X or Y) == (not X) and (not Y) List<ConstraintImpl> list = newArrayList(); for (ConstraintImpl constraint : getConstraints()) { list.add(new NotImpl(constraint)); } return new AndImpl(list).simplify(); }
@Override ConstraintImpl not() { // not (X or Y) == (not X) and (not Y) List<ConstraintImpl> list = newArrayList(); for (ConstraintImpl constraint : getConstraints()) { list.add(new NotImpl(constraint)); } return new AndImpl(list).simplify(); }
public void addToUnionList(Set<ConstraintImpl> target) { // conditions of type // @a = 1 and (@x = 1 or @y = 2) // are automatically converted to // (@a = 1 and @x = 1) union (@a = 1 and @y = 2) AndImpl and = pullOrRight(); ConstraintImpl last = and.getLastConstraint(); if (last instanceof OrImpl) { OrImpl or = (OrImpl) last; // same as above, but with the added "and" for(ConstraintImpl c : or.getConstraints()) { ArrayList<ConstraintImpl> list = and.getFirstConstraints(); list.add(c); new AndImpl(list).addToUnionList(target); } return; } target.add(this); }
public void addToUnionList(Set<ConstraintImpl> target) { // conditions of type // @a = 1 and (@x = 1 or @y = 2) // are automatically converted to // (@a = 1 and @x = 1) union (@a = 1 and @y = 2) AndImpl and = pullOrRight(); ConstraintImpl last = and.getLastConstraint(); if (last instanceof OrImpl) { OrImpl or = (OrImpl) last; // same as above, but with the added "and" for(ConstraintImpl c : or.getConstraints()) { ArrayList<ConstraintImpl> list = and.getFirstConstraints(); list.add(c); new AndImpl(list).addToUnionList(target); } return; } target.add(this); }
public void addToUnionList(Set<ConstraintImpl> target) { // conditions of type // @a = 1 and (@x = 1 or @y = 2) // are automatically converted to // (@a = 1 and @x = 1) union (@a = 1 and @y = 2) AndImpl and = pullOrRight(); ConstraintImpl last = and.getLastConstraint(); if (last instanceof OrImpl) { OrImpl or = (OrImpl) last; // same as above, but with the added "and" for(ConstraintImpl c : or.getConstraints()) { ArrayList<ConstraintImpl> list = and.getFirstConstraints(); list.add(c); new AndImpl(list).addToUnionList(target); } return; } target.add(this); }
private static Set<String> extractFulltext(ConstraintImpl c) { Set<String> tokens = new HashSet<String>(); // TODO instanceof should not be used, // as it will break without us noticing if we extend the AST if (c instanceof FullTextSearchImpl) { FullTextSearchImpl f = (FullTextSearchImpl) c; if (f.getFullTextSearchExpression() instanceof LiteralImpl) { LiteralImpl l = (LiteralImpl) f.getFullTextSearchExpression(); tokens.add(l.getLiteralValue().getValue(Type.STRING)); } } if (c instanceof AndImpl) { for (ConstraintImpl constraint : ((AndImpl) c).getConstraints()) { tokens.addAll(extractFulltext(constraint)); } } if (c instanceof OrImpl) { for (ConstraintImpl constraint : ((OrImpl) c).getConstraints()) { tokens.addAll(extractFulltext(constraint)); } } return tokens; }
private static Set<String> extractFulltext(ConstraintImpl c) { Set<String> tokens = new HashSet<String>(); // TODO instanceof should not be used, // as it will break without us noticing if we extend the AST if (c instanceof FullTextSearchImpl) { FullTextSearchImpl f = (FullTextSearchImpl) c; if (f.getFullTextSearchExpression() instanceof LiteralImpl) { LiteralImpl l = (LiteralImpl) f.getFullTextSearchExpression(); tokens.add(l.getLiteralValue().getValue(Type.STRING)); } } if (c instanceof AndImpl) { for (ConstraintImpl constraint : ((AndImpl) c).getConstraints()) { tokens.addAll(extractFulltext(constraint)); } } if (c instanceof OrImpl) { for (ConstraintImpl constraint : ((OrImpl) c).getConstraints()) { tokens.addAll(extractFulltext(constraint)); } } return tokens; }
private static Set<String> extractFulltext(ConstraintImpl c) { Set<String> tokens = new HashSet<String>(); // TODO instanceof should not be used, // as it will break without us noticing if we extend the AST if (c instanceof FullTextSearchImpl) { FullTextSearchImpl f = (FullTextSearchImpl) c; if (f.getFullTextSearchExpression() instanceof LiteralImpl) { LiteralImpl l = (LiteralImpl) f.getFullTextSearchExpression(); tokens.add(l.getLiteralValue().getValue(Type.STRING)); } } if (c instanceof AndImpl) { for (ConstraintImpl constraint : ((AndImpl) c).getConstraints()) { tokens.addAll(extractFulltext(constraint)); } } if (c instanceof OrImpl) { for (ConstraintImpl constraint : ((OrImpl) c).getConstraints()) { tokens.addAll(extractFulltext(constraint)); } } return tokens; }