org.jooq.Table.as()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(302)

本文整理了Java中org.jooq.Table.as()方法的一些代码示例,展示了Table.as()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.as()方法的具体详情如下:
包路径:org.jooq.Table
类名称:Table
方法名:as

Table.as介绍

[英]Create an alias for this table.

Note that the case-sensitivity of the returned table depends on Settings#getRenderNameStyle(). By default, table aliases are quoted, and thus case-sensitive!
[中]为此表创建别名。
请注意,返回表的大小写敏感度取决于设置#getRenderNameStyle()。默认情况下,会引用表别名,因此区分大小写!

代码示例

代码示例来源:origin: palantir/atlasdb

  1. @Override
  2. public void delete(final TableReference tableRef, final Multimap<Cell, Long> keys) {
  3. if (keys.isEmpty()) {
  4. return;
  5. }
  6. for (List<Entry<Cell, Long>> partition : Iterables.partition(keys.entries(), batchSizeForMutations)) {
  7. run((Function<DSLContext, Void>) ctx -> {
  8. Collection<Row3<byte[], byte[], Long>> rows = Lists.newArrayListWithCapacity(partition.size());
  9. for (Entry<Cell, Long> entry : partition) {
  10. rows.add(row(entry.getKey().getRowName(), entry.getKey().getColumnName(), entry.getValue()));
  11. }
  12. ctx.deleteFrom(atlasTable(tableRef).as(ATLAS_TABLE))
  13. .where(row(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP).in(rows))
  14. .execute();
  15. return null;
  16. });
  17. }
  18. }

代码示例来源:origin: palantir/atlasdb

  1. private Select<? extends Record> getAllTimestampsQueryAllColumns(DSLContext ctx,
  2. TableReference tableRef,
  3. Select<Record1<byte[]>> subQuery,
  4. long timestamp) {
  5. return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP)
  6. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  7. .where(A_ROW_NAME.in(subQuery)
  8. .and(A_TIMESTAMP.lessThan(timestamp)));
  9. }

代码示例来源:origin: palantir/atlasdb

  1. @Override
  2. public Multimap<Cell, Long> getAllTimestamps(final TableReference tableRef,
  3. final Set<Cell> cells,
  4. final long timestamp) throws InsufficientConsistencyException {
  5. if (cells.isEmpty()) {
  6. return ImmutableMultimap.of();
  7. }
  8. Multimap<Cell, Long> toReturn = ArrayListMultimap.create();
  9. for (List<Cell> partition : Iterables.partition(cells, batchSizeForReads)) {
  10. toReturn.putAll(run(ctx -> {
  11. Result<? extends Record> records = ctx
  12. .select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP)
  13. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  14. .join(values(ctx, toRows(Sets.newHashSet(partition)), TEMP_TABLE_1, ROW_NAME, COL_NAME))
  15. .on(A_ROW_NAME.eq(T1_ROW_NAME)
  16. .and(A_COL_NAME.eq(T1_COL_NAME)))
  17. .where(A_TIMESTAMP.lessThan(timestamp))
  18. .fetch();
  19. Multimap<Cell, Long> results = ArrayListMultimap.create(records.size() / 4, 4);
  20. for (Record record : records) {
  21. results.put(
  22. Cell.create(record.getValue(A_ROW_NAME), record.getValue(A_COL_NAME)),
  23. record.getValue(A_TIMESTAMP));
  24. }
  25. return results;
  26. }));
  27. }
  28. return toReturn;
  29. }

代码示例来源:origin: palantir/atlasdb

  1. private Select<? extends Record> getAllTimestampsQuerySomeColumns(DSLContext ctx,
  2. TableReference tableRef,
  3. Select<Record1<byte[]>> subQuery,
  4. Collection<byte[]> cols,
  5. long timestamp) {
  6. return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP)
  7. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  8. .where(A_ROW_NAME.in(subQuery)
  9. .and(A_COL_NAME.in(cols)))
  10. .and(A_TIMESTAMP.lessThan(timestamp));
  11. }

代码示例来源:origin: palantir/atlasdb

  1. private Select<? extends Record> getLatestTimestampQueryAllColumnsSubQuery(DSLContext ctx,
  2. TableReference tableRef,
  3. Select<Record1<byte[]>> subQuery,
  4. long timestamp) {
  5. return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
  6. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  7. .where(A_ROW_NAME.in(subQuery)
  8. .and(A_TIMESTAMP.lessThan(timestamp)))
  9. .groupBy(A_ROW_NAME, A_COL_NAME);
  10. }

代码示例来源:origin: palantir/atlasdb

  1. private Select<? extends Record> getLatestTimestampQueryAllColumns(DSLContext ctx,
  2. TableReference tableRef,
  3. Collection<byte[]> rows,
  4. long timestamp) {
  5. return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
  6. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  7. .where(A_ROW_NAME.in(rows)
  8. .and(A_TIMESTAMP.lessThan(timestamp)))
  9. .groupBy(A_ROW_NAME, A_COL_NAME);
  10. }

代码示例来源:origin: palantir/atlasdb

  1. TableLike<?> values(DSLContext ctx, RowN[] rows, String tableName, String... fieldNames) {
  2. switch (sqlDialect.family()) {
  3. case H2:
  4. List<SelectField<?>> fields = Lists.newArrayListWithCapacity(fieldNames.length);
  5. for (int i = 1; i <= fieldNames.length; i++) {
  6. fields.add(DSL.field("C" + i).as(fieldNames[i-1]));
  7. }
  8. RenderContext context = ctx.renderContext();
  9. context.start(TABLE_VALUES)
  10. .keyword("values")
  11. .formatIndentLockStart();
  12. boolean firstRow = true;
  13. for (Row row : rows) {
  14. if (!firstRow) {
  15. context.sql(',').formatSeparator();
  16. }
  17. context.sql(row.toString());
  18. firstRow = false;
  19. }
  20. context.formatIndentLockEnd()
  21. .end(TABLE_VALUES);
  22. String valuesClause = context.render();
  23. return ctx.select(fields).from(valuesClause).asTable(tableName);
  24. default:
  25. return DSL.values(rows).as(tableName, fieldNames);
  26. }
  27. }

代码示例来源:origin: palantir/atlasdb

  1. private Result<? extends Record> fetchValues(DSLContext ctx,
  2. TableReference tableRef,
  3. Select<? extends Record> subQuery) {
  4. return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP, A_VALUE)
  5. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  6. .join(subQuery.asTable(TEMP_TABLE_2))
  7. .on(A_ROW_NAME.eq(T2_ROW_NAME)
  8. .and(A_COL_NAME.eq(T2_COL_NAME))
  9. .and(A_TIMESTAMP.eq(T2_MAX_TIMESTAMP)))
  10. .fetch();
  11. }

代码示例来源:origin: palantir/atlasdb

  1. private Select<? extends Record> getLatestTimestampQuerySomeColumns(DSLContext ctx,
  2. TableReference tableRef,
  3. Collection<byte[]> rows,
  4. Collection<byte[]> cols,
  5. long timestamp) {
  6. return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
  7. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  8. .where(A_ROW_NAME.in(rows)
  9. .and(A_COL_NAME.in(cols)))
  10. .and(A_TIMESTAMP.lessThan(timestamp))
  11. .groupBy(A_ROW_NAME, A_COL_NAME);
  12. }

代码示例来源:origin: palantir/atlasdb

  1. private Select<? extends Record> getLatestTimestampQuerySomeColumnsSubQuery(DSLContext ctx,
  2. TableReference tableRef,
  3. Select<Record1<byte[]>> subQuery,
  4. Collection<byte[]> cols,
  5. long timestamp) {
  6. return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
  7. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  8. .where(A_ROW_NAME.in(subQuery)
  9. .and(A_COL_NAME.in(cols)))
  10. .and(A_TIMESTAMP.lessThan(timestamp))
  11. .groupBy(A_ROW_NAME, A_COL_NAME);
  12. }

代码示例来源:origin: palantir/atlasdb

  1. private Select<? extends Record> getLatestTimestampQueryManyTimestamps(DSLContext ctx,
  2. TableReference tableRef,
  3. RowN[] rows) {
  4. return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
  5. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  6. .join(values(ctx, rows, TEMP_TABLE_1, ROW_NAME, COL_NAME, TIMESTAMP))
  7. .on(A_ROW_NAME.eq(T1_ROW_NAME)
  8. .and(A_COL_NAME.eq(T1_COL_NAME)))
  9. .where(A_TIMESTAMP.lessThan(T1_TIMESTAMP))
  10. .groupBy(A_ROW_NAME, A_COL_NAME);
  11. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

  1. @Override
  2. public final Table<Record> as(String alias) {
  3. if (force) {
  4. return FORCED_DUAL.as(alias);
  5. }
  6. else {
  7. return new TableAlias<Record>(this, alias);
  8. }
  9. }

代码示例来源:origin: org.jooq/jooq

  1. @Override
  2. public final Table<Record> as(Name alias) {
  3. if (force) {
  4. return FORCED_DUAL.as(alias);
  5. }
  6. else {
  7. return new TableAlias<Record>(this, alias);
  8. }
  9. }

代码示例来源:origin: org.jooq/jooq

  1. @Override
  2. public final Table<Record> as(Name alias, Name... fieldAliases) {
  3. if (force) {
  4. return FORCED_DUAL.as(alias, fieldAliases);
  5. }
  6. else {
  7. return new TableAlias<Record>(this, alias, fieldAliases);
  8. }
  9. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

  1. @Override
  2. public final Table<Record> as(String alias, String... fieldAliases) {
  3. if (force) {
  4. return FORCED_DUAL.as(alias, fieldAliases);
  5. }
  6. else {
  7. return new TableAlias<Record>(this, alias, fieldAliases);
  8. }
  9. }

代码示例来源:origin: com.torodb.torod.backends/postgresql

  1. @Nonnull
  2. @Override
  3. public Table arrayElements(Field<?> iteratorVariable, Field<?> field) {
  4. return DSL.table("jsonb_array_elements(" + field.toString() + ")").as(iteratorVariable.toString());
  5. }

代码示例来源:origin: palantir/atlasdb

  1. private SelectOffsetStep<Record1<byte[]>> getRangeQuery(DSLContext ctx,
  2. TableReference tableRef,
  3. RangeRequest rangeRequest,
  4. long timestamp,
  5. int maxRows) {
  6. boolean reverse = rangeRequest.isReverse();
  7. byte[] start = rangeRequest.getStartInclusive();
  8. byte[] end = rangeRequest.getEndExclusive();
  9. Condition cond = R_TIMESTAMP.lessThan(timestamp);
  10. if (start.length > 0) {
  11. cond = cond.and(reverse ? R_ROW_NAME.lessOrEqual(start) : R_ROW_NAME.greaterOrEqual(start));
  12. }
  13. if (end.length > 0) {
  14. cond = cond.and(reverse ? R_ROW_NAME.greaterThan(end) : R_ROW_NAME.lessThan(end));
  15. }
  16. return ctx.selectDistinct(R_ROW_NAME)
  17. .from(atlasTable(tableRef).as(RANGE_TABLE))
  18. .where(cond)
  19. .orderBy(reverse ? R_ROW_NAME.desc() : R_ROW_NAME.asc())
  20. .limit(maxRows);
  21. }

代码示例来源:origin: palantir/atlasdb

  1. .from(values(ctx, rows, TEMP_TABLE_1, ROW_NAME, COL_NAME, TIMESTAMP, VALUE))
  2. .whereNotExists(ctx.selectOne()
  3. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  4. .where(A_ROW_NAME.eq(T1_ROW_NAME)
  5. .and(A_COL_NAME.eq(T1_COL_NAME))

代码示例来源:origin: palantir/atlasdb

  1. private void putBatch(DSLContext ctx, TableReference tableRef, PutBatch batch, boolean allowReinserts) {
  2. InsertValuesStep4<Record, byte[], byte[], Long, byte[]> query =
  3. ctx.insertInto(table(tableName(tableRef)),
  4. field(ROW_NAME, byte[].class),
  5. field(COL_NAME, byte[].class),
  6. field(TIMESTAMP, Long.class),
  7. field(VALUE, byte[].class));
  8. query = batch.addValuesForInsert(query);
  9. try {
  10. query.execute();
  11. } catch (DataAccessException e) {
  12. if (allowReinserts) {
  13. Result<? extends Record> records = ctx
  14. .select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP, A_VALUE)
  15. .from(atlasTable(tableRef).as(ATLAS_TABLE))
  16. .where(row(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP).in(batch.getRowsForSelect()))
  17. .fetch();
  18. if (records.isEmpty()) {
  19. throw e;
  20. }
  21. PutBatch nextBatch = batch.getNextBatch(records);
  22. if (nextBatch != null) {
  23. putBatch(ctx, tableRef, nextBatch, allowReinserts);
  24. return;
  25. }
  26. }
  27. throw new KeyAlreadyExistsException("Conflict on table " + tableRef, e);
  28. }
  29. }

代码示例来源:origin: infiniteautomation/ma-core-public

  1. @Override
  2. public <R extends Record> SelectJoinStep<R> joinTables(SelectJoinStep<R> select, ConditionSortLimit conditions) {
  3. if (conditions instanceof ConditionSortLimitWithTagKeys) {
  4. Map<String, Name> tagKeyToColumn = ((ConditionSortLimitWithTagKeys) conditions).getTagKeyToColumn();
  5. if (!tagKeyToColumn.isEmpty()) {
  6. Table<Record> pivotTable = DataPointTagsDao.getInstance().createTagPivotSql(tagKeyToColumn).asTable().as(DATA_POINT_TAGS_PIVOT_ALIAS);
  7. return select.leftJoin(pivotTable)
  8. .on(DataPointTagsDao.PIVOT_ALIAS_DATA_POINT_ID.eq(ID));
  9. }
  10. }
  11. return select;
  12. }

相关文章