fetchCount(); } finally { freeJooq(context);
freeJooq(context); throw e;
@Override public Iterable<LocalLink> getLinks(Language language, int localId, boolean outlinks) throws DaoException{ // if (counter.incrementAndGet() % 1000 == 0) { // double mean = 1.0 * timer.get() / counter.get(); // System.out.println("counter is " + counter.get() + ", mean millis is " + mean); // } DSLContext context = getJooq(); // long start = System.currentTimeMillis(); try { TableField idField; if (outlinks){ idField = Tables.LOCAL_LINK.SOURCE_ID; } else { idField = Tables.LOCAL_LINK.DEST_ID; } Cursor<Record> result = context.select() .from(Tables.LOCAL_LINK) .where(Tables.LOCAL_LINK.LANG_ID.equal(language.getId())) .and(idField.equal(localId)) .fetchLazy(getFetchSize()); // long end = System.currentTimeMillis(); // timer.addAndGet(end - start); return buildLocalLinks(result, outlinks, context); } catch (RuntimeException e) { freeJooq(context); throw e; } }
@Override public LocalLink getLink(Language language, int sourceId, int destId) throws DaoException { DSLContext context = getJooq(); try { Result<Record> result = context.select(). from(Tables.LOCAL_LINK). where(Tables.LOCAL_LINK.LANG_ID.eq(language.getId())). and(Tables.LOCAL_LINK.SOURCE_ID.eq(sourceId)). and(Tables.LOCAL_LINK.DEST_ID.eq(destId)). fetch(); //Work-around to avoid pages that have multiple links to the same page Record record; if (result.isEmpty()){ record = null; } else { record = result.get(0); } return buildLocalLink(record, true); } catch (RuntimeException e) { freeJooq(context); throw e; } }
@Override public Iterable<LocalLink> getLinks(Language language, int localId, boolean outlinks, boolean isParseable, LocalLink.LocationType locationType) throws DaoException{ DSLContext context = getJooq(); try { TableField idField; if (outlinks){ idField = Tables.LOCAL_LINK.SOURCE_ID; } else { idField = Tables.LOCAL_LINK.DEST_ID; } Cursor<Record> result = context.select() .from(Tables.LOCAL_LINK) .where(Tables.LOCAL_LINK.LANG_ID.equal(language.getId())) .and(idField.equal(localId)) .and(Tables.LOCAL_LINK.IS_PARSEABLE.equal(isParseable)) .and(Tables.LOCAL_LINK.LOCATION_TYPE.equal((short) locationType.ordinal())) .fetchLazy(getFetchSize()); return buildLocalLinks(result, outlinks, context); } catch (RuntimeException e) { freeJooq(context); throw e; } }