コード例 #1
0
    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
 private boolean isDirectLookup() {
   for (TableFilter tf : filters) {
     if (!tf.isFromTableMate() && !isNestedJoinTable(tf)) {
       return false;
     }
   }
   if (filters.size() == 1) {
     return true;
   } else {
     List<TableFilter> shardingTableFilter = New.arrayList();
     for (TableFilter tf : filters) {
       if (isNestedJoinTable(tf)) {
         continue;
       }
       if (!isGropTableFilter(tf)) {
         return false;
       }
       TableMate table = (TableMate) tf.getTable();
       if (table.getRuleColumns() != null) {
         shardingTableFilter.add(tf);
       }
     }
     if (shardingTableFilter.size() < 2) {
       return true;
     }
     this.joinTableChain = New.hashSet();
     evaluationJoinChain(shardingTableFilter.iterator().next());
     return joinTableChain.containsAll(shardingTableFilter);
   }
 }