@Override public boolean containsUnfilteredFullTextCondition() { // If the constraint is a fulltext condition, // then we can not apply it, as in "not contains(., 'x')". // Also, if the constraint _contains_ a unfiltered fulltext condition, as in // "not (x=1 or contains(., 'x')". return constraint.containsUnfilteredFullTextCondition() || constraint.requiresFullTextIndex(); }
@Override public boolean evaluate() { for (ConstraintImpl constraint : constraints) { if (!constraint.evaluate()) { return false; } } return true; }
@Override public boolean evaluateStop() { // the logic is reversed here: // we stop only if both conditions say we need to for (ConstraintImpl constraint : constraints) { if (!constraint.evaluateStop()) { return false; } } return true; }
/** * Apply DeMorgan's Laws to push AND/OR constraints higher. */ @Override public ConstraintImpl simplify() { ConstraintImpl simple = constraint.simplify(); ConstraintImpl not = simple.not(); if (not != null) { return not.simplify(); } else if (simple != constraint) { return new NotImpl(simple); } return this; }
@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; }
private boolean evaluateCurrentRow() { if (currentRow.isVirtualRow()) { //null path implies that all checks are already done -- we just need to pass it through return true; } if (!matchesAllTypes && !evaluateTypeMatch()) { return false; } for (ConstraintImpl constraint : selectorConstraints) { if (!constraint.evaluate()) { if (constraint.evaluateStop()) { // stop processing from now on cursor = null; } return false; } } if (joinCondition != null && !joinCondition.evaluate()) { return false; } return true; }
/** * Calls accept on each of the attached constraints of the AND node. */ @Override public boolean visit(AndImpl node) { for (ConstraintImpl constraint : node.getConstraints()) { constraint.accept(this); } return true; }
@Override public Set<SelectorImpl> getSelectors() { return constraint.getSelectors(); }
queryConstraint.restrict(f); FullTextExpression ft = queryConstraint.getFullTextConstraint(this); f.setFullTextConstraint(ft); constraint.restrict(f);
@Override public boolean requiresFullTextIndex() { for (ConstraintImpl c : constraints) { if (c.requiresFullTextIndex()) { return true; } } return false; }
@Override public Set<PropertyExistenceImpl> getPropertyExistenceConditions() { // for the condition "x=1 or x=2", the existence condition // "x is not null" be be derived Set<PropertyExistenceImpl> result = null; for (ConstraintImpl constraint : constraints) { if (result == null) { result = newHashSet(constraint.getPropertyExistenceConditions()); } else { result.retainAll(constraint.getPropertyExistenceConditions()); } } return result; }
@Override public boolean containsUnfilteredFullTextCondition() { for (ConstraintImpl c : constraints) { if (c.containsUnfilteredFullTextCondition()) { return true; } } return false; }
@Override public FullTextExpression getFullTextConstraint(SelectorImpl s) { List<FullTextExpression> list = newArrayList(); for (ConstraintImpl constraint : constraints) { FullTextExpression expression = constraint.getFullTextConstraint(s); if (expression != null) { list.add(expression); } else { // the full-text index can not be used for conditions // of the form "contains(a, 'x') or b=123" return null; } } return new FullTextOr(list); }
@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; }
private boolean evaluateCurrentRow() { if (currentRow.isVirtualRow()) { //null path implies that all checks are already done -- we just need to pass it through return true; } if (!matchesAllTypes && !evaluateTypeMatch()) { return false; } for (ConstraintImpl constraint : selectorConstraints) { if (!constraint.evaluate()) { if (constraint.evaluateStop()) { // stop processing from now on cursor = null; } return false; } } if (joinCondition != null && !joinCondition.evaluate()) { return false; } return true; }
/** * 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<SelectorImpl> getSelectors() { return constraint.getSelectors(); }
/** * Apply DeMorgan's Laws to push AND/OR constraints higher. */ @Override public ConstraintImpl simplify() { ConstraintImpl simple = constraint.simplify(); ConstraintImpl not = simple.not(); if (not != null) { return not.simplify(); } else if (simple != constraint) { return new NotImpl(simple); } return this; }
queryConstraint.restrict(f); FullTextExpression ft = queryConstraint.getFullTextConstraint(this); f.setFullTextConstraint(ft); constraint.restrict(f);
@Override public boolean requiresFullTextIndex() { for (ConstraintImpl c : constraints) { if (c.requiresFullTextIndex()) { return true; } } return false; }