use of com.yahoo.elide.core.filter.visitors.FilterExpressionNormalizationVisitor in project elide by yahoo.
the class MatchesTemplateVisitor method isValid.
/**
* Determines if a client filter matches or contains a subexpression that matches a template filter.
* @param templateFilter A templated filter expression
* @param clientFilter The client provided filter expression.
* @param arguments If the client filter matches, extract any table arguments.
* @return True if the client filter matches. False otherwise.
*/
public static boolean isValid(FilterExpression templateFilter, FilterExpression clientFilter, Map<String, Argument> arguments) {
Preconditions.checkNotNull(templateFilter);
if (clientFilter == null) {
return false;
}
// First we normalize the filters so any NOT clauses are pushed down immediately in front of a predicate.
// This lets us treat logical AND and OR without regard for any preceding NOT clauses.
FilterExpression normalizedTemplateFilter = templateFilter.accept(new FilterExpressionNormalizationVisitor());
FilterExpression normalizedClientFilter = clientFilter.accept(new FilterExpressionNormalizationVisitor());
MatchesTemplateVisitor templateVisitor = new MatchesTemplateVisitor(normalizedTemplateFilter);
boolean matches = normalizedClientFilter.accept(templateVisitor);
if (matches) {
arguments.putAll(templateVisitor.arguments);
}
return matches;
}
use of com.yahoo.elide.core.filter.visitors.FilterExpressionNormalizationVisitor in project elide by yahoo.
the class SubqueryFilterSplitter method splitFilter.
public static SplitFilter splitFilter(MetaDataStore metaDataStore, FilterExpression expression) {
if (expression == null) {
return SplitFilter.builder().build();
}
FilterExpressionNormalizationVisitor normalizer = new FilterExpressionNormalizationVisitor();
FilterExpression normalizedExpression = expression.accept(normalizer);
return normalizedExpression.accept(new SubqueryFilterSplitter(metaDataStore));
}
use of com.yahoo.elide.core.filter.visitors.FilterExpressionNormalizationVisitor in project elide by yahoo.
the class FilterPredicatePushdownExtractor method extractPushDownPredicate.
/**
* @param dictionary
* @param expression
* @return A filter expression that can be safely executed in the data store.
*/
public static FilterExpression extractPushDownPredicate(EntityDictionary dictionary, FilterExpression expression) {
FilterExpressionNormalizationVisitor normalizationVisitor = new FilterExpressionNormalizationVisitor();
FilterExpression normalizedExpression = expression.accept(normalizationVisitor);
FilterPredicatePushdownExtractor verifier = new FilterPredicatePushdownExtractor(dictionary);
return normalizedExpression.accept(verifier);
}
Aggregations