private String generateCreateIndex(ColumnDesc cd, boolean unique) { StringBuilder sb = new StringBuilder(); sb.append("CREATE"); if (unique) { sb.append(" UNIQUE"); } sb.append(" INDEX "); String indexName = "i_" + cd.getTableName().replace(".", "_") + "_" + cd.getColumnName(); sb.append(indexName); sb.append(" ON ").append(cd.getTableName()); String using = ddType.getIndexUsingQualifier(cd, unique); if (using != null) { sb.append(" USING ").append(using); } sb.append(" ("); sb.append(cd.getColumnName()); String iop = ddType.getIndexColumnOperator(cd); if (iop != null) { sb.append(" ").append(iop); } sb.append(")"); return sb.toString(); } }
/** * Creates Lists of Columns with a common Table name, then adds the Lists to the Tables. * * @param tableDescs List of Tables. * @param columnDescs List of Columns. */ private void addColumnsToTables(List<TableDesc> tableDescs, List<ColumnDesc> columnDescs) { for (ColumnDesc col : columnDescs) { for (TableDesc tableDesc : tableDescs) { if (col.getTableName().equals(tableDesc.getTableName())) { tableDesc.getColumnDescs().add(col); break; } } } }
/** * A normal column with an alternate name (alias). * All metadata is copied from the specified column descriptor. * * @param name * @param column */ public TapSelectItem(String name, ColumnDesc column) { this(name, column.getDatatype()); this.columnName = column.getColumnName(); this.tableName = column.getTableName(); this.description = column.description; this.id = column.id; this.indexed = column.indexed; this.principal = column.principal; this.std = column.std; this.ucd = column.ucd; this.unit = column.unit; this.utype = column.utype; }
public void createIndex(ColumnDesc cd, boolean unique) { try { TapSchemaUtil.checkValidTableName(cd.getTableName()); } catch (ADQLIdentifierException ex) { throw new IllegalArgumentException("invalid table name: " + cd.getTableName(), ex); throw ex; throw new RuntimeException("failed to create index on " + cd.getTableName() + "(" + cd.getColumnName() + ")", ex); } finally { if (tm.isOpen()) {
safeSetString(sb, ps, col++, column.id); safeSetInteger(sb, ps, col++, column.column_index); safeSetString(sb, ps, col++, column.getTableName()); safeSetString(sb, ps, col++, column.getColumnName()); log.debug("values: " + sb.toString());
ColumnDesc newColumnDesc = new ColumnDesc(columnDesc.getTableName(), columnDesc.getColumnName(), columnDesc.getDatatype()); newTableDesc.getColumnDescs().add(newColumnDesc);