tkalkirill commented on code in PR #4583: URL: https://github.com/apache/ignite-3/pull/4583#discussion_r1806011221
########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/index/IndexMetaSerializer.java: ########## @@ -0,0 +1,91 @@ +/* + * 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.table.distributed.index; + +import java.io.IOException; +import java.util.EnumMap; +import java.util.Map; +import java.util.Map.Entry; +import org.apache.ignite.internal.util.io.IgniteDataInput; +import org.apache.ignite.internal.util.io.IgniteDataOutput; +import org.apache.ignite.internal.versioned.VersionedSerializer; + +/** + * {@link VersionedSerializer} for {@link IndexMeta} instances. + */ +class IndexMetaSerializer extends VersionedSerializer<IndexMeta> { + static final IndexMetaSerializer INSTANCE = new IndexMetaSerializer(); + + @Override + protected void writeExternalData(IndexMeta meta, IgniteDataOutput out) throws IOException { + out.writeVarInt(meta.catalogVersion()); + out.writeVarInt(meta.indexId()); + out.writeVarInt(meta.tableId()); + out.writeVarInt(meta.tableVersion()); + out.writeUTF(meta.indexName()); Review Comment: Can it write long string? ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/index/MetaIndexStatus.java: ########## @@ -26,43 +31,74 @@ public enum MetaIndexStatus { * * @see CatalogIndexStatus#REGISTERED */ - REGISTERED, + REGISTERED(0), /** * Index was in the process of being built. * * @see CatalogIndexStatus#BUILDING */ - BUILDING, + BUILDING(1), /** * Index has been successfully built and is available for reading from it. * * @see CatalogIndexStatus#AVAILABLE */ - AVAILABLE, + AVAILABLE(2), /** * Available index has started preparing to be removed from the catalog. * * @see CatalogIndexStatus#STOPPING */ - STOPPING, + STOPPING(3), /** * Index has been removed from the catalog, with {@link CatalogIndexStatus#REGISTERED}/{@link CatalogIndexStatus#BUILDING} statuses, but * has not yet been destroyed due to a low watermark. */ // TODO: IGNITE-20934 Get rid of such indexes immediately - REMOVED, + REMOVED(4), /** * Index has been removed from the catalog, with statuses {@link CatalogIndexStatus#AVAILABLE} (on table destruction) or * {@link CatalogIndexStatus#STOPPING}, but has not yet been destroyed due to a low watermark. * * <p>Such an index cannot be used by RW transactions, only by RO transactions with the correct readTimestamp.</p> */ - READ_ONLY; + READ_ONLY(5); + + /** Status code. It's persisted and should not be changed for existing statuses. */ + private final int code; + + private static final Map<Integer, MetaIndexStatus> VALUES_BY_CODE = Arrays.stream(values()) Review Comment: I would suggest using an array and doing the same approach as for messages, see `org.apache.ignite.internal.network.annotations.Transferable`. -- 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