Example #1
0
  @Override
  public RouteResultset routeToMultiNode(
      SchemaConfig schema,
      boolean isSelect,
      boolean cache,
      QueryTreeNode ast,
      RouteResultset rrs,
      Collection<String> dataNodes,
      String stmt)
      throws SQLSyntaxErrorException {
    if (isSelect) {
      String sql = SelectSQLAnalyser.analyseMergeInf(rrs, ast, true, schema.getDefaultMaxLimit());
      if (sql != null) {
        stmt = sql;
      }
    }
    RouteResultsetNode[] nodes = new RouteResultsetNode[dataNodes.size()];
    int i = 0;
    for (String dataNode : dataNodes) {

      nodes[i++] = new RouteResultsetNode(dataNode, rrs.getSqlType(), stmt);
    }
    rrs.setCacheAble(cache);
    rrs.setNodes(nodes);
    return rrs;
  }
Example #2
0
 /**
  * 判断两个表所在节点集合是否相等
  *
  * @param curRNodeSet 当前表所在的节点集合
  * @param newNodeSet 新表所在节点集合
  * @return 返回fase(不相等)或true(相等)
  * @author mycat
  */
 private static boolean checkIfValidMultiTableRoute(
     Set<String> curRNodeSet, Collection<String> newNodeSet) {
   if (curRNodeSet.size() != newNodeSet.size()) {
     return false;
   } else {
     for (String dataNode : newNodeSet) {
       if (!curRNodeSet.contains(dataNode)) {
         return false;
       }
     }
   }
   return true;
 }