You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/09/02 07:20:29 UTC

[GitHub] [ignite] ptupitsyn commented on a change in pull request #9370: IGNITE-15015 C++ Add support for affinity field

ptupitsyn commented on a change in pull request #9370:
URL: https://github.com/apache/ignite/pull/9370#discussion_r700814521



##########
File path: modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
##########
@@ -56,85 +81,161 @@ namespace ignite
 
             static void Read(BinaryReader& reader, IgniteError& dst);
         };
+    } // namespace binary
 
-        /**
-         * Write helper. Takes care of proper writing of pointers.
-         */
-        template<typename T>
-        struct WriteHelper
+    namespace impl
+    {
+        namespace binary
         {
-            template<typename W>
-            static void Write(W& writer, const T& val)
+            /**
+             * Write helper. Takes care of proper writing of pointers.
+             */
+            template<typename T>
+            struct WriteHelper
             {
-                writer.template WriteTopObject0<BinaryWriter>(val);
-            }
-        };
-
-        /**
-         * Specialization for the pointer case.
-         */
-        template<typename T>
-        struct WriteHelper<T*>
-        {
-            template<typename W>
-            static void Write(W& writer, const T* val)
+                template<typename W>
+                static void Write(W& writer, const T& val)
+                {
+                    writer.template WriteTopObject0<ignite::binary::BinaryWriter>(val);
+                }
+            };
+
+            /**
+             * Specialization for the pointer case.
+             */
+            template<typename T>
+            struct WriteHelper<T*>
             {
-                if (!val)
-                    writer.WriteNull0();
-                else
-                    writer.template WriteTopObject0<BinaryWriter>(*val);
-            }
-        };
-
-        /**
-         * Read helper. Takes care of proper reading of pointers.
-         */
-        template<typename T>
-        struct ReadHelper
-        {
-            template<typename R>
-            static T Read(R& reader)
+                template<typename W>
+                static void Write(W& writer, const T* val)
+                {
+                    if (!val)
+                        writer.WriteNull0();
+                    else
+                        writer.template WriteTopObject0<ignite::binary::BinaryWriter>(*val);
+                }
+            };
+
+            /**
+             * Read helper. Takes care of proper reading of pointers.
+             */
+            template<typename T>
+            struct ReadHelper
             {
-                T res;
-
-                Read<R>(reader, res);
-
-                return res;
-            }
-
-            template<typename R>
-            static void Read(R& reader, T& val)
+                template<typename R>
+                static T Read(R& reader)
+                {
+                    T res;
+
+                    Read<R>(reader, res);
+
+                    return res;
+                }
+
+                template<typename R>
+                static void Read(R& reader, T& val)
+                {
+                    reader.template ReadTopObject0<ignite::binary::BinaryReader, T>(val);
+                }
+            };
+
+            /**
+             * Specialization for the pointer case.
+             */
+            template<typename T>
+            struct ReadHelper<T*>
             {
-                reader.template ReadTopObject0<BinaryReader, T>(val);
-            }
-        };
-
-        /**
-         * Specialization for the pointer case.
-         */
-        template<typename T>
-        struct ReadHelper<T*>
-        {
-            template<typename R>
-            static T* Read(R& reader)
+                template<typename R>
+                static T* Read(R& reader)
+                {
+                    if (reader.SkipIfNull())
+                        return 0;
+
+                    std::auto_ptr<T> res(new T());
+
+                    reader.template ReadTopObject0<ignite::binary::BinaryReader, T>(*res);
+
+                    return res.release();
+                }
+
+                template<typename R>
+                static void Read(R& reader, T*& ptr)
+                {
+                    ptr = Read<R>(reader);
+                }
+            };
+
+            IGNITE_DECLARE_BINARY_TYPE_METHOD_CHECKER(GetAffinityFieldName, void(*)(std::string&));

Review comment:
       My only concern is - if you make a typo in the method signature, the code will compile, but affinity won't work as expected.




-- 
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-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org