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

yiguolei 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 c6ae402d0ea Reduce AlterJobV2/TruncateTable binlog size (#30505)
c6ae402d0ea is described below

commit c6ae402d0ea1286679dcf63ca6094b9af4c8fe57
Author: Jack Drogon <jack.xsuper...@gmail.com>
AuthorDate: Mon Jan 29 18:54:46 2024 +0800

    Reduce AlterJobV2/TruncateTable binlog size (#30505)
    
    Signed-off-by: Jack Drogon <jack.xsuper...@gmail.com>
---
 .../java/org/apache/doris/alter/AlterJobV2.java    |  4 ++
 .../org/apache/doris/binlog/AlterJobRecord.java    | 54 ++++++++++++++++++++++
 .../org/apache/doris/binlog/BinlogManager.java     |  6 ++-
 .../apache/doris/binlog/TruncateTableRecord.java   | 51 ++++++++++++++++++++
 4 files changed, 113 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterJobV2.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterJobV2.java
index 828a7650c58..a863b7775b0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterJobV2.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterJobV2.java
@@ -165,6 +165,10 @@ public abstract class AlterJobV2 implements Writable {
         this.finishedTimeMs = finishedTimeMs;
     }
 
+    public String getRawSql() {
+        return rawSql;
+    }
+
     // /api/debug_point/add/{name}?value=100
     private void stateWait(final String name) {
         long waitTimeMs = DebugPointUtil.getDebugParamOrDefault(name, 0);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/binlog/AlterJobRecord.java 
b/fe/fe-core/src/main/java/org/apache/doris/binlog/AlterJobRecord.java
new file mode 100644
index 00000000000..36c772d5246
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/binlog/AlterJobRecord.java
@@ -0,0 +1,54 @@
+// 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.binlog;
+
+import org.apache.doris.alter.AlterJobV2;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AlterJobRecord {
+    @SerializedName(value = "type")
+    private AlterJobV2.JobType type;
+    @SerializedName(value = "dbId")
+    private long dbId;
+    @SerializedName(value = "tableId")
+    private long tableId;
+    @SerializedName(value = "tableName")
+    private String tableName;
+    @SerializedName(value = "jobId")
+    private long jobId;
+    @SerializedName(value = "jobState")
+    private AlterJobV2.JobState jobState;
+    @SerializedName(value = "rawSql")
+    private String rawSql;
+
+    public AlterJobRecord(AlterJobV2 job) {
+        this.type = job.getType();
+        this.dbId = job.getDbId();
+        this.tableId = job.getTableId();
+        this.tableName = job.getTableName();
+        this.jobId = job.getJobId();
+        this.jobState = job.getJobState();
+        this.rawSql = job.getRawSql();
+    }
+
+    public String toJson() {
+        return GsonUtils.GSON.toJson(this);
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java 
b/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java
index 6ac3ba3b3a4..8c68f908ce5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java
@@ -213,7 +213,8 @@ public class BinlogManager {
         tableIds.add(alterJob.getTableId());
         long timestamp = -1;
         TBinlogType type = TBinlogType.ALTER_JOB;
-        String data = alterJob.toJson();
+        AlterJobRecord alterJobRecord = new AlterJobRecord(alterJob);
+        String data = alterJobRecord.toJson();
 
         addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false);
     }
@@ -303,7 +304,8 @@ public class BinlogManager {
         tableIds.add(info.getTblId());
         long timestamp = -1;
         TBinlogType type = TBinlogType.TRUNCATE_TABLE;
-        String data = info.toJson();
+        TruncateTableRecord record = new TruncateTableRecord(info);
+        String data = record.toJson();
 
         addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false);
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/binlog/TruncateTableRecord.java 
b/fe/fe-core/src/main/java/org/apache/doris/binlog/TruncateTableRecord.java
new file mode 100644
index 00000000000..0c43ce781cd
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/binlog/TruncateTableRecord.java
@@ -0,0 +1,51 @@
+// 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.binlog;
+
+import org.apache.doris.persist.TruncateTableInfo;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
+
+public class TruncateTableRecord {
+    @SerializedName(value = "dbId")
+    private long dbId;
+    @SerializedName(value = "db")
+    private String db;
+    @SerializedName(value = "tblId")
+    private long tblId;
+    @SerializedName(value = "table")
+    private String table;
+    @SerializedName(value = "isEntireTable")
+    private boolean isEntireTable = false;
+    @SerializedName(value = "rawSql")
+    private String rawSql = "";
+
+    public TruncateTableRecord(TruncateTableInfo info) {
+        this.dbId = info.getDbId();
+        this.db = info.getDb();
+        this.tblId = info.getTblId();
+        this.table = info.getTable();
+        this.isEntireTable = info.isEntireTable();
+        this.rawSql = info.getRawSql();
+    }
+
+    public String toJson() {
+        return GsonUtils.GSON.toJson(this);
+    }
+}


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

Reply via email to