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); } } H2ScoreDistributionReader(String pathDb, String tableName); @Override ObjectScoreDistribution readForTermCountAndObject(int termCount, TermId objectId); @Override ScoreDistribution readForTermCount(int termCount); @Override Map<Integer, ScoreDistribution> readAll(); @Override void close();  }
@Test void readForTermCount() throws Exception { ScoreDistribution objScoreDist = objDbReader.readForTermCount(3); assertEquals(objScoreDist.getObjectIds().size(), 1); }