xtern commented on code in PR #3627:
URL: https://github.com/apache/ignite-3/pull/3627#discussion_r1571289616


##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/commands/DefaultValue.java:
##########
@@ -68,9 +92,28 @@ public Type type() {
         return type;
     }
 
+    /** Serializes this default value or {@code null}. */
+    public abstract void writeTo(IgniteDataOutput os) throws IOException;
+
+    /** Reads default value or {@code null}. */
+    public static @Nullable DefaultValue readFrom(IgniteDataInput in) throws 
IOException {

Review Comment:
   First, the fact that there is a "static" version of `writeTo` somewhere 
below is difficult to understand.
   Secondly, from my point of view it might be worth implementing them 
identically...  I understand that this is more like structured programming and 
not OOP, but it seems in this particular case it will be simpler, shorter and 
clearer.
   ```
   /** Writes the given default value into output. */
   public static void writeTo(@Nullable DefaultValue val, IgniteDataOutput out) 
throws IOException {
       if (val == null) {
           out.writeByte(Type.NO_DEFAULT);
       } else {
           out.writeByte(val.type.typeId);
   
           if (val.type == Type.CONSTANT) {
               ConstantValue val0 = (ConstantValue) val;
   
               writeValue(val0.columnType, val0.value, out);
           } else {
               assert val instanceof FunctionCall;
   
               out.writeUTF(((FunctionCall) val).functionName());
           }
       }
   }
   ```
   wdyt?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to