class H2ScoreDistributionReader implements ScoreDistributionReader {

  @Override
  public ScoreDistribution readForTermCount(int termCount) throws PhenolException {
    final Map<TermId, ObjectScoreDistribution> dists = new HashMap<>();

    try (final PreparedStatement stmt =
        conn.prepareStatement(String.format(H2_SELECT_BY_TERM_COUNT_STATEMENT, tableName))) {
      stmt.setInt(1, termCount);
      try (final ResultSet rs = stmt.executeQuery()) {
        while (rs.next()) {
          final ObjectScoreDistribution objScoreDist = objectScoreDistributionFromResultSet(rs);
          dists.put(objScoreDist.getObjectId(), objScoreDist);
        }
      }
    } catch (SQLException e) {
      throw new PhenolException(
          "Problem with getting object score distributions for termCount: " + termCount);
    }

    if (dists.size() == 0) {
      throw new PhenolException("Found no score distributions for termCount: " + termCount);
    } else {
      return new ScoreDistribution(termCount, dists);
    }
  }

  public  H2ScoreDistributionReader(String pathDb, String tableName);

}