|
27 | 27 | import org.apache.iotdb.commons.exception.IllegalPathException; |
28 | 28 | import org.apache.iotdb.commons.exception.MetadataException; |
29 | 29 | import org.apache.iotdb.commons.exception.SemanticException; |
30 | | -import org.apache.iotdb.commons.exception.table.ColumnInAlterException; |
31 | | -import org.apache.iotdb.commons.exception.table.ColumnInDeletionException; |
32 | | -import org.apache.iotdb.commons.exception.table.TableInDeletionException; |
33 | 30 | import org.apache.iotdb.commons.path.PartialPath; |
34 | 31 | import org.apache.iotdb.commons.path.PathPatternTree; |
35 | 32 | import org.apache.iotdb.commons.schema.table.TableNodeStatus; |
36 | 33 | import org.apache.iotdb.commons.schema.table.TableType; |
37 | 34 | import org.apache.iotdb.commons.schema.table.TreeViewSchema; |
38 | 35 | import org.apache.iotdb.commons.schema.table.TsTable; |
39 | 36 | import org.apache.iotdb.commons.schema.table.TsTableInternalRPCUtil; |
40 | | -import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema; |
41 | 37 | import org.apache.iotdb.commons.schema.template.Template; |
42 | 38 | import org.apache.iotdb.commons.snapshot.SnapshotProcessor; |
43 | 39 | import org.apache.iotdb.commons.utils.PathUtils; |
|
71 | 67 | import org.apache.iotdb.confignode.consensus.request.write.table.RenameTableColumnPlan; |
72 | 68 | import org.apache.iotdb.confignode.consensus.request.write.table.RenameTablePlan; |
73 | 69 | import org.apache.iotdb.confignode.consensus.request.write.table.RollbackCreateTablePlan; |
74 | | -import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreAlterColumnDataTypePlan; |
75 | 70 | import org.apache.iotdb.confignode.consensus.request.write.table.RollbackPreDeleteTablePlan; |
76 | 71 | import org.apache.iotdb.confignode.consensus.request.write.table.SetTableColumnCommentPlan; |
77 | 72 | import org.apache.iotdb.confignode.consensus.request.write.table.SetTableCommentPlan; |
|
114 | 109 | import org.apache.iotdb.rpc.TSStatusCode; |
115 | 110 |
|
116 | 111 | import org.apache.tsfile.annotations.TableModel; |
117 | | -import org.apache.tsfile.enums.TSDataType; |
118 | 112 | import org.apache.tsfile.utils.Pair; |
119 | 113 | import org.slf4j.Logger; |
120 | 114 | import org.slf4j.LoggerFactory; |
@@ -1358,11 +1352,9 @@ public ShowTableResp showTables(final ShowTablePlan plan) { |
1358 | 1352 | }) |
1359 | 1353 | .collect(Collectors.toList()) |
1360 | 1354 | : tableModelMTree |
1361 | | - .getAllTablesUnderSpecificDatabase( |
| 1355 | + .getAllUsingTablesUnderSpecificDatabase( |
1362 | 1356 | getQualifiedDatabasePartialPath(plan.getDatabase())) |
1363 | 1357 | .stream() |
1364 | | - .filter(pair -> pair.getRight() != TableNodeStatus.PRE_CREATE) |
1365 | | - .map(Pair::getLeft) |
1366 | 1358 | .map( |
1367 | 1359 | tsTable -> |
1368 | 1360 | new TTableInfo( |
@@ -1455,7 +1447,7 @@ public DescTableResp descTable(final DescTablePlan plan) { |
1455 | 1447 | } |
1456 | 1448 | return new DescTableResp( |
1457 | 1449 | StatusUtils.OK, |
1458 | | - tableModelMTree.getTableSchemaForDesc(databasePath, plan.getTableName()), |
| 1450 | + tableModelMTree.getUsingTableSchema(databasePath, plan.getTableName()), |
1459 | 1451 | null, |
1460 | 1452 | null); |
1461 | 1453 | } catch (final MetadataException e) { |
@@ -1565,80 +1557,6 @@ public Optional<Pair<TsTable, TableNodeStatus>> getTsTableIfExists( |
1565 | 1557 | } |
1566 | 1558 | } |
1567 | 1559 |
|
1568 | | - public TsTable getTableForModification( |
1569 | | - final String database, final String tableName, final String... columnNames) |
1570 | | - throws MetadataException { |
1571 | | - databaseReadWriteLock.readLock().lock(); |
1572 | | - try { |
1573 | | - final PartialPath databasePath = getQualifiedDatabasePartialPath(database); |
1574 | | - final Optional<Pair<TsTable, TableNodeStatus>> tableAndStatus = |
1575 | | - tableModelMTree.getTableAndStatusIfExists(databasePath, tableName); |
1576 | | - if (!tableAndStatus.isPresent()) { |
1577 | | - return null; |
1578 | | - } |
1579 | | - if (tableAndStatus.get().getRight() == TableNodeStatus.PRE_DELETE) { |
1580 | | - throw new TableInDeletionException(database, tableName); |
1581 | | - } |
1582 | | - final TableSchemaDetails details = |
1583 | | - tableModelMTree.getTableSchemaDetails(databasePath, tableName); |
1584 | | - for (final String columnName : columnNames) { |
1585 | | - if (details.preDeletedColumns.contains(columnName)) { |
1586 | | - throw new ColumnInDeletionException(database, tableName, columnName); |
1587 | | - } |
1588 | | - if (details.preAlteredColumns.containsKey(columnName)) { |
1589 | | - throw new ColumnInAlterException(database, tableName, columnName); |
1590 | | - } |
1591 | | - } |
1592 | | - return tableModelMTree.getTableSchemaForDataNode(databasePath, tableName); |
1593 | | - } finally { |
1594 | | - databaseReadWriteLock.readLock().unlock(); |
1595 | | - } |
1596 | | - } |
1597 | | - |
1598 | | - public boolean isColumnAlterCommitted( |
1599 | | - final String database, |
1600 | | - final String tableName, |
1601 | | - final String columnName, |
1602 | | - final TSDataType dataType) |
1603 | | - throws MetadataException { |
1604 | | - databaseReadWriteLock.readLock().lock(); |
1605 | | - try { |
1606 | | - final PartialPath databasePath = getQualifiedDatabasePartialPath(database); |
1607 | | - final Optional<Pair<TsTable, TableNodeStatus>> tableAndStatus = |
1608 | | - tableModelMTree.getTableAndStatusIfExists(databasePath, tableName); |
1609 | | - if (!tableAndStatus.isPresent()) { |
1610 | | - return false; |
1611 | | - } |
1612 | | - final TableSchemaDetails details = |
1613 | | - tableModelMTree.getTableSchemaDetails(databasePath, tableName); |
1614 | | - final TsTableColumnSchema columnSchema = details.table.getColumnSchema(columnName); |
1615 | | - return !details.preAlteredColumns.containsKey(columnName) |
1616 | | - && columnSchema != null |
1617 | | - && columnSchema.getDataType() == dataType; |
1618 | | - } finally { |
1619 | | - databaseReadWriteLock.readLock().unlock(); |
1620 | | - } |
1621 | | - } |
1622 | | - |
1623 | | - public Optional<TSDataType> getPreAlteredColumnType( |
1624 | | - final String database, final String tableName, final String columnName) |
1625 | | - throws MetadataException { |
1626 | | - databaseReadWriteLock.readLock().lock(); |
1627 | | - try { |
1628 | | - final PartialPath databasePath = getQualifiedDatabasePartialPath(database); |
1629 | | - if (!tableModelMTree.getTableAndStatusIfExists(databasePath, tableName).isPresent()) { |
1630 | | - return Optional.empty(); |
1631 | | - } |
1632 | | - return Optional.ofNullable( |
1633 | | - tableModelMTree |
1634 | | - .getTableSchemaDetails(databasePath, tableName) |
1635 | | - .preAlteredColumns |
1636 | | - .get(columnName)); |
1637 | | - } finally { |
1638 | | - databaseReadWriteLock.readLock().unlock(); |
1639 | | - } |
1640 | | - } |
1641 | | - |
1642 | 1560 | public TSStatus addTableColumn(final AddTableColumnPlan plan) { |
1643 | 1561 | return executeWithLock( |
1644 | 1562 | () -> { |
@@ -1726,23 +1644,6 @@ public TSStatus preAlterColumnDataType(final PreAlterColumnDataTypePlan plan) { |
1726 | 1644 | } |
1727 | 1645 | } |
1728 | 1646 |
|
1729 | | - public TSStatus rollbackPreAlterColumnDataType(final RollbackPreAlterColumnDataTypePlan plan) { |
1730 | | - databaseReadWriteLock.writeLock().lock(); |
1731 | | - try { |
1732 | | - tableModelMTree.rollbackPreAlterColumnDataType( |
1733 | | - getQualifiedDatabasePartialPath(plan.getDatabase()), |
1734 | | - plan.getTableName(), |
1735 | | - plan.getColumnName(), |
1736 | | - plan.getNewType()); |
1737 | | - return RpcUtils.SUCCESS_STATUS; |
1738 | | - } catch (final MetadataException e) { |
1739 | | - LOGGER.warn(e.getMessage(), e); |
1740 | | - return RpcUtils.getStatus(e.getErrorCode(), e.getMessage()); |
1741 | | - } finally { |
1742 | | - databaseReadWriteLock.writeLock().unlock(); |
1743 | | - } |
1744 | | - } |
1745 | | - |
1746 | 1647 | public TSStatus commitAlterColumnDataType(AlterColumnDataTypePlan plan) { |
1747 | 1648 | databaseReadWriteLock.writeLock().lock(); |
1748 | 1649 | try { |
|
0 commit comments