This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new a89a358d0c2 [improvement](meta) Switch meta serialization to gson 1 
(#36125)
a89a358d0c2 is described below

commit a89a358d0c296a41a4c7c17867d110523e70f93d
Author: Peyz <30936555+iszhang...@users.noreply.github.com>
AuthorDate: Fri Jun 14 14:23:54 2024 +0800

    [improvement](meta) Switch meta serialization to gson 1 (#36125)
    
    ## Proposed changes
    
    Issue Number:
    
    Switch meta serialization to gson
    Contains the following classes:
    
    ~~JournalEntity~~
    DatabaseInfo
    ~~PartitionPersistInfo~~
    ConsistencyCheckInfo
    Timestamp
    BrokerMgr.ModifyBrokerInfo
    LoadErrorHub.Param
    TableInfo
    
    ---------
    
    Co-authored-by: zhangpeicheng <zhangpeich...@meituan.com>
---
 .../org/apache/doris/common/FeMetaVersion.java     |  7 ++-
 .../doris/analysis/AlterDatabaseQuotaStmt.java     |  8 +++
 .../java/org/apache/doris/catalog/BrokerMgr.java   | 26 +++++----
 .../org/apache/doris/catalog/PartitionKey.java     |  5 ++
 .../org/apache/doris/journal/JournalEntity.java    | 18 ++----
 .../org/apache/doris/journal/bdbje/Timestamp.java  | 20 ++++++-
 .../java/org/apache/doris/load/LoadErrorHub.java   | 39 +++++++++----
 .../apache/doris/persist/ConsistencyCheckInfo.java | 43 ++++++++------
 .../org/apache/doris/persist/DatabaseInfo.java     | 26 +++++----
 .../java/org/apache/doris/persist/TableInfo.java   | 36 +++++++-----
 .../org/apache/doris/persist/gson/GsonUtils.java   |  4 ++
 .../apache/doris/catalog/ModifyBrokerInfoTest.java | 65 ++++++++++++++++++++++
 .../org/apache/doris/common/io/DeepCopyTest.java   |  4 +-
 .../doris/journal/bdbje/BDBDebuggerTest.java       | 13 +----
 .../apache/doris/journal/bdbje/TimestampTest.java  |  3 +-
 .../doris/persist/ConsistencyCheckInfoTest.java    | 55 ++++++++++++++++++
 .../org/apache/doris/persist/DatabaseInfoTest.java | 58 +++++++++++++++++++
 .../org/apache/doris/persist/TableInfoTest.java    | 57 +++++++++++++++++++
 18 files changed, 393 insertions(+), 94 deletions(-)

diff --git 
a/fe/fe-common/src/main/java/org/apache/doris/common/FeMetaVersion.java 
b/fe/fe-common/src/main/java/org/apache/doris/common/FeMetaVersion.java
index 5cb60063256..5f7b7991e00 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/FeMetaVersion.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/FeMetaVersion.java
@@ -80,15 +80,18 @@ public final class FeMetaVersion {
     public static final int VERSION_129 = 129;
 
     public static final int VERSION_130 = 130;
+
     // for java-udtf add a bool field to write
     public static final int VERSION_131 = 131;
+
     // For transaction insert
     public static final int VERSION_132 = 132;
     // for expr serde
     public static final int VERSION_133 = 133;
-
+    // For mate gson
+    public static final int VERSION_134 = 134;
     // note: when increment meta version, should assign the latest version to 
VERSION_CURRENT
-    public static final int VERSION_CURRENT = VERSION_133;
+    public static final int VERSION_CURRENT = VERSION_134;
 
     // all logs meta version should >= the minimum version, so that we could 
remove many if clause, for example
     // if (FE_METAVERSION < VERSION_94) ...
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterDatabaseQuotaStmt.java
 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterDatabaseQuotaStmt.java
index 88c964c7342..647273add40 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterDatabaseQuotaStmt.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/AlterDatabaseQuotaStmt.java
@@ -27,11 +27,19 @@ import org.apache.doris.mysql.privilege.PrivPredicate;
 import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.base.Strings;
+import com.google.gson.annotations.SerializedName;
 
 public class AlterDatabaseQuotaStmt extends DdlStmt {
+    @SerializedName("db")
     private String dbName;
+
+    @SerializedName("qt")
     private QuotaType quotaType;
+
+    @SerializedName("qv")
     private String quotaValue;
+
+    @SerializedName("q")
     private long quota;
 
     public enum QuotaType {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/BrokerMgr.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BrokerMgr.java
index 6595dfde66a..5e4e7c7cbc8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/BrokerMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/BrokerMgr.java
@@ -21,6 +21,7 @@ import org.apache.doris.analysis.BrokerDesc;
 import org.apache.doris.analysis.ModifyBrokerClause;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.DdlException;
+import org.apache.doris.common.FeMetaVersion;
 import org.apache.doris.common.Pair;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
@@ -29,11 +30,13 @@ import org.apache.doris.common.proc.ProcNodeInterface;
 import org.apache.doris.common.proc.ProcResult;
 import org.apache.doris.common.util.NetUtils;
 import org.apache.doris.common.util.TimeUtils;
+import org.apache.doris.persist.gson.GsonUtils;
 
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.google.gson.annotations.SerializedName;
 
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -383,7 +386,9 @@ public class BrokerMgr {
     }
 
     public static class ModifyBrokerInfo implements Writable {
+        @SerializedName(value = "n")
         public String brokerName;
+        @SerializedName(value = "a")
         public List<FsBroker> brokerAddresses;
 
         public ModifyBrokerInfo() {
@@ -396,13 +401,20 @@ public class BrokerMgr {
 
         @Override
         public void write(DataOutput out) throws IOException {
-            Text.writeString(out, brokerName);
-            out.writeInt(brokerAddresses.size());
-            for (FsBroker address : brokerAddresses) {
-                address.write(out);
+            Text.writeString(out, GsonUtils.GSON.toJson(this));
+        }
+
+        public static ModifyBrokerInfo read(DataInput in) throws IOException {
+            if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_134) 
{
+                ModifyBrokerInfo modifyBrokerInfo = new ModifyBrokerInfo();
+                modifyBrokerInfo.readFields(in);
+                return modifyBrokerInfo;
+            } else {
+                return GsonUtils.GSON.fromJson(Text.readString(in), 
ModifyBrokerInfo.class);
             }
         }
 
+        @Deprecated
         public void readFields(DataInput in) throws IOException {
             brokerName = Text.readString(in);
             int size = in.readInt();
@@ -411,11 +423,5 @@ public class BrokerMgr {
                 brokerAddresses.add(FsBroker.readIn(in));
             }
         }
-
-        public static ModifyBrokerInfo readIn(DataInput in) throws IOException 
{
-            ModifyBrokerInfo info = new ModifyBrokerInfo();
-            info.readFields(in);
-            return info;
-        }
     }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java
index bd6706d737a..0426759fe4f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java
@@ -46,6 +46,7 @@ import com.google.gson.JsonParseException;
 import com.google.gson.JsonPrimitive;
 import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
+import com.google.gson.annotations.SerializedName;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -59,9 +60,13 @@ import java.util.zip.CRC32;
 
 public class PartitionKey implements Comparable<PartitionKey>, Writable {
     private static final Logger LOG = LogManager.getLogger(PartitionKey.class);
+    @SerializedName("ks")
     private List<LiteralExpr> keys;
+    @SerializedName("hk")
     private List<String> originHiveKeys;
+    @SerializedName("ts")
     private List<PrimitiveType> types;
+    @SerializedName("isD")
     private boolean isDefaultListPartitionKey = false;
 
     // constructor for partition prune
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java 
b/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java
index 647a16e30a9..e4a77df77f3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java
@@ -224,8 +224,7 @@ public class JournalEntity implements Writable {
             }
             case OperationType.OP_ALTER_DB:
             case OperationType.OP_RENAME_DB: {
-                data = new DatabaseInfo();
-                ((DatabaseInfo) data).readFields(in);
+                data = DatabaseInfo.read(in);
                 isRead = true;
                 break;
             }
@@ -293,8 +292,7 @@ public class JournalEntity implements Writable {
             case OperationType.OP_RENAME_TABLE:
             case OperationType.OP_RENAME_ROLLUP:
             case OperationType.OP_RENAME_PARTITION: {
-                data = new TableInfo();
-                ((TableInfo) data).readFields(in);
+                data = TableInfo.read(in);
                 isRead = true;
                 break;
             }
@@ -319,8 +317,7 @@ public class JournalEntity implements Writable {
                 break;
             }
             case OperationType.OP_FINISH_CONSISTENCY_CHECK: {
-                data = new ConsistencyCheckInfo();
-                ((ConsistencyCheckInfo) data).readFields(in);
+                data = ConsistencyCheckInfo.read(in);
                 isRead = true;
                 break;
             }
@@ -373,8 +370,7 @@ public class JournalEntity implements Writable {
                 break;
             }
             case OperationType.OP_SET_LOAD_ERROR_HUB: {
-                data = new LoadErrorHub.Param();
-                ((LoadErrorHub.Param) data).readFields(in);
+                data = LoadErrorHub.Param.read(in);
                 isRead = true;
                 break;
             }
@@ -410,8 +406,7 @@ public class JournalEntity implements Writable {
                 break;
             }
             case OperationType.OP_TIMESTAMP: {
-                data = new Timestamp();
-                ((Timestamp) data).readFields(in);
+                data = Timestamp.read(in);
                 isRead = true;
                 break;
             }
@@ -428,8 +423,7 @@ public class JournalEntity implements Writable {
             }
             case OperationType.OP_ADD_BROKER:
             case OperationType.OP_DROP_BROKER: {
-                data = new BrokerMgr.ModifyBrokerInfo();
-                ((BrokerMgr.ModifyBrokerInfo) data).readFields(in);
+                data = BrokerMgr.ModifyBrokerInfo.read(in);
                 isRead = true;
                 break;
             }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/journal/bdbje/Timestamp.java 
b/fe/fe-core/src/main/java/org/apache/doris/journal/bdbje/Timestamp.java
index b66b51509aa..59cbb2e8386 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/journal/bdbje/Timestamp.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/journal/bdbje/Timestamp.java
@@ -17,7 +17,13 @@
 
 package org.apache.doris.journal.bdbje;
 
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.FeMetaVersion;
+import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
 
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -25,6 +31,7 @@ import java.io.IOException;
 
 // Write this class to bdb periodically
 public class Timestamp implements Writable {
+    @SerializedName("ts")
     private long timestamp;
 
     public Timestamp() {
@@ -37,9 +44,20 @@ public class Timestamp implements Writable {
 
     @Override
     public void write(DataOutput out) throws IOException {
-        out.writeLong(timestamp);
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
+
+    public static Timestamp read(DataInput in) throws IOException {
+        if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_134) {
+            Timestamp timestamp = new Timestamp();
+            timestamp.readFields(in);
+            return timestamp;
+        } else {
+            return GsonUtils.GSON.fromJson(Text.readString(in), 
Timestamp.class);
+        }
     }
 
+    @Deprecated
     public void readFields(DataInput in) throws IOException {
         timestamp = in.readLong();
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/LoadErrorHub.java 
b/fe/fe-core/src/main/java/org/apache/doris/load/LoadErrorHub.java
index e40f0689a90..cf8add9f4ed 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/LoadErrorHub.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/LoadErrorHub.java
@@ -17,12 +17,16 @@
 
 package org.apache.doris.load;
 
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.FeMetaVersion;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
 import org.apache.doris.common.util.PrintableMap;
+import org.apache.doris.persist.gson.GsonUtils;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
+import com.google.gson.annotations.SerializedName;
 
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -32,11 +36,17 @@ import java.util.Map;
 public abstract class LoadErrorHub {
 
     public static class MysqlParam implements Writable {
+        @SerializedName("h")
         private String host;
+        @SerializedName("p")
         private int port;
+        @SerializedName("u")
         private String user;
+        @SerializedName("pwd")
         private String passwd;
+        @SerializedName("db")
         private String db;
+        @SerializedName("tb")
         private String table;
 
         public MysqlParam() {
@@ -90,8 +100,11 @@ public abstract class LoadErrorHub {
     }
 
     public static class BrokerParam implements Writable {
+        @SerializedName("b")
         private String brokerName;
+        @SerializedName("pa")
         private String path;
+        @SerializedName("pr")
         private Map<String, String> prop = Maps.newHashMap();
 
         // for persist
@@ -137,8 +150,11 @@ public abstract class LoadErrorHub {
     }
 
     public static class Param implements Writable {
+        @SerializedName(value = "t")
         private HubType type;
+        @SerializedName(value = "m")
         private MysqlParam mysqlParam;
+        @SerializedName(value = "b")
         private BrokerParam brokerParam;
 
         // for replay
@@ -148,21 +164,20 @@ public abstract class LoadErrorHub {
 
         @Override
         public void write(DataOutput out) throws IOException {
-            Text.writeString(out, type.name());
-            switch (type) {
-                case MYSQL_TYPE:
-                    mysqlParam.write(out);
-                    break;
-                case BROKER_TYPE:
-                    brokerParam.write(out);
-                    break;
-                case NULL_TYPE:
-                    break;
-                default:
-                    Preconditions.checkState(false, "unknown hub type");
+            Text.writeString(out, GsonUtils.GSON.toJson(this));
+        }
+
+        public static Param read(DataInput in) throws IOException {
+            if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_134) 
{
+                Param param = new Param();
+                param.readFields(in);
+                return param;
+            } else {
+                return GsonUtils.GSON.fromJson(Text.readString(in), 
Param.class);
             }
         }
 
+        @Deprecated
         public void readFields(DataInput in) throws IOException {
             type = HubType.valueOf(Text.readString(in));
             switch (type) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/persist/ConsistencyCheckInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/persist/ConsistencyCheckInfo.java
index 08975c98fc9..39aa614f4cd 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/persist/ConsistencyCheckInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/persist/ConsistencyCheckInfo.java
@@ -17,7 +17,14 @@
 
 package org.apache.doris.persist;
 
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.FeMetaVersion;
+import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
 
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -25,18 +32,28 @@ import java.io.IOException;
 
 public class ConsistencyCheckInfo implements Writable {
 
+    @SerializedName("db")
     private long dbId;
+    @SerializedName("tb")
     private long tableId;
+    @SerializedName("p")
     private long partitionId;
+    @SerializedName("ind")
     private long indexId;
+    @SerializedName("tab")
     private long tabletId;
 
+    @SerializedName("t")
     private long lastCheckTime;
 
+    @SerializedName("v")
     private long checkedVersion;
+
     @Deprecated
+    @Expose(serialize = false, deserialize = false)
     private long checkedVersionHash;
 
+    @SerializedName("isC")
     private boolean isConsistent;
 
     public ConsistencyCheckInfo() {
@@ -91,19 +108,19 @@ public class ConsistencyCheckInfo implements Writable {
 
     @Override
     public void write(DataOutput out) throws IOException {
-        out.writeLong(dbId);
-        out.writeLong(tableId);
-        out.writeLong(partitionId);
-        out.writeLong(indexId);
-        out.writeLong(tabletId);
-
-        out.writeLong(lastCheckTime);
-        out.writeLong(checkedVersion);
-        out.writeLong(checkedVersionHash);
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
 
-        out.writeBoolean(isConsistent);
+    public static ConsistencyCheckInfo read(DataInput in) throws IOException {
+        if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_134) {
+            ConsistencyCheckInfo info = new ConsistencyCheckInfo();
+            info.readFields(in);
+            return info;
+        }
+        return GsonUtils.GSON.fromJson(Text.readString(in), 
ConsistencyCheckInfo.class);
     }
 
+    @Deprecated
     public void readFields(DataInput in) throws IOException {
         dbId = in.readLong();
         tableId = in.readLong();
@@ -117,10 +134,4 @@ public class ConsistencyCheckInfo implements Writable {
 
         isConsistent = in.readBoolean();
     }
-
-    public static ConsistencyCheckInfo read(DataInput in) throws IOException {
-        ConsistencyCheckInfo info = new ConsistencyCheckInfo();
-        info.readFields(in);
-        return info;
-    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/persist/DatabaseInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/persist/DatabaseInfo.java
index f6772f60da8..966444c11c4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/DatabaseInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/DatabaseInfo.java
@@ -20,7 +20,9 @@ package org.apache.doris.persist;
 import org.apache.doris.analysis.AlterDatabaseQuotaStmt.QuotaType;
 import org.apache.doris.catalog.BinlogConfig;
 import org.apache.doris.catalog.Database.DbState;
+import org.apache.doris.catalog.Env;
 import org.apache.doris.cluster.ClusterNamespace;
+import org.apache.doris.common.FeMetaVersion;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
 import org.apache.doris.persist.gson.GsonPostProcessable;
@@ -86,22 +88,22 @@ public class DatabaseInfo implements Writable, 
GsonPostProcessable {
         return binlogConfig;
     }
 
-    public static DatabaseInfo read(DataInput in) throws IOException {
-        DatabaseInfo dbInfo = new DatabaseInfo();
-        dbInfo.readFields(in);
-        return dbInfo;
-    }
-
     @Override
     public void write(DataOutput out) throws IOException {
-        Text.writeString(out, ClusterNamespace.getNameFromFullName(dbName));
-        Text.writeString(out, ClusterNamespace.getNameFromFullName(newDbName));
-        out.writeLong(quota);
-        Text.writeString(out, this.clusterName);
-        Text.writeString(out, this.dbState.name());
-        Text.writeString(out, this.quotaType.name());
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
+
+    public static DatabaseInfo read(DataInput in) throws IOException {
+        if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_134) {
+            DatabaseInfo dbInfo = new DatabaseInfo();
+            dbInfo.readFields(in);
+            return dbInfo;
+        } else {
+            return GsonUtils.GSON.fromJson(Text.readString(in), 
DatabaseInfo.class);
+        }
     }
 
+    @Deprecated
     public void readFields(DataInput in) throws IOException {
         this.dbName = 
ClusterNamespace.getNameFromFullName(Text.readString(in));
         newDbName = ClusterNamespace.getNameFromFullName(Text.readString(in));
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/TableInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/persist/TableInfo.java
index 2d08a8a43fa..8a210508fc2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/TableInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/TableInfo.java
@@ -17,8 +17,13 @@
 
 package org.apache.doris.persist;
 
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.FeMetaVersion;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
 
 import java.io.DataInput;
 import java.io.DataOutput;
@@ -26,13 +31,20 @@ import java.io.IOException;
 
 public class TableInfo implements Writable {
 
+    @SerializedName("db")
     private long dbId;
+    @SerializedName("tb")
     private long tableId;
+    @SerializedName("ind")
     private long indexId;
+    @SerializedName("p")
     private long partitionId;
 
+    @SerializedName("nT")
     private String newTableName;
+    @SerializedName("nR")
     private String newRollupName;
+    @SerializedName("nP")
     private String newPartitionName;
 
     public TableInfo() {
@@ -98,16 +110,20 @@ public class TableInfo implements Writable {
 
     @Override
     public void write(DataOutput out) throws IOException {
-        out.writeLong(dbId);
-        out.writeLong(tableId);
-        out.writeLong(indexId);
-        out.writeLong(partitionId);
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
 
-        Text.writeString(out, newTableName);
-        Text.writeString(out, newRollupName);
-        Text.writeString(out, newPartitionName);
+    public static TableInfo read(DataInput in) throws IOException {
+        if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_134) {
+            TableInfo tableInfo = new TableInfo();
+            tableInfo.readFields(in);
+            return tableInfo;
+        } else {
+            return GsonUtils.GSON.fromJson(Text.readString(in), 
TableInfo.class);
+        }
     }
 
+    @Deprecated
     public void readFields(DataInput in) throws IOException {
         dbId = in.readLong();
         tableId = in.readLong();
@@ -118,10 +134,4 @@ public class TableInfo implements Writable {
         newRollupName = Text.readString(in);
         newPartitionName = Text.readString(in);
     }
-
-    public static TableInfo read(DataInput in) throws IOException {
-        TableInfo info = new TableInfo();
-        info.readFields(in);
-        return info;
-    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java 
b/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java
index 55b0e117704..482118bb4ee 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java
@@ -51,6 +51,8 @@ import org.apache.doris.analysis.MapLiteral;
 import org.apache.doris.analysis.MatchPredicate;
 import org.apache.doris.analysis.MaxLiteral;
 import org.apache.doris.analysis.NullLiteral;
+import org.apache.doris.analysis.NumericLiteralExpr;
+import org.apache.doris.analysis.PlaceHolderExpr;
 import org.apache.doris.analysis.SlotRef;
 import org.apache.doris.analysis.StringLiteral;
 import org.apache.doris.analysis.StructLiteral;
@@ -266,6 +268,8 @@ public class GsonUtils {
             .registerSubtype(JsonLiteral.class, 
JsonLiteral.class.getSimpleName())
             .registerSubtype(ArrayLiteral.class, 
ArrayLiteral.class.getSimpleName())
             .registerSubtype(StructLiteral.class, 
StructLiteral.class.getSimpleName())
+            .registerSubtype(NumericLiteralExpr.class, 
NumericLiteralExpr.class.getSimpleName())
+            .registerSubtype(PlaceHolderExpr.class, 
PlaceHolderExpr.class.getSimpleName())
             .registerSubtype(CaseExpr.class, CaseExpr.class.getSimpleName())
             .registerSubtype(LambdaFunctionExpr.class, 
LambdaFunctionExpr.class.getSimpleName())
             .registerSubtype(EncryptKeyRef.class, 
EncryptKeyRef.class.getSimpleName())
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBrokerInfoTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBrokerInfoTest.java
new file mode 100644
index 00000000000..62ed86463a7
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/catalog/ModifyBrokerInfoTest.java
@@ -0,0 +1,65 @@
+// 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.doris.catalog;
+
+import org.apache.doris.common.AnalysisException;
+
+import com.google.common.collect.Lists;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class ModifyBrokerInfoTest {
+    @Test
+    public void testSerialization() throws IOException, AnalysisException {
+        // 1. Write objects to file
+        final Path path = Files.createTempFile("modifyBrokerInfo", "tmp");
+        DataOutputStream out = new 
DataOutputStream(Files.newOutputStream(path));
+
+        List<FsBroker> brokerAddresses = Lists.newArrayList(
+            new FsBroker("127.0.0.1", 0)
+        );
+
+        BrokerMgr.ModifyBrokerInfo modifyBrokerInfo1 = new 
BrokerMgr.ModifyBrokerInfo("test", brokerAddresses);
+
+        modifyBrokerInfo1.write(out);
+        out.flush();
+        out.close();
+
+        // 2. Read objects from file
+        DataInputStream in = new DataInputStream(Files.newInputStream(path));
+
+        BrokerMgr.ModifyBrokerInfo modifyBrokerInfo2 = 
BrokerMgr.ModifyBrokerInfo.read(in);
+
+        Assert.assertEquals(modifyBrokerInfo1.brokerName, 
modifyBrokerInfo2.brokerName);
+        Assert.assertEquals(modifyBrokerInfo1.brokerAddresses.get(0).host,
+                modifyBrokerInfo2.brokerAddresses.get(0).host);
+        Assert.assertEquals(modifyBrokerInfo1.brokerAddresses.get(0).port,
+                modifyBrokerInfo2.brokerAddresses.get(0).port);
+
+        // 3. delete files
+        in.close();
+        Files.delete(path);
+    }
+}
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/common/io/DeepCopyTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/common/io/DeepCopyTest.java
index 71b42d7e28a..4d9fb317227 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/io/DeepCopyTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/io/DeepCopyTest.java
@@ -28,9 +28,7 @@ public class DeepCopyTest {
     @Test
     public void test() {
         TableInfo info = TableInfo.createForTableRename(1, 2, "newTbl");
-        TableInfo copied = new TableInfo();
-        boolean res = DeepCopy.copy(info, copied, TableInfo.class, 
FeConstants.meta_version);
-        Assert.assertTrue(res);
+        TableInfo copied = DeepCopy.copy(info, TableInfo.class, 
FeConstants.meta_version);
         Assert.assertEquals(1, copied.getDbId());
         Assert.assertEquals(2, copied.getTableId());
         Assert.assertEquals("newTbl", copied.getNewTableName());
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/BDBDebuggerTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/BDBDebuggerTest.java
index 3d54affbce0..32b0a7238b8 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/BDBDebuggerTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/BDBDebuggerTest.java
@@ -18,8 +18,6 @@
 package org.apache.doris.journal.bdbje;
 
 import org.apache.doris.catalog.Env;
-import org.apache.doris.common.io.Text;
-import org.apache.doris.common.io.Writable;
 import org.apache.doris.common.jmockit.Deencapsulation;
 import org.apache.doris.journal.JournalEntity;
 import org.apache.doris.persist.OperationType;
@@ -37,7 +35,6 @@ import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.RepeatedTest;
 
-import java.io.DataOutput;
 import java.io.File;
 import java.io.IOException;
 import java.net.DatagramSocket;
@@ -153,14 +150,8 @@ public class BDBDebuggerTest {
 
         journal.rollJournal();
         for (int i = 0; i < 10; i++) {
-            String data = "OperationType.OP_TIMESTAMP";
-            Writable writable = new Writable() {
-                @Override
-                public void write(DataOutput out) throws IOException {
-                    Text.writeString(out, data);
-                }
-            };
-            journal.write(OperationType.OP_TIMESTAMP, writable);
+            Timestamp ts = new Timestamp();
+            journal.write(OperationType.OP_TIMESTAMP, ts);
         }
         JournalEntity journalEntity = journal.read(1);
         Assertions.assertEquals(OperationType.OP_TIMESTAMP, 
journalEntity.getOpCode());
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/TimestampTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/TimestampTest.java
index 73120774c61..bc79563eac5 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/TimestampTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/journal/bdbje/TimestampTest.java
@@ -83,8 +83,7 @@ public class TimestampTest {
 
         DataInputStream in = new DataInputStream(new 
FileInputStream(testFile));
         Thread.sleep(1000);
-        Timestamp timestamp2 = new Timestamp();
-        timestamp2.readFields(in);
+        Timestamp timestamp2 = Timestamp.read(in);
 
         Assertions.assertEquals(ts, timestamp2.getTimestamp());
         Assertions.assertEquals("" + ts, timestamp2.toString());
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/persist/ConsistencyCheckInfoTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/persist/ConsistencyCheckInfoTest.java
new file mode 100644
index 00000000000..de75d578f49
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/persist/ConsistencyCheckInfoTest.java
@@ -0,0 +1,55 @@
+// 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.doris.persist;
+
+import org.apache.doris.common.AnalysisException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class ConsistencyCheckInfoTest {
+    @Test
+    public void testSerialization() throws IOException, AnalysisException {
+        // 1. Write objects to file
+        final Path path = Files.createTempFile("consistencyCheckInfo", "tmp");
+        DataOutputStream out = new 
DataOutputStream(Files.newOutputStream(path));
+
+        ConsistencyCheckInfo consistencyCheckInfo1 = new 
ConsistencyCheckInfo(1L, 2L, 3L, 4L, 5L, 6L, 7L, true);
+
+        consistencyCheckInfo1.write(out);
+        out.flush();
+        out.close();
+
+        // 2. Read objects from file
+        DataInputStream in = new DataInputStream(Files.newInputStream(path));
+
+        ConsistencyCheckInfo consistencyCheckInfo2 = 
ConsistencyCheckInfo.read(in);
+
+        Assert.assertEquals(consistencyCheckInfo1.getDbId(), 
consistencyCheckInfo2.getDbId());
+
+        // 3. delete files
+        in.close();
+        Files.delete(path);
+    }
+}
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/persist/DatabaseInfoTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/persist/DatabaseInfoTest.java
new file mode 100644
index 00000000000..3edd0b21ffb
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/persist/DatabaseInfoTest.java
@@ -0,0 +1,58 @@
+// 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.doris.persist;
+
+import org.apache.doris.analysis.AlterDatabaseQuotaStmt.QuotaType;
+import org.apache.doris.common.AnalysisException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class DatabaseInfoTest {
+    @Test
+    public void testSerialization() throws IOException, AnalysisException {
+        // 1. Write objects to file
+        final Path path = Files.createTempFile("databaseInfo", "tmp");
+        DataOutputStream out = new 
DataOutputStream(Files.newOutputStream(path));
+
+        DatabaseInfo databaseInfo1 = new DatabaseInfo("test1", "test2", 1L, 
QuotaType.DATA);
+
+        databaseInfo1.write(out);
+        out.flush();
+        out.close();
+
+        // 2. Read objects from file
+        DataInputStream in = new DataInputStream(Files.newInputStream(path));
+
+        DatabaseInfo databaseInfo2 = DatabaseInfo.read(in);
+
+        Assert.assertEquals(databaseInfo1.getDbName(), 
databaseInfo2.getDbName());
+        Assert.assertEquals(databaseInfo1.getNewDbName(), 
databaseInfo2.getNewDbName());
+        Assert.assertEquals(databaseInfo1.getQuota(), 
databaseInfo2.getQuota());
+
+        // 3. delete files
+        in.close();
+        Files.delete(path);
+    }
+}
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/persist/TableInfoTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/persist/TableInfoTest.java
new file mode 100644
index 00000000000..ae6d1ec0923
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/persist/TableInfoTest.java
@@ -0,0 +1,57 @@
+// 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.doris.persist;
+
+import org.apache.doris.common.AnalysisException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class TableInfoTest {
+    @Test
+    public void testSerialization() throws IOException, AnalysisException {
+        // 1. Write objects to file
+        final Path path = Files.createTempFile("tableInfo", "tmp");
+        DataOutputStream out = new 
DataOutputStream(Files.newOutputStream(path));
+
+        TableInfo tableInfo1 = TableInfo.createForTableRename(1L, 2L, "test");
+
+        tableInfo1.write(out);
+        out.flush();
+        out.close();
+
+        // 2. Read objects from file
+        DataInputStream in = new DataInputStream(Files.newInputStream(path));
+
+        TableInfo tableInfo2 = TableInfo.read(in);
+
+        Assert.assertEquals(tableInfo1.getTableId(), tableInfo2.getTableId());
+        Assert.assertEquals(tableInfo1.getDbId(), tableInfo2.getDbId());
+        Assert.assertEquals(tableInfo1.getNewTableName(), 
tableInfo2.getNewTableName());
+
+        // 3. delete files
+        in.close();
+        Files.delete(path);
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org


Reply via email to