lowka commented on code in PR #5373: URL: https://github.com/apache/ignite-3/pull/5373#discussion_r1999059169
########## modules/catalog/src/main/java/org/apache/ignite/internal/catalog/storage/serialization/CatalogObjectDataInput.java: ########## @@ -0,0 +1,139 @@ +/* + * 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.storage.serialization; + +import java.io.IOException; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; +import org.apache.ignite.internal.util.io.IgniteUnsafeDataInput; + +/** + * Catalog object data input. + */ +public class CatalogObjectDataInput extends IgniteUnsafeDataInput { + + private final CatalogEntrySerializerProvider serializers; + + /** + * Constructor. + */ + public CatalogObjectDataInput(CatalogEntrySerializerProvider serializers, byte[] bytes) { + super(bytes); + + this.serializers = serializers; + } + + /** + * Reads an entry using a serializer of the version it was written with. + */ + public MarshallableEntry readEntry() throws IOException { + int typeId = readShort(); + int entryVersion = readVarIntAsInt(); + + return serializers.get(entryVersion, typeId).readFrom(this); + } + + /** + * Reads an entry. + * + * @param type Entry type. + */ + public <T extends MarshallableEntry> T readEntry(Class<T> type) throws IOException { + int typeId = readShort(); + int entryVersion = readVarIntAsInt(); + MarshallableEntry entry = serializers.get(entryVersion, typeId).readFrom(this); + return type.cast(entry); + } + + /** + * Reads entry list. + * + * @param type Type. + */ + public <T extends MarshallableEntry> List<T> readEntryList(Class<T> type) throws IOException { + int size = readVarIntAsInt(); + List<T> list = new ArrayList<>(size); + + for (int i = 0; i < size; i++) { + int typeId = readShort(); + int entryVersion = readVarIntAsInt(); Review Comment: Done. Introduced read/write CompactEntryList. Removed readEntryArray. -- 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