Remove unused SpatialJoinUtils::isSpatialJoinFilter
*/
package com.facebook.presto.util;
-import com.facebook.presto.sql.planner.Symbol;
-import com.facebook.presto.sql.planner.plan.PlanNode;
import com.facebook.presto.sql.tree.ComparisonExpression;
import com.facebook.presto.sql.tree.Expression;
import com.facebook.presto.sql.tree.FunctionCall;
-import com.facebook.presto.sql.tree.Literal;
-import com.facebook.presto.sql.tree.SymbolReference;
-import java.util.Collection;
import java.util.List;
-import java.util.Set;
import static com.facebook.presto.sql.ExpressionUtils.extractConjuncts;
-import static com.facebook.presto.sql.tree.ComparisonExpression.Operator.LESS_THAN;
-import static com.facebook.presto.sql.tree.ComparisonExpression.Operator.LESS_THAN_OR_EQUAL;
-import static com.google.common.base.Verify.verify;
import static com.google.common.collect.ImmutableList.toImmutableList;
-import static com.google.common.collect.ImmutableSet.toImmutableSet;
public class SpatialJoinUtils
{
@@ -106,59 +96,4 @@ public class SpatialJoinUtils
return false;
}
-
- public static boolean isSpatialJoinFilter(PlanNode left, PlanNode right, Expression filterExpression)
- {
- List<FunctionCall> functionCalls = extractSupportedSpatialFunctions(filterExpression);
- for (FunctionCall functionCall : functionCalls) {
- if (isSpatialJoinFilter(left, right, functionCall)) {
- return true;
- }
- }
-
- List<ComparisonExpression> spatialComparisons = extractSupportedSpatialComparisons(filterExpression);
- for (ComparisonExpression spatialComparison : spatialComparisons) {
- if (spatialComparison.getOperator() == LESS_THAN || spatialComparison.getOperator() == LESS_THAN_OR_EQUAL) {
- // ST_Distance(a, b) <= r
- Expression radius = spatialComparison.getRight();
- if (radius instanceof Literal || (radius instanceof SymbolReference && getSymbolReferences(right.getOutputSymbols()).contains(radius))) {
- if (isSpatialJoinFilter(left, right, (FunctionCall) spatialComparison.getLeft())) {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- private static boolean isSpatialJoinFilter(PlanNode left, PlanNode right, FunctionCall spatialFunction)
- {
- List<Expression> arguments = spatialFunction.getArguments();
- verify(arguments.size() == 2);
- if (!(arguments.get(0) instanceof SymbolReference) || !(arguments.get(1) instanceof SymbolReference)) {
- return false;
- }
-
- SymbolReference firstSymbol = (SymbolReference) arguments.get(0);
- SymbolReference secondSymbol = (SymbolReference) arguments.get(1);
-
- Set<SymbolReference> probeSymbols = getSymbolReferences(left.getOutputSymbols());
- Set<SymbolReference> buildSymbols = getSymbolReferences(right.getOutputSymbols());
-
- if (probeSymbols.contains(firstSymbol) && buildSymbols.contains(secondSymbol)) {
- return true;
- }
-
- if (probeSymbols.contains(secondSymbol) && buildSymbols.contains(firstSymbol)) {
- return true;
- }
-
- return false;
- }
-
- private static Set<SymbolReference> getSymbolReferences(Collection<Symbol> symbols)
- {
- return symbols.stream().map(Symbol::toSymbolReference).collect(toImmutableSet());
- }
}
