@Test void readForTermCountAndObject() throws Exception { TermId termId = TermId.of("MONDO", "001"); ObjectScoreDistribution objScoreDist = objDbReader.readForTermCountAndObject(3, termId); assertEquals(objScoreDist.getObjectId(), termId); }
@Override public ObjectScoreDistribution readForTermCountAndObject(int termCount, TermId objectId) throws PhenolException { try (final PreparedStatement stmt = conn.prepareStatement( String.format(H2_SELECT_BY_TERM_COUNT_AND_OBJECT_STATEMENT, tableName))) { stmt.setInt(1, termCount); try { stmt.setString(2, ObjHexStringConverter.object2hex(objectId)); } catch (IOException e) { throw new RuntimeException("Unable to convert object id to hexadecimal String: " + objectId.toString()); } try (final ResultSet rs = stmt.executeQuery()) { while (rs.next()) { return objectScoreDistributionFromResultSet(rs); } } } catch (SQLException e) { throw new PhenolException( "Problem with getting object score distribution for termCount: " + termCount + ", objectId: " + objectId); } throw new PhenolException( "Found no object for termCount: " + termCount + ", objectId: " + objectId); }
H2ScoreDistributionReader implements ScoreDistributionReader { @Override public ObjectScoreDistribution readForTermCountAndObject(int termCount, TermId objectId) throws PhenolException { try (final PreparedStatement stmt = conn.prepareStatement( String.format(H2_SELECT_BY_TERM_COUNT_AND_OBJECT_STATEMENT, tableName))) { stmt.setInt(1, termCount); try { stmt.setString(2, ObjHexStringConverter.object2hex(objectId)); } catch (IOException e) { throw new RuntimeException("Unable to convert object id to hexadecimal String: " + objectId.toString()); } try (final ResultSet rs = stmt.executeQuery()) { while (rs.next()) { return objectScoreDistributionFromResultSet(rs); } } } catch (SQLException e) { throw new PhenolException( "Problem with getting object score distribution for termCount: " + termCount + ", objectId: " + objectId); } throw new PhenolException( "Found no object for termCount: " + termCount + ", objectId: " + objectId); } }
H2ScoreDistributionReader implements ScoreDistributionReader { @Override public ObjectScoreDistribution readForTermCountAndObject(int termCount, TermId objectId) throws PhenolException { try (final PreparedStatement stmt = conn.prepareStatement( String.format(H2_SELECT_BY_TERM_COUNT_AND_OBJECT_STATEMENT, tableName))) { stmt.setInt(1, termCount); try { stmt.setString(2, ObjHexStringConverter.object2hex(objectId)); } catch (IOException e) { throw new RuntimeException("Unable to convert object id to hexadecimal String: " + objectId.toString()); } try (final ResultSet rs = stmt.executeQuery()) { while (rs.next()) { return objectScoreDistributionFromResultSet(rs); } } } catch (SQLException e) { throw new PhenolException( "Problem with getting object score distribution for termCount: " + termCount + ", objectId: " + objectId); } throw new PhenolException( "Found no object for termCount: " + termCount + ", objectId: " + objectId); } H2ScoreDistributionReader(String pathDb, String tableName); }
H2ScoreDistributionReader implements ScoreDistributionReader { @Override public ObjectScoreDistribution readForTermCountAndObject(int termCount, TermId objectId) throws PhenolException { try (final PreparedStatement stmt = conn.prepareStatement( String.format(H2_SELECT_BY_TERM_COUNT_AND_OBJECT_STATEMENT, tableName))) { stmt.setInt(1, termCount); try { stmt.setString(2, ObjHexStringConverter.object2hex(objectId)); } catch (IOException e) { throw new RuntimeException("Unable to convert object id to hexadecimal String: " + objectId.toString()); } try (final ResultSet rs = stmt.executeQuery()) { while (rs.next()) { return objectScoreDistributionFromResultSet(rs); } } } catch (SQLException e) { throw new PhenolException( "Problem with getting object score distribution for termCount: " + termCount + ", objectId: " + objectId); } throw new PhenolException( "Found no object for termCount: " + termCount + ", objectId: " + objectId); } 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(); }
H2ScoreDistributionReader implements ScoreDistributionReader { @Override public ObjectScoreDistribution readForTermCountAndObject(int termCount, TermId objectId) throws PhenolException { try (final PreparedStatement stmt = conn.prepareStatement( String.format(H2_SELECT_BY_TERM_COUNT_AND_OBJECT_STATEMENT, tableName))) { stmt.setInt(1, termCount); try { stmt.setString(2, ObjHexStringConverter.object2hex(objectId)); } catch (IOException e) { throw new RuntimeException("Unable to convert object id to hexadecimal String: " + objectId.toString()); } try (final ResultSet rs = stmt.executeQuery()) { while (rs.next()) { return objectScoreDistributionFromResultSet(rs); } } } catch (SQLException e) { throw new PhenolException( "Problem with getting object score distribution for termCount: " + termCount + ", objectId: " + objectId); } throw new PhenolException( "Found no object for termCount: " + termCount + ", objectId: " + objectId); } 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();  }