private Result<? extends Record> fetchValues(DSLContext ctx, TableReference tableRef, Select<? extends Record> subQuery) { return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP, A_VALUE) .from(atlasTable(tableRef).as(ATLAS_TABLE)) .join(subQuery.asTable(TEMP_TABLE_2)) .on(A_ROW_NAME.eq(T2_ROW_NAME) .and(A_COL_NAME.eq(T2_COL_NAME)) .and(A_TIMESTAMP.eq(T2_MAX_TIMESTAMP))) .fetch(); }
@Override public Map<Cell, Long> getLatestTimestamps(final TableReference tableRef, final Map<Cell, Long> timestampByCell) { if (timestampByCell.isEmpty()) { return ImmutableMap.of(); } Map<Cell, Long> toReturn = new HashMap<>(); for (List<Entry<Cell, Long>> partition : Iterables.partition(timestampByCell.entrySet(), batchSizeForReads)) { toReturn.putAll(run(ctx -> { Select<? extends Record> query = getLatestTimestampQueryManyTimestamps( ctx, tableRef, toRows(partition)); Result<? extends Record> records = query.fetch(); Map<Cell, Long> results = Maps.newHashMapWithExpectedSize(records.size()); for (Record record : records) { results.put( Cell.create(record.getValue(A_ROW_NAME), record.getValue(A_COL_NAME)), record.getValue(MAX_TIMESTAMP, Long.class)); } return results; })); } return toReturn; }
final Select<Record> insertSelect() { Select<Record> select = null; for (int row = 0; row < rows; row++) { List<Field<?>> fields = new ArrayList<Field<?>>(values.size()); for (List<Field<?>> list : values.values()) fields.add(list.get(row)); Select<Record> iteration = DSL.select(fields); if (select == null) select = iteration; else select = select.unionAll(iteration); } return select; }
private final Table<Record> table(Configuration configuration) { if (table == null) { Select<Record> select = null; for (Object element : array) { // [#1081] Be sure to get the correct cast type also for null Field<?> val = DSL.val(element, field.fields[0].getDataType()); Select<Record> subselect = using(configuration).select(val.as("COLUMN_VALUE")).select(); if (select == null) { select = subselect; } else { select = select.unionAll(subselect); } } // Empty arrays should result in empty tables if (select == null) { select = using(configuration).select(one().as("COLUMN_VALUE")).select().where(falseCondition()); } table = select.asTable(alias); } return table; } }
@Override public final <T, U> U fetchAny(Field<T> field, Converter<? super T, ? extends U> converter) { return getDelegate().fetchAny(field, converter); }
@Override public final Map<?, Result<R>> fetchGroups(String keyFieldName) { return getDelegate().fetchGroups(keyFieldName); }
@Override public final R[] fetchArray() { return getDelegate().fetchArray(); }
@Override public final <T> Field<T> asField() { return getDelegate().asField(); }
@Override @Deprecated public final int fetchCount() { return getDelegate().fetchCount(); }
@Override public final Object[][] fetchArrays() { return getDelegate().fetchArrays(); }
@Override public final SelectImpl except(Select<? extends R> select) { return new SelectImpl(getDelegate().except(select)); }
@Override public final Object fetchAny(String fieldName) { return getDelegate().fetchAny(fieldName); }
@Override public final Map<?, Result<R>> fetchGroups(Name keyFieldName) { return getDelegate().fetchGroups(keyFieldName); }
@Override public final Object[] fetchArray(int fieldIndex) { return getDelegate().fetchArray(fieldIndex); }
@Override public final <T> InsertImpl set(Field<T> field, Select<? extends Record1<T>> value) { return set(field, value.<T>asField()); }
@Override public final int fetchCount() { return getDelegate().fetchCount(); }
@Override public final Object[][] fetchArrays() { return getDelegate().fetchArrays(); }
@Override public final SelectImpl except(Select<? extends R> select) { return new SelectImpl(getDelegate().except(select)); }
/** * A synonym for {@link Select#asTable()}, which might look a bit more fluent * like this, to some users. * * @see Select#asTable() */ @Support public static <R extends Record> Table<R> table(Select<R> select) { return select.asTable(); }
query = getAllTimestampsQuerySomeColumns(ctx, tableRef, rangeQuery, rangeRequest.getColumnNames(), timestamp); Result<? extends Record> records = query.fetch(); if (records.isEmpty()) { return SimpleTokenBackedResultsPage.create(null, ImmutableList.<RowResult<Set<Long>>>of(), false);