You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/09/22 09:30:25 UTC
[GitHub] [ignite-3] AMashenkov commented on a diff in pull request #1110: IGNITE-17562 Sql. Implement cascade drop for indexes
AMashenkov commented on code in PR #1110:
URL: https://github.com/apache/ignite-3/pull/1110#discussion_r977424782
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -1234,42 +1232,47 @@ private CompletableFuture<Void> dropTableAsyncInternal(String name) {
if (tbl == null) {
dropTblFut.completeExceptionally(new TableNotFoundException(name));
} else {
- tablesCfg.tables()
+ List<CompletableFuture<Void>> idxsChange = new ArrayList<>();
+
+ CompletableFuture<Void> tblOps = tablesCfg.tables()
.change(change -> {
TableView tableCfg = change.get(name);
if (tableCfg == null) {
throw new TableNotFoundException(name);
}
- NamedListView<TableIndexView> idxView = tablesCfg.indexes().value();
+ change.delete(name);
+
+ List<String> indicesNames = tablesCfg.indexes().value().namedListKeys();
- boolean idxFound = idxView.namedListKeys().stream()
- .anyMatch(idx -> idxView.get(idx).tableId().equals(tbl.tableId()));
+ List<String> indexes = indicesNames.stream().filter(idx ->
+ tablesCfg.indexes().get(idx).tableId().value().equals(tbl.tableId())).collect(Collectors.toList());
- //TODO: https://issues.apache.org/jira/browse/IGNITE-17562
- // Let's drop orphaned indices instantly.
- if (idxFound) {
- throw new IgniteException("Can't drop table with indices.");
+ for (String indexName : indexes) {
+ idxsChange.add(tablesCfg.indexes().change(chg -> chg.delete(indexName)));
Review Comment:
What if external changer will be called more than once?
Should `idxsChange` be cleaned at first?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org