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


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/descriptors/CatalogStorageProfilesDescriptorSerializers.java:
##########
@@ -55,11 +56,34 @@ public CatalogStorageProfilesDescriptor 
readFrom(IgniteDataInput input) throws I
         }
 
         @Override
-        public void writeTo(CatalogStorageProfilesDescriptor descriptor, 
IgniteDataOutput output) throws IOException {
+        public void writeTo(CatalogStorageProfilesDescriptor descriptor, 
CatalogObjectDataOutput output) throws IOException {
             CatalogObjectSerializer<CatalogStorageProfileDescriptor> 
profileSerializer =
                     serializers.get(1, 
MarshallableEntryType.DESCRIPTOR_STORAGE_PROFILE.id());
 
             writeList(descriptor.profiles(), profileSerializer, output);
         }
     }
+
+    /**
+     * Serializer for {@link CatalogStorageProfilesDescriptor}.
+     */
+    @CatalogSerializer(version = 2, since = "3.1.0")
+    static class StorageProfilesDescriptorSerializerV2 implements 
CatalogObjectSerializer<CatalogStorageProfilesDescriptor> {
+
+        private final MarshallableType<CatalogStorageProfileDescriptor> 
profileType =
+                MarshallableType.typeOf(CatalogStorageProfileDescriptor.class,
+                        MarshallableEntryType.DESCRIPTOR_STORAGE_PROFILE, 2);
+
+        @Override
+        public CatalogStorageProfilesDescriptor 
readFrom(CatalogObjectDataInput input) throws IOException {
+            List<CatalogStorageProfileDescriptor> storageProfileDescriptors = 
input.readEntryList(profileType);
+
+            return new 
CatalogStorageProfilesDescriptor(storageProfileDescriptors);
+        }
+
+        @Override
+        public void writeTo(CatalogStorageProfilesDescriptor descriptor, 
CatalogObjectDataOutput output) throws IOException {
+            output.writeEntryList(profileType, descriptor.profiles());

Review Comment:
   I don't like the way we writing/reading a list.
   For catalog objects we assume that CatalogObjectDataOutput will use a 
correct serializer version underneath.
   But here we use hardcoded version.
   
   What if we upgrade storage profile serializer up to version of 3?
   Then from one side, it maybe incorrect to write a list with version of 2.
   From another side, we must be able to read both versions 2 and 3, and can't 
pass a profileType into input.readEntryList.



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