Esempio n. 1
0
    private void handleFilter(FilterTuple filterTuple, FilterExpr expr) {

      /*
       * CompareEQ expressions are inserted as bindings if possible
       *
       * if the filtertuple contains all vars of the filterexpr, we
       * can evaluate the filter expr safely on the filterTuple
       *
       * if there is no intersection of variables, the filter is
       * irrelevant for this expr
       *
       * if there is some intersection, we cannot remove the filter
       * and have to keep it in the query plan for postfiltering
       */
      int intersected = 0;
      for (String filterVar : expr.getVars()) {
        if (filterTuple.getFreeVars().contains(filterVar)) intersected++;
      }

      // filter expression is irrelevant
      if (intersected == 0) return;

      // push eq comparison into stmt as bindings
      if (expr.isCompareEq()) {

        if (handleCompare(filterTuple, (Compare) expr.getExpression())) return;
      }

      // filter contains all variables => push filter
      if (intersected == expr.getVars().size()) filterTuple.addFilterExpr(expr);

      // filter is still needed for post filtering
      else {
        canRemove = false;
      }
    }