Beispiel #1
0
 @Override
 public void workQuery(CorrectEntry ce, ResultEntry re) {
   if (ce.getDocName().equalsIgnoreCase(re.getDocName())) {
     correctHits++;
   }
   map.put(ce.getDocName().hashCode(), 0);
 }
Beispiel #2
0
 /**
  * Log a result entry
  *
  * @param re
  */
 public void logResult(ResultEntry re) {
   entries.add(re);
   re.save(getConnection());
   for (ResultViewBase view : views.values()) {
     view.addResult(re);
   }
 }
Beispiel #3
0
  /**
   * Generate some random test data and put it in the results table. This is just for testing
   * purposes.
   */
  public void addTestData() {
    final int N_PLAYERS = 10;
    String[] pgnResults = {"1-0", "0-1", "1/2-1/2"};

    try {
      getConnection().setAutoCommit(false);
      Statement clear = getConnection().createStatement();
      clear.executeUpdate(
          "DELETE FROM results WHERE playerWhite LIKE 'testplayer%' OR playerBlack LIKE 'testplayer%'");
      Random rnd = new Random();
      for (int i = 0; i < N_PLAYERS; i++) {
        for (int j = 0; j < N_PLAYERS; j++) {
          if (i == j) {
            continue;
          }
          String plw = "testplayer" + i;
          String plb = "testplayer" + j;
          String gn = "testgame-" + i + "-" + j;
          long start = System.currentTimeMillis() - 5000;
          long end = System.currentTimeMillis() - 4000;
          String pgnRes = pgnResults[rnd.nextInt(pgnResults.length)];
          GameResult rt;
          if (pgnRes.equals("1-0") || pgnRes.equals("0-1")) {
            rt = GameResult.Checkmate;
          } else {
            rt = GameResult.DrawAgreed;
          }
          ResultEntry re = new ResultEntry(plw, plb, gn, start, end, pgnRes, rt);
          entries.add(re);
          re.save(getConnection());
        }
      }
      getConnection().setAutoCommit(true);
      for (ResultViewBase view : views.values()) {
        view.rebuild();
      }
      System.out.println("test data added & committed");
    } catch (SQLException e) {
      ChessCraftLogger.warning("can't put test data into DB: " + e.getMessage());
    }
  }
Beispiel #4
0
 @Override
 public void workQuery(CorrectEntry ce, ResultEntry re) {
   if (ce.getDocName().equalsIgnoreCase(re.getDocName()) && firstCorrectAnswer > resultIteration) {
     firstCorrectAnswer = resultIteration;
   }
 }