-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IGNITE-24247 Indexes created with table must be created in AVAILABLE …
…state (wip).
- Loading branch information
Showing
51 changed files
with
415 additions
and
342 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/BulkUpdateProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.catalog; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.ignite.internal.catalog.storage.UpdateEntry; | ||
|
||
/** | ||
* Update producer that is used to group updates | ||
* when executing a batch of catalog commands. | ||
*/ | ||
class BulkUpdateProducer implements UpdateProducer { | ||
private final List<? extends UpdateProducer> commands; | ||
|
||
BulkUpdateProducer(List<? extends UpdateProducer> producers) { | ||
this.commands = producers; | ||
} | ||
|
||
@Override | ||
public List<UpdateEntry> get(UpdateContext updateContext) { | ||
List<UpdateEntry> bulkUpdateEntries = new ArrayList<>(); | ||
|
||
for (UpdateProducer producer : commands) { | ||
List<UpdateEntry> entries = producer.get(updateContext); | ||
|
||
for (UpdateEntry entry : entries) { | ||
updateContext.updateCatalog( | ||
catalog -> entry.applyUpdate(catalog, CatalogManagerImpl.INITIAL_CAUSALITY_TOKEN) | ||
); | ||
} | ||
|
||
bulkUpdateEntries.addAll(entries); | ||
} | ||
|
||
return bulkUpdateEntries; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/UpdateContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.catalog; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Context contains the catalog to be updated. | ||
* It is used by {@link BulkUpdateProducer} when executing a batch of catalog commands | ||
* | ||
* @see BulkUpdateProducer | ||
*/ | ||
public class UpdateContext { | ||
/** Catalog descriptor. */ | ||
private Catalog catalog; | ||
|
||
/** Identifiers of created tables. */ | ||
private @Nullable Set<Integer> tableIds; | ||
|
||
/** Constructor. */ | ||
public UpdateContext(Catalog catalog) { | ||
this.catalog = catalog; | ||
} | ||
|
||
/** Returns catalog descriptor. */ | ||
public Catalog catalog() { | ||
return catalog; | ||
} | ||
|
||
/** Registers the table being created in the context. */ | ||
public void registerTableCreation(int tableId) { | ||
if (tableIds == null) { | ||
tableIds = new HashSet<>(); | ||
} | ||
|
||
tableIds.add(tableId); | ||
} | ||
|
||
/** Returns whether the command to create a table with the specified identifier was processed. */ | ||
public boolean containsTableCreation(int tableId) { | ||
return tableIds != null && tableIds.contains(tableId); | ||
} | ||
|
||
/** Applies specified action to the catalog. */ | ||
void updateCatalog(Function<Catalog, Catalog> updater) { | ||
catalog = updater.apply(catalog); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.