@Override public int fetchCount(Table<?> table) { return selectCount().from(table).fetchOne(0, int.class); }
@Override public int numPreferences() { return dsl .selectCount() .from(DATA) .fetchOne().value1(); }
@Override public int numUsers() { return dsl .selectCount() .from(USERS) .fetchOne().value1(); }
@Override public final long count() { return using(configuration) .selectCount() .from(table) .fetchOne(0, Long.class); }
@Override public /* non-final */ long count() { return using(configuration) .selectCount() .from(table) .fetchOne(0, Long.class); }
@Override public int numItems() { return dsl .selectCount() .from(ITEMS) .fetchOne().value1(); }
@Override public int numUsersWithPreferences() { return dsl .select(DSL.countDistinct(UIDX)) .from(DATA) .fetchOne().value1(); }
@Override public int numItemsWithPreferences() { return dsl .select(DSL.countDistinct(IIDX)) .from(DATA) .fetchOne().value1(); }
@Override public Map<String, Integer> findCollections() { Collection<CollectionSchema> collections = meta.getCollectionSchemes(); Map<String, Integer> result = Maps.newHashMapWithExpectedSize(collections.size()); for (CollectionSchema colSchema : collections) { int firstFree = Routines.firstFreeDocId(jooqConf, colSchema); result.put(colSchema.getCollection(), firstFree); Integer lastUsed = (Integer) getDsl().select(DSL.max(DSL.field("did"))) .from(DSL.table(DSL.name(colSchema.getName(), "root"))) .fetchOne().value1(); LOGGER.debug("Collection {} has {} as last used id", colSchema.getName(), lastUsed); if (lastUsed == null) { lastUsed = 0; } if (lastUsed >= firstFree) { LOGGER.warn( "Collection {}.root: last used = {}. First free = {}", new Object[]{ colSchema.getName(), lastUsed, firstFree } ); } } return result; }
sum(q.field(ENQUEUED.name(), Integer.class))) .from(q) .fetchOne();
@WithTimer public int getDepth(UUID parentInstanceId) { return txResult(tx -> tx.withRecursive("ancestors").as( select(PROCESS_QUEUE.INSTANCE_ID, PROCESS_QUEUE.PARENT_INSTANCE_ID, field("1", Integer.class).as("depth")) .from(PROCESS_QUEUE) .where(PROCESS_QUEUE.INSTANCE_ID.eq(parentInstanceId)) .unionAll( select(PROCESS_QUEUE.INSTANCE_ID, PROCESS_QUEUE.PARENT_INSTANCE_ID, field("1 + ancestors.depth", Integer.class).as("depth")) .from(PROCESS_QUEUE) .join(name("ancestors")) .on(PROCESS_QUEUE.INSTANCE_ID.eq( field(name("ancestors", "PARENT_INSTANCE_ID"), UUID.class))))) .select(max(field(name("ancestors", "depth"), Integer.class))) .from(name("ancestors")) .fetchOne(Record1::value1)); } }