public int[] getDocsForPageRange(Integer begin_inclusive, Integer end_exclusive) throws SQLException { Statement st = SQL.forThread().createStatement(); try { String query = "SELECT " + ResolvedPage.DOC_ID + " FROM " + ResolvedPage.TABLE; if (begin_inclusive != null && end_exclusive != null) { query += " WHERE " + ResolvedPage.PAGE_NUMBER + ">=" + begin_inclusive + " AND " + ResolvedPage.PAGE_NUMBER + "<" + end_exclusive; } else if (begin_inclusive != null) { query += " WHERE " + ResolvedPage.PAGE_NUMBER + ">=" + begin_inclusive; } else if (end_exclusive != null) { query += " WHERE " + ResolvedPage.PAGE_NUMBER + "<" + end_exclusive; } query += " ORDER BY " + ResolvedPage.DOC_ID; ResultSet rs = st.executeQuery(query); try { TIntLinkedList docs = new TIntLinkedList(); while (rs.next()) { docs.add(rs.getInt(1)); } return docs.toArray(new int[docs.size()]); } finally { rs.close(); } } finally { st.close(); } }
public PageAccessor() throws SQLException { this(SQL.forThread()); }