private void evaluationJoinChain(TableFilter filter) {
      TableMate table1 = (TableMate) filter.getTable();
      Column[] columns1 = table1.getRuleColumns();
      if (columns1 == null) {
        throw new IllegalArgumentException("not sharding TableFilter");
      }
      ArrayList<IndexCondition> conditions = getIndexConditions(filter);
      List<IndexCondition> masks = New.arrayList(10);
      List<Column> compareColumns = New.arrayList(10);
      for (Column column : columns1) {
        for (IndexCondition condition : conditions) {
          Column compareColumn = condition.getCompareColumn();
          if ((condition.getMask(conditions) & IndexCondition.EQUALITY)
              != IndexCondition.EQUALITY) {
            continue;
          }
          if (condition.getColumn() != column || compareColumn == null) {
            continue;
          }
          masks.add(condition);
          compareColumns.add(compareColumn);
        }
      }

      Set<Table> tables = New.hashSet();
      for (IndexCondition mask : masks) {
        Column compareColumn = mask.getCompareColumn();
        Table table = compareColumn.getTable();
        if (!(table instanceof TableMate)) {
          continue;
        }
        TableMate tableMate = (TableMate) table;
        Column[] rc = tableMate.getRuleColumns();
        if (compareColumns.containsAll(Arrays.asList(rc))) {
          tables.add(table);
        }
      }
      if (tables.isEmpty()) {
        return;
      }
      for (Table table : tables) {
        for (TableFilter tf : filters) {
          if (tf.getTable() == table && !joinTableChain.contains(tf)) {
            joinTableChain.add(tf);
            evaluationJoinChain(tf);
          }
        }
      }
    }
示例#2
0
 /**
  * Keep a collection of the columns to pass to update if a duplicate key happens, for MySQL-style
  * INSERT ... ON DUPLICATE KEY UPDATE ....
  *
  * @param column the column
  * @param expression the expression
  */
 public void addAssignmentForDuplicate(Column column, Expression expression) {
   if (duplicateKeyAssignmentMap == null) {
     duplicateKeyAssignmentMap = New.hashMap();
   }
   if (duplicateKeyAssignmentMap.containsKey(column)) {
     throw DbException.get(ErrorCode.DUPLICATE_COLUMN_NAME_1, column.getName());
   }
   duplicateKeyAssignmentMap.put(column, expression);
 }