AMashenkov commented on code in PR #5373:
URL: https://github.com/apache/ignite-3/pull/5373#discussion_r2000694905


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/storage/serialization/CatalogObjectDataOutput.java:
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.util.Collection;
+import java.util.List;
+import org.apache.ignite.internal.util.io.IgniteUnsafeDataOutput;
+
+/**
+ * Catalog object data output.
+ */
+public class CatalogObjectDataOutput extends IgniteUnsafeDataOutput {
+
+    /** Initial capacity (in bytes) of the buffer used for data output. */
+    private static final int INITIAL_BUFFER_CAPACITY = 256;
+
+    private final CatalogEntrySerializerProvider serializers;
+
+    /**
+     * Constructor.
+     */
+    public CatalogObjectDataOutput(CatalogEntrySerializerProvider serializers) 
{
+        super(INITIAL_BUFFER_CAPACITY);
+
+        this.serializers = serializers;
+    }
+
+    /**
+     * Writes an entry with the latest serializer.
+     *
+     * @param entry Entry.
+     */
+    public void writeEntry(MarshallableEntry entry) throws IOException {
+        int typeId = entry.typeId();
+        int entryVersion = serializers.latestSerializerVersion(typeId);
+
+        writeEntryHeader(entry, entryVersion);
+        serializers.get(entryVersion, typeId).writeTo(entry, this);
+    }
+
+    /**
+     * Writes a list of entries.
+     *
+     * @param entries Entries.
+     */
+    public <T extends MarshallableEntry> void writeEntryList(List<T> entries) 
throws IOException {
+        writeVarInt(entries.size());
+
+        for (T entry : entries) {
+            int typeId = entry.typeId();
+            int version = serializers.latestSerializerVersion(typeId);
+
+            writeEntryHeader(entry, version);
+            serializers.get(version, typeId).writeTo(entry, this);
+        }
+    }
+
+    /**
+     * Writes a compact list of entries.

Review Comment:
   ```suggestion
        * Writes a list of entries of the exactly same type in a compact way.
   ```



-- 
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

Reply via email to