private Select<? extends Record> getAllTimestampsQuerySomeColumns(DSLContext ctx, TableReference tableRef, Select<Record1<byte[]>> subQuery, Collection<byte[]> cols, long timestamp) { return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP) .from(atlasTable(tableRef).as(ATLAS_TABLE)) .where(A_ROW_NAME.in(subQuery) .and(A_COL_NAME.in(cols))) .and(A_TIMESTAMP.lessThan(timestamp)); }
private Select<? extends Record> getLatestTimestampQuerySomeColumns(DSLContext ctx, TableReference tableRef, Collection<byte[]> rows, Collection<byte[]> cols, long timestamp) { return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP)) .from(atlasTable(tableRef).as(ATLAS_TABLE)) .where(A_ROW_NAME.in(rows) .and(A_COL_NAME.in(cols))) .and(A_TIMESTAMP.lessThan(timestamp)) .groupBy(A_ROW_NAME, A_COL_NAME); }
private Select<? extends Record> getLatestTimestampQuerySomeColumnsSubQuery(DSLContext ctx, TableReference tableRef, Select<Record1<byte[]>> subQuery, Collection<byte[]> cols, long timestamp) { return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP)) .from(atlasTable(tableRef).as(ATLAS_TABLE)) .where(A_ROW_NAME.in(subQuery) .and(A_COL_NAME.in(cols))) .and(A_TIMESTAMP.lessThan(timestamp)) .groupBy(A_ROW_NAME, A_COL_NAME); }
@Override public void dropTables(final Set<TableReference> tableRefs) throws InsufficientConsistencyException { if (tableRefs.isEmpty()) { return; } run((Function<DSLContext, Void>) ctx -> { for (TableReference tableRef : tableRefs) { ctx.dropTableIfExists(tableName(tableRef)).execute(); } ctx.deleteFrom(METADATA_TABLE) .where(TABLE_NAME.in(tableRefs)) .execute(); return null; }); }
private Select<? extends Record> getAllTimestampsQueryAllColumns(DSLContext ctx, TableReference tableRef, Select<Record1<byte[]>> subQuery, long timestamp) { return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP) .from(atlasTable(tableRef).as(ATLAS_TABLE)) .where(A_ROW_NAME.in(subQuery) .and(A_TIMESTAMP.lessThan(timestamp))); }
private Select<? extends Record> getLatestTimestampQueryAllColumnsSubQuery(DSLContext ctx, TableReference tableRef, Select<Record1<byte[]>> subQuery, long timestamp) { return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP)) .from(atlasTable(tableRef).as(ATLAS_TABLE)) .where(A_ROW_NAME.in(subQuery) .and(A_TIMESTAMP.lessThan(timestamp))) .groupBy(A_ROW_NAME, A_COL_NAME); }
private Select<? extends Record> getLatestTimestampQueryAllColumns(DSLContext ctx, TableReference tableRef, Collection<byte[]> rows, long timestamp) { return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP)) .from(atlasTable(tableRef).as(ATLAS_TABLE)) .where(A_ROW_NAME.in(rows) .and(A_TIMESTAMP.lessThan(timestamp))) .groupBy(A_ROW_NAME, A_COL_NAME); }
/** * Find records by a given field and a set of values asynchronously. * * @param field The field to compare values against * @param values The accepted values * @param resultHandler the resultHandler which succeeds when the blocking method of this type succeeds or fails * with an <code>DataAccessException</code> if the blocking method of this type throws an exception * @param <Z> the value type */ default <Z> void fetchAsync(Field<Z> field, Collection<Z> values, Handler<AsyncResult<List<P>>> resultHandler){ fetchAsync(field.in(values),resultHandler); }
/** * Find records by a given field and a set of values asynchronously. * * @param field The field to compare values against * @param values The accepted values * @return Single which succeeds when the blocking method of this type succeeds or fails * with an <code>DataAccessException</code> if the blocking method of this type throws an exception */ default <Z> Single<List<P>> fetchAsync(Field<Z> field, Collection<Z> values) { return fetchAsync(field.in(values)); }
/** * Find records by a given field and a set of values asynchronously. * * @param field The field to compare values against * @param values The accepted values * @param <Z> the value type * @return CompletableFuture which succeeds when the blocking method of this type succeeds or fails * with an <code>DataAccessException</code> if the blocking method of this type throws an exception */ default <Z> CompletableFuture<List<P>> fetchAsync(Field<Z> field, Collection<Z> values){ return fetchAsync(field.in(values)); }
/** * Find records by a given field and a set of values asynchronously. * * @param field The field to compare values against * @param values The accepted values * @param resultHandler the resultHandler which succeeds when the blocking method of this type succeeds or fails * with an <code>DataAccessException</code> if the blocking method of this type throws an exception * @param <Z> the value type */ default <Z> void fetchAsync(Field<Z> field, Collection<Z> values, Handler<AsyncResult<List<P>>> resultHandler){ fetchAsync(field.in(values),resultHandler); }
/** * Find records by a given field and a set of values asynchronously. * * @param field The field to compare values against * @param values The accepted values * @param <Z> the value type * @return CompletableFuture which succeeds when the blocking method of this type succeeds or fails * with an <code>DataAccessException</code> if the blocking method of this type throws an exception */ default <Z> CompletableFuture<List<P>> fetchAsync(Field<Z> field, Collection<Z> values){ return fetchAsync(field.in(values)); }
/** * Find records by a given field and a set of values asynchronously. * * @param field The field to compare values against * @param values The accepted values * @return Single which succeeds when the blocking method of this type succeeds or fails * with an <code>DataAccessException</code> if the blocking method of this type throws an exception */ default <Z> Single<List<P>> fetchAsync(Field<Z> field, Collection<Z> values) { return fetchAsync(field.in(values)); }
private final <U> Condition equal(Field<U> pk, Collection<T> ids) { if (ids.size() == 1) { return equal(pk, ids.iterator().next()); } else { return pk.in(pk.getDataType().convert(ids)); } }
@SuppressWarnings({ "unchecked" }) @Override public final Condition isFalse() { Class<?> type = getType(); if (type == String.class) return ((Field<String>) this).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING))); else if (Number.class.isAssignableFrom(type)) return ((Field<Number>) this).equal(inline((Number) getDataType().convert(0))); else if (Boolean.class.isAssignableFrom(type)) return ((Field<Boolean>) this).equal(inline(false)); else return cast(String.class).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING))); }
@SuppressWarnings({ "unchecked" }) @Override public final Condition isTrue() { Class<?> type = getType(); if (type == String.class) return ((Field<String>) this).in(Tools.inline(TRUE_VALUES.toArray(EMPTY_STRING))); else if (Number.class.isAssignableFrom(type)) return ((Field<Number>) this).equal(inline((Number) getDataType().convert(1))); else if (Boolean.class.isAssignableFrom(type)) return ((Field<Boolean>) this).equal(inline(true)); else return cast(String.class).in(TRUE_VALUES); }
@Override public void deleteByIds(Collection<ID> ids) { getDSLContext().delete(table).where(primaryKey.in(ids)).execute(); }
private void addFkRecords(ReflectedTable t2, HashMap<Object, Object> fkValues, Params params, DSLContext dsl, ArrayList<Record> records) { Field<Object> pk = t2.getPk(); ArrayList<Field<?>> fields = columns.getNames(t2, false, params); ResultQuery<org.jooq.Record> query = dsl.select(fields).from(t2).where(pk.in(fkValues.keySet())); for (org.jooq.Record record : query.fetch()) { records.add(Record.valueOf(record.intoMap())); } }
@SuppressWarnings("unchecked") @Override public /* non-final */ <Z> List<P> fetch(Field<Z> field, Z... values) { return using(configuration) .selectFrom(table) .where(field.in(values)) .fetch() .map(mapper()); }
@Override public final <Z> List<P> fetch(Field<Z> field, Z... values) { return using(configuration) .selectFrom(table) .where(field.in(values)) .fetch() .map(mapper()); }