rpuch commented on code in PR #2756: URL: https://github.com/apache/ignite-3/pull/2756#discussion_r1375775109
########## modules/index/src/main/java/org/apache/ignite/internal/index/IndexManagementUtils.java: ########## @@ -0,0 +1,266 @@ +/* + * 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.index; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.stream.Collectors.toList; +import static org.apache.ignite.internal.metastorage.dsl.Conditions.exists; +import static org.apache.ignite.internal.metastorage.dsl.Conditions.notExists; +import static org.apache.ignite.internal.metastorage.dsl.Operations.noop; +import static org.apache.ignite.internal.metastorage.dsl.Operations.put; +import static org.apache.ignite.internal.metastorage.dsl.Operations.remove; +import static org.apache.ignite.internal.util.ArrayUtils.BYTE_EMPTY_ARRAY; +import static org.apache.ignite.internal.util.CollectionUtils.concat; +import static org.apache.ignite.internal.util.ExceptionUtils.unwrapCause; + +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.stream.IntStream; +import org.apache.ignite.internal.catalog.CatalogManager; +import org.apache.ignite.internal.catalog.CatalogService; +import org.apache.ignite.internal.catalog.IndexAlreadyAvailableValidationException; +import org.apache.ignite.internal.catalog.IndexNotFoundValidationException; +import org.apache.ignite.internal.catalog.commands.MakeIndexAvailableCommand; +import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor; +import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; +import org.apache.ignite.internal.catalog.descriptors.CatalogZoneDescriptor; +import org.apache.ignite.internal.hlc.HybridTimestamp; +import org.apache.ignite.internal.lang.ByteArray; +import org.apache.ignite.internal.lang.NodeStoppingException; +import org.apache.ignite.internal.logger.IgniteLogger; +import org.apache.ignite.internal.metastorage.Entry; +import org.apache.ignite.internal.metastorage.MetaStorageManager; +import org.apache.ignite.internal.metastorage.dsl.Operation; +import org.apache.ignite.internal.placementdriver.ReplicaMeta; +import org.apache.ignite.internal.util.Cursor; +import org.apache.ignite.network.ClusterNode; + +/** Helper class for index management. */ +class IndexManagementUtils { + /** Metastore key prefix for the "index in the process of building" in the format: {@code "indexBuild.inProgress.<indexId>"}. */ + static final String IN_PROGRESS_BUILD_INDEX_KEY_PREFIX = "indexBuild.inProgress."; + + /** + * Metastore key prefix for the "index in the process of building for partition" in the format: + * {@code "indexBuild.partition.<indexId>.<partitionId>"}. + */ + static final String PARTITION_BUILD_INDEX_KEY_PREFIX = "indexBuild.partition."; + + /** + * Returns {@code true} if the {@code key} is <b>absent</b> in the metastore locally. + * + * @param metastore Metastore manager. + * @param key Key to check. + * @param revUpperBound Upper bound of metastore revision. + */ + static boolean isMetastoreKeyAbsentLocally(MetaStorageManager metastore, ByteArray key, long revUpperBound) { + return metastore.getLocally(key, revUpperBound).value() == null; + } + + /** + * Returns {@code true} if at least one key by prefix is <b>present</b> in the metastore locally. + * + * @param metastore Metastore manager. + * @param keyPrefix Key prefix to check. + * @param revUpperBound Upper bound of metastore revision. + */ + static boolean isMetastoreKeysPresentLocally(MetaStorageManager metastore, ByteArray keyPrefix, long revUpperBound) { Review Comment: The problem here is that it's not clear whether we want to check that ALL keys are present, or just ANY of them. This looks important. Without this clarification, the reader has to look into the method code. -- 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-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org