Exemple #1
0
 private void setPartitionKey() {
   HashMap<String, TableNode> tableMap = dbData.getMetaData();
   for (String table : tableMap.keySet()) {
     TableNode tableNode = tableMap.get(table);
     List<String> primaryKey = tableNode.getPrimaryKey();
     List<String> keys = new ArrayList<String>();
     if (primaryKey.size() > 0) keys.add(primaryKey.get(0));
     else keys.add(tableNode.getAttrVector().get(0).getName());
     tableKeyMap.put(table, keys);
   }
 }
Exemple #2
0
  private void setPlacement() {
    HashMap<String, TableNode> tables = dbData.getMetaData();

    for (String tableName : tableKeyMap.keySet()) {
      String key = tableKeyMap.get(tableName).get(0);

      Statement stmt;
      try {
        stmt = conn.createStatement();
        ResultSet resultMin =
            stmt.executeQuery(
                "select min(" + key + ") from " + QueryPrepare.prepare(tableName) + ";");
        resultMin.next();
        double min = resultMin.getDouble(1);

        ResultSet resultMax =
            stmt.executeQuery(
                "select max(" + key + ") from " + QueryPrepare.prepare(tableName) + ";");
        resultMax.next();
        double max = resultMax.getDouble(1);

        double range = 0;
        if (paraList != null) {
          String rangeString = paraList.get(0)[1];
          try {
            range = Double.valueOf(rangeString);
          } catch (NumberFormatException e) {
            System.out.println("illegal range value");
            range = 0;
          }
        }
        LookUpTable aLookUp = new LookUpTable(min, max, range, nodes);
        keyLookUpMap.put(tableName, aLookUp);
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }