From fae6bd574513b7bfcb5aab9dd9e9ae56448febbb Mon Sep 17 00:00:00 2001 From: Yongqiang YANG Date: Thu, 20 Jun 2024 15:41:29 +0800 Subject: [PATCH] fix --- .../org/apache/doris/analysis/TableRef.java | 23 +++++++++---------- .../org/apache/doris/backup/BackupJob.java | 13 +++++++---- .../org/apache/doris/backup/BackupMeta.java | 13 +---------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java index 1de581834d0da9c..3166d327d37e70d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableRef.java @@ -26,6 +26,7 @@ import org.apache.doris.common.AnalysisException; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; +import org.apache.doris.common.FeMetaVersion; import org.apache.doris.common.Pair; import org.apache.doris.common.UserException; import org.apache.doris.common.io.Text; @@ -33,6 +34,7 @@ import org.apache.doris.common.util.TimeUtils; import org.apache.doris.datasource.hive.HMSExternalTable; import org.apache.doris.datasource.hudi.HudiUtils; +import org.apache.doris.persist.gson.GsonUtils; import org.apache.doris.rewrite.ExprRewriter; import org.apache.doris.rewrite.ExprRewriter.ClauseType; @@ -977,23 +979,20 @@ public String toString() { @Override public void write(DataOutput out) throws IOException { - name.write(out); - if (partitionNames == null) { - out.writeBoolean(false); - } else { - out.writeBoolean(true); - partitionNames.write(out); - } + Text.writeString(out, GsonUtils.GSON.toJson(this)); + } - if (hasExplicitAlias()) { - out.writeBoolean(true); - Text.writeString(out, getExplicitAlias()); + public static TableRef read(DataInput in) throws IOException { + if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_135) { + TableRef ref = new TableRef(); + ref.readFields(in); + return ref; } else { - out.writeBoolean(false); + return GsonUtils.GSON.fromJson(Text.readString(in), TableRef.class); } } - public void readFields(DataInput in) throws IOException { + private void readFields(DataInput in) throws IOException { name = new TableName(); name.readFields(in); if (in.readBoolean()) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java index 1a71ead1732aa00..07920724d5afec4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java @@ -1045,10 +1045,11 @@ public void readFields(DataInput in) throws IOException { // table refs int size = in.readInt(); + LOG.info("read {} tablerefs ", size); + tableRefs = Lists.newArrayList(); for (int i = 0; i < size; i++) { - TableRef tblRef = new TableRef(); - tblRef.readFields(in); + TableRef tblRef = TableRef.read(in); tableRefs.add(tblRef); } @@ -1060,14 +1061,16 @@ public void readFields(DataInput in) throws IOException { // snapshot info size = in.readInt(); + LOG.info("read {} snapshotinfo ", size); + for (int i = 0; i < size; i++) { - SnapshotInfo snapshotInfo = new SnapshotInfo(); - snapshotInfo.readFields(in); + SnapshotInfo snapshotInfo = SnapshotInfo.read(in); snapshotInfos.put(snapshotInfo.getTabletId(), snapshotInfo); } // backup meta if (in.readBoolean()) { + LOG.info("read backup meta"); backupMeta = BackupMeta.read(in); } @@ -1083,6 +1086,8 @@ public void readFields(DataInput in) throws IOException { } // read properties size = in.readInt(); + LOG.info("read {} property ", size); + for (int i = 0; i < size; i++) { String key = Text.readString(in); String value = Text.readString(in); diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java index 39261c6c0217dd8..741226f13e6fafb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java +++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupMeta.java @@ -127,18 +127,7 @@ public static BackupMeta read(DataInput in) throws IOException { // We can not change, because backup meta stored in external storage @Override public void write(DataOutput out) throws IOException { - if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_135) { - out.writeInt(tblNameMap.size()); - for (Table table : tblNameMap.values()) { - table.write(out); - } - out.writeInt(resourceNameMap.size()); - for (Resource resource : resourceNameMap.values()) { - resource.write(out); - } - } else { - Text.writeString(out, toJson()); - } + Text.writeString(out, toJson()); } public void readFields(DataInput in) throws IOException {