diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/io/DeepCopy.java b/fe/fe-common/src/main/java/org/apache/doris/common/io/DeepCopy.java index 106205f2256da5..282e6a0e16a57f 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/common/io/DeepCopy.java +++ b/fe/fe-common/src/main/java/org/apache/doris/common/io/DeepCopy.java @@ -39,6 +39,7 @@ public class DeepCopy { // deep copy orig to dest. // the param "c" is the implementation class of "dest". // And the "dest" class must has method "readFields(DataInput)" + @Deprecated public static boolean copy(Writable orig, Writable dest, Class c, int metaVersion) { MetaContext metaContext = new MetaContext(); metaContext.setMetaVersion(metaVersion); 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 45fdd1261ce8ce..e27c8d19a840a2 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 @@ -140,6 +140,7 @@ public void write(DataOutput out) throws IOException { Text.writeString(out, GsonUtils.GSON.toJson(this)); } + @Deprecated public void readFields(DataInput in) throws IOException { int size = in.readInt(); for (int i = 0; i < size; i++) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java index 6b6fe5284a4ae7..17cc5cd148bbea 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java @@ -1305,6 +1305,7 @@ public void gsonPostProcess() throws IOException { updateDbInfoForLowerVersion(); } + @Deprecated public void readFields(DataInput in) throws IOException { int count = in.readInt(); for (int i = 0; i < count; i++) { @@ -1439,6 +1440,7 @@ public Table getTable() { return table; } + @Deprecated public void readFields(DataInput in) throws IOException { dbId = in.readLong(); table = Table.read(in); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java index 8d453b1b0f0fad..0aca7e4e28e31a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java @@ -29,7 +29,6 @@ import org.apache.doris.common.Config; import org.apache.doris.common.DdlException; import org.apache.doris.common.io.Text; -import org.apache.doris.common.io.Writable; import org.apache.doris.common.util.SqlUtils; import org.apache.doris.persist.gson.GsonPostProcessable; import org.apache.doris.persist.gson.GsonUtils; @@ -48,7 +47,6 @@ import org.apache.logging.log4j.Logger; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; @@ -60,7 +58,7 @@ /** * This class represents the column-related metadata. */ -public class Column implements Writable, GsonPostProcessable { +public class Column implements GsonPostProcessable { private static final Logger LOG = LogManager.getLogger(Column.class); public static final String DELETE_SIGN = "__DORIS_DELETE_SIGN__"; public static final String WHERE_SIGN = "__DORIS_WHERE_SIGN__"; @@ -1065,33 +1063,7 @@ name, getDefaultValue(), aggregationType, isAggregationTypeImplicit, isKey, isAl return ok; } - @Override - public void write(DataOutput out) throws IOException { - String json = GsonUtils.GSON.toJson(this); - Text.writeString(out, json); - } - @Deprecated - private void readFields(DataInput in) throws IOException { - name = Text.readString(in); - type = ColumnType.read(in); - boolean notNull = in.readBoolean(); - if (notNull) { - aggregationType = AggregateType.valueOf(Text.readString(in)); - isAggregationTypeImplicit = in.readBoolean(); - } - isKey = in.readBoolean(); - isAllowNull = in.readBoolean(); - notNull = in.readBoolean(); - if (notNull) { - defaultValue = Text.readString(in); - realDefaultValue = defaultValue; - } - stats = ColumnStats.read(in); - - comment = Text.readString(in); - } - public static Column read(DataInput in) throws IOException { String json = Text.readString(in); return GsonUtils.GSON.fromJson(json, Column.class); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnStats.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnStats.java index 8ba694b42dbe0b..198ca02f51b5c8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnStats.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnStats.java @@ -19,7 +19,6 @@ import org.apache.doris.analysis.Expr; import org.apache.doris.analysis.SlotRef; -import org.apache.doris.common.io.Writable; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; @@ -27,15 +26,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; import java.util.Objects; /** * Statistics for a single column. */ -public class ColumnStats implements Writable { +public class ColumnStats { private static final Logger LOG = LogManager.getLogger(ColumnStats.class); @SerializedName(value = "avgSerializedSize") @@ -120,26 +116,6 @@ public String toString() { "numNulls", numNulls).toString(); } - public void write(DataOutput out) throws IOException { - out.writeLong(numDistinctValues); - out.writeFloat(avgSerializedSize); - out.writeLong(maxSize); - out.writeLong(numNulls); - } - - public void readFields(DataInput in) throws IOException { - numDistinctValues = in.readLong(); - avgSerializedSize = in.readFloat(); - maxSize = in.readLong(); - numNulls = in.readLong(); - } - - public static ColumnStats read(DataInput in) throws IOException { - ColumnStats columnStats = new ColumnStats(); - columnStats.readFields(in); - return columnStats; - } - @Override public int hashCode() { return Objects.hash(avgSerializedSize, maxSize, numDistinctValues, numNulls); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/DistributionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/DistributionInfo.java index b8265ccae40df6..9b05f8ca70997a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/DistributionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/DistributionInfo.java @@ -84,6 +84,7 @@ public DistributionDesc toDistributionDesc() { throw new NotImplementedException("toDistributionDesc not implemented"); } + @Deprecated public void readFields(DataInput in) throws IOException { type = DistributionInfoType.valueOf(Text.readString(in)); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/HashDistributionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/HashDistributionInfo.java index 0967a3b912bc39..2de384961dd277 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/HashDistributionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/HashDistributionInfo.java @@ -66,6 +66,7 @@ public void setBucketNum(int bucketNum) { this.bucketNum = bucketNum; } + @Deprecated @Override public void readFields(DataInput in) throws IOException { super.readFields(in); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java index c2b3451cf671ac..da48ac980bf76a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ListPartitionInfo.java @@ -67,6 +67,7 @@ public ListPartitionInfo(boolean isAutoCreatePartitions, ArrayList exprs, } } + @Deprecated public static PartitionInfo read(DataInput in) throws IOException { if (Env.getCurrentEnvJournalVersion() >= FeMetaVersion.VERSION_136) { return GsonUtils.GSON.fromJson(Text.readString(in), ListPartitionInfo.class); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndex.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndex.java index 1d4d2d7e45eeed..d56f043873a9eb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndex.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndex.java @@ -19,7 +19,6 @@ 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; import org.apache.doris.persist.gson.GsonUtils; @@ -27,7 +26,6 @@ import com.google.gson.annotations.SerializedName; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -37,7 +35,7 @@ /** * The OlapTraditional table is a materialized table which stored as rowcolumnar file or columnar file */ -public class MaterializedIndex extends MetaObject implements Writable, GsonPostProcessable { +public class MaterializedIndex extends MetaObject implements GsonPostProcessable { public enum IndexState { NORMAL, @Deprecated @@ -208,11 +206,7 @@ public int getTabletOrderIdx(long tabletId) { return -1; } - @Override - public void write(DataOutput out) throws IOException { - Text.writeString(out, GsonUtils.GSON.toJson(this)); - } - + @Deprecated public void readFields(DataInput in) throws IOException { super.readFields(in); @@ -232,6 +226,7 @@ public void readFields(DataInput in) throws IOException { rollupFinishedVersion = in.readLong(); } + @Deprecated public static MaterializedIndex read(DataInput in) throws IOException { if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_136) { MaterializedIndex mi = new MaterializedIndex(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java index b0103e0d68bab0..f5e3cc90e85004 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java @@ -1559,6 +1559,7 @@ public void write(DataOutput out) throws IOException { Text.writeString(out, GsonUtils.GSON.toJson(this)); } + @Deprecated @Override public void readFields(DataInput in) throws IOException { super.readFields(in); @@ -1796,7 +1797,7 @@ public static OlapTable read(DataInput in) throws IOException { t.readFields(in); return t; } - return (OlapTable) GsonUtils.GSON.fromJson(Text.readString(in), OlapTable.class); + return GsonUtils.GSON.fromJson(Text.readString(in), OlapTable.class); } /* diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Partition.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Partition.java index 22762cbaeae61f..775ee5530c50e2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Partition.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Partition.java @@ -341,12 +341,14 @@ public boolean visualiseShadowIndex(long shadowIndexId, boolean isBaseIndex) { return true; } + @Deprecated public static Partition read(DataInput in) throws IOException { Partition partition = EnvFactory.getInstance().createPartition(); partition.readFields(in); return partition; } + @Deprecated @Override public void readFields(DataInput in) throws IOException { super.readFields(in); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java index 10c01f5f2dea35..8deaa6d5f41406 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionInfo.java @@ -29,8 +29,6 @@ import org.apache.doris.common.DdlException; 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 org.apache.doris.thrift.TStorageMedium; import org.apache.doris.thrift.TTabletType; @@ -42,7 +40,6 @@ import org.apache.logging.log4j.Logger; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -56,7 +53,7 @@ /* * Repository of a partition's related infos */ -public class PartitionInfo implements Writable { +public class PartitionInfo { private static final Logger LOG = LogManager.getLogger(PartitionInfo.class); @SerializedName("Type") @@ -361,16 +358,6 @@ public void addPartition(long partitionId, DataProperty dataProperty, idToInMemory.put(partitionId, isInMemory); } - public static PartitionInfo read(DataInput in) throws IOException { - if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_136) { - PartitionInfo partitionInfo = new PartitionInfo(); - partitionInfo.readFields(in); - return partitionInfo; - } else { - return GsonUtils.GSON.fromJson(Text.readString(in), PartitionInfo.class); - } - } - public boolean isMultiColumnPartition() { return isMultiColumnPartition; } @@ -431,11 +418,6 @@ public void resetPartitionIdForRestore( } } - @Override - public void write(DataOutput out) throws IOException { - Text.writeString(out, GsonUtils.GSON.toJson(this)); - } - @Deprecated public void readFields(DataInput in) throws IOException { type = PartitionType.valueOf(Text.readString(in)); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/RandomDistributionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/RandomDistributionInfo.java index 6ec9200c8ce20e..d225adbf0a2148 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/RandomDistributionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/RandomDistributionInfo.java @@ -62,6 +62,7 @@ public String toSql(boolean forSync) { return builder.toString(); } + @Deprecated @Override public void readFields(DataInput in) throws IOException { super.readFields(in); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java index a35f97537d1785..87e1d5d19b438b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java @@ -206,6 +206,7 @@ public void checkPartitionItemListsConflict(List list1, List= FeMetaVersion.VERSION_136) { return GsonUtils.GSON.fromJson(Text.readString(in), RangePartitionInfo.class); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Replica.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Replica.java index 7c22489285b3e2..22813ef51185c7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Replica.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Replica.java @@ -19,7 +19,6 @@ import org.apache.doris.common.Config; import org.apache.doris.common.io.Text; -import org.apache.doris.common.io.Writable; import org.apache.doris.common.util.DebugPointUtil; import org.apache.doris.system.Backend; import org.apache.doris.thrift.TTabletInfo; @@ -30,14 +29,13 @@ import org.apache.logging.log4j.Logger; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.Comparator; /** * This class represents the olap replica related metadata. */ -public class Replica implements Writable { +public class Replica { private static final Logger LOG = LogManager.getLogger(Replica.class); public static final VersionComparator VERSION_DESC_COMPARATOR = new VersionComparator(); public static final LastSuccessVersionComparator LAST_SUCCESS_VERSION_COMPARATOR = @@ -710,22 +708,7 @@ public String toStringSimple(boolean checkBeAlive) { return strBuffer.toString(); } - @Override - public void write(DataOutput out) throws IOException { - out.writeLong(id); - out.writeLong(backendId); - out.writeLong(version); - out.writeLong(versionHash); - out.writeLong(dataSize); - out.writeLong(rowCount); - Text.writeString(out, state.name()); - - out.writeLong(lastFailedVersion); - out.writeLong(lastFailedVersionHash); - out.writeLong(lastSuccessVersion); - out.writeLong(lastSuccessVersionHash); - } - + @Deprecated public void readFields(DataInput in) throws IOException { id = in.readLong(); backendId = in.readLong(); @@ -740,6 +723,7 @@ public void readFields(DataInput in) throws IOException { lastSuccessVersionHash = in.readLong(); } + @Deprecated public static Replica read(DataInput in) throws IOException { Replica replica = EnvFactory.getInstance().createReplica(); replica.readFields(in); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/SinglePartitionInfo.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/SinglePartitionInfo.java index 97cda77fb32991..495d57c61f9968 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/SinglePartitionInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/SinglePartitionInfo.java @@ -29,6 +29,7 @@ public SinglePartitionInfo() { super(PartitionType.UNPARTITIONED); } + @Deprecated public static PartitionInfo read(DataInput in) throws IOException { if (Env.getCurrentEnvJournalVersion() >= FeMetaVersion.VERSION_136) { return GsonUtils.GSON.fromJson(Text.readString(in), SinglePartitionInfo.class); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java index cdf59fe41b148d..899eb94b8d0956 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java @@ -27,7 +27,6 @@ import org.apache.doris.common.Pair; import org.apache.doris.common.UserException; import org.apache.doris.common.io.Text; -import org.apache.doris.common.io.Writable; import org.apache.doris.persist.gson.GsonUtils; import org.apache.doris.resource.Tag; import org.apache.doris.system.Backend; @@ -44,7 +43,6 @@ import org.apache.logging.log4j.Logger; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -60,7 +58,7 @@ /** * This class represents the olap tablet related metadata. */ -public class Tablet extends MetaObject implements Writable { +public class Tablet extends MetaObject { private static final Logger LOG = LogManager.getLogger(Tablet.class); // if current version count of replica is mor than // QUERYABLE_TIMES_OF_MIN_VERSION_COUNT times the minimum version count, @@ -394,12 +392,7 @@ public String toString() { return "tabletId=" + this.id; } - @Override - public void write(DataOutput out) throws IOException { - String json = GsonUtils.GSON.toJson(this); - Text.writeString(out, json); - } - + @Deprecated @Override public void readFields(DataInput in) throws IOException { super.readFields(in); @@ -418,6 +411,7 @@ public void readFields(DataInput in) throws IOException { isConsistent = in.readBoolean(); } + @Deprecated public static Tablet read(DataInput in) throws IOException { if (Env.getCurrentEnvJournalVersion() >= FeMetaVersion.VERSION_115) { String json = Text.readString(in); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TempPartitions.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/TempPartitions.java index f28eb870f771d0..083f69b741d930 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TempPartitions.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TempPartitions.java @@ -18,7 +18,6 @@ package org.apache.doris.catalog; import org.apache.doris.common.io.Text; -import org.apache.doris.common.io.Writable; import org.apache.doris.persist.gson.GsonPostProcessable; import org.apache.doris.persist.gson.GsonUtils; @@ -28,7 +27,6 @@ import com.google.gson.annotations.SerializedName; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.List; import java.util.Map; @@ -40,7 +38,7 @@ // user can load data into some of the temp partitions, // and then replace the formal partitions with these temp partitions // to make a overwrite load. -public class TempPartitions implements Writable, GsonPostProcessable { +public class TempPartitions implements GsonPostProcessable { @SerializedName(value = "idToPartition") private Map idToPartition = Maps.newHashMap(); private Map nameToPartition = Maps.newHashMap(); @@ -124,30 +122,12 @@ public void dropAll() { } } - @Override - public void write(DataOutput out) throws IOException { - String json = GsonUtils.GSON.toJson(this); - Text.writeString(out, json); - } - + @Deprecated public static TempPartitions read(DataInput in) throws IOException { String json = Text.readString(in); return GsonUtils.GSON.fromJson(json, TempPartitions.class); } - @Deprecated - private void readFields(DataInput in) throws IOException { - int size = in.readInt(); - for (int i = 0; i < size; i++) { - Partition partition = Partition.read(in); - idToPartition.put(partition.getId(), partition); - nameToPartition.put(partition.getName(), partition); - } - if (in.readBoolean()) { - partitionInfo = (RangePartitionInfo) RangePartitionInfo.read(in); - } - } - @Override public void gsonPostProcess() { for (Partition partition : idToPartition.values()) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudPartition.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudPartition.java index 42327b6039da36..b3f868ebe12b32 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudPartition.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudPartition.java @@ -36,7 +36,6 @@ import org.apache.logging.log4j.Logger; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -359,6 +358,7 @@ private static SummaryProfile getSummaryProfile() { return null; } + @Deprecated @Override public void readFields(DataInput in) throws IOException { super.readFields(in); @@ -366,13 +366,6 @@ public void readFields(DataInput in) throws IOException { this.tableId = in.readLong(); } - @Override - public void write(DataOutput out) throws IOException { - super.write(out); - out.writeLong(this.dbId); - out.writeLong(this.tableId); - } - public boolean equals(Object obj) { if (!super.equals(obj)) { return false; diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java index b18dbb9970e509..d2e173dfd5347f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java @@ -36,7 +36,6 @@ import org.apache.logging.log4j.Logger; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -347,6 +346,7 @@ && getVersion() == Partition.PARTITION_INIT_VERSION) { return true; } + @Deprecated @Override public void readFields(DataInput in) throws IOException { super.readFields(in); @@ -375,21 +375,6 @@ public void readFields(DataInput in) throws IOException { } } - @Override - public void write(DataOutput out) throws IOException { - super.write(out); - out.writeLong(dbId); - out.writeLong(tableId); - out.writeLong(partitionId); - out.writeLong(indexId); - out.writeLong(idx); - out.writeInt(clusterToBackends.size()); - for (Map.Entry> entry : clusterToBackends.entrySet()) { - Text.writeString(out, entry.getKey()); - out.writeLong(entry.getValue().get(0)); - } - } - public long getDbId() { return dbId; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/BackendIdsUpdateInfo.java b/fe/fe-core/src/main/java/org/apache/doris/persist/BackendIdsUpdateInfo.java deleted file mode 100644 index ac2e0ea9d23c79..00000000000000 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/BackendIdsUpdateInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -// 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.io.Writable; - -import com.google.common.collect.Lists; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.List; - -public class BackendIdsUpdateInfo implements Writable { - private List backendIds; - - public BackendIdsUpdateInfo() { - this.backendIds = Lists.newArrayList(); - } - - public BackendIdsUpdateInfo(List backends) { - this.backendIds = backends; - } - - @Override - public void write(DataOutput out) throws IOException { - out.writeInt(backendIds.size()); - for (Long id : backendIds) { - out.writeLong(id); - } - } - - public void readFields(DataInput in) throws IOException { - int backendCount = in.readInt(); - while (backendCount-- > 0) { - backendIds.add(in.readLong()); - } - } - - public List getBackendList() { - return backendIds; - } - - public void setBackendList(List backendList) { - this.backendIds = backendList; - } - -} diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/ClusterInfo.java b/fe/fe-core/src/main/java/org/apache/doris/persist/ClusterInfo.java deleted file mode 100644 index aad46a232f5683..00000000000000 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/ClusterInfo.java +++ /dev/null @@ -1,114 +0,0 @@ -// 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.io.Text; -import org.apache.doris.common.io.Writable; - -import com.google.common.collect.Lists; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.List; - -public class ClusterInfo implements Writable { - - private String clusterName; - private long clusterId; - private int instanceNum; - - private String newClusterName; - private long newClusterId; - private int newInstanceNum; - - private List expandBackendIds = Lists.newArrayList(); - - public ClusterInfo() { - this.clusterName = ""; - this.clusterId = 0L; - this.instanceNum = 0; - this.newClusterName = ""; - this.newClusterId = 0L; - this.newInstanceNum = 0; - } - - public ClusterInfo(String clusterName, long clusterId) { - this.clusterName = clusterName; - this.clusterId = clusterId; - this.instanceNum = 0; - this.newClusterName = ""; - this.newClusterId = 0L; - this.newInstanceNum = 0; - } - - public ClusterInfo(String clusterName, long clusterId, List expandBackendIds) { - this.clusterName = clusterName; - this.clusterId = clusterId; - this.expandBackendIds = expandBackendIds; - this.instanceNum = 0; - this.newClusterName = ""; - this.newClusterId = 0L; - this.newInstanceNum = 0; - } - - @Override - public void write(DataOutput out) throws IOException { - Text.writeString(out, clusterName); - out.writeLong(clusterId); - out.writeInt(instanceNum); - out.writeInt(expandBackendIds.size()); - for (long id : expandBackendIds) { - out.writeLong(id); - } - } - - public void readFields(DataInput in) throws IOException { - clusterName = Text.readString(in); - clusterId = in.readLong(); - instanceNum = in.readInt(); - int count = in.readInt(); - while (count-- > 0) { - expandBackendIds.add(in.readLong()); - } - } - - public String getClusterName() { - return clusterName; - } - - public long getClusterId() { - return clusterId; - } - - public int getInstanceNum() { - return instanceNum; - } - - public String getNewClusterName() { - return newClusterName; - } - - public int getNewInstanceNum() { - return newInstanceNum; - } - - public List getBackendIdList() { - return expandBackendIds; - } -} diff --git a/fe/fe-core/src/main/java/org/apache/doris/transaction/TabletCommitInfo.java b/fe/fe-core/src/main/java/org/apache/doris/transaction/TabletCommitInfo.java index ed8aa01320e579..8ca75a3bd7e7a2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/transaction/TabletCommitInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/transaction/TabletCommitInfo.java @@ -17,18 +17,16 @@ package org.apache.doris.transaction; -import org.apache.doris.common.io.Writable; import org.apache.doris.thrift.TTabletCommitInfo; import com.google.common.collect.Lists; import com.google.gson.Gson; import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import java.util.List; -public class TabletCommitInfo implements Writable { +public class TabletCommitInfo { private long tabletId; private long backendId; @@ -55,12 +53,7 @@ public static List fromThrift(List tTabletC return commitInfos; } - @Override - public void write(DataOutput out) throws IOException { - out.writeLong(tabletId); - out.writeLong(backendId); - } - + @Deprecated public void readFields(DataInput in) throws IOException { tabletId = in.readLong(); backendId = in.readLong(); diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnStatTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnStatTest.java index 9fe3ac8b59b9eb..5e48f91069e2eb 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnStatTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnStatTest.java @@ -17,6 +17,9 @@ package org.apache.doris.catalog; +import org.apache.doris.common.io.Text; +import org.apache.doris.persist.gson.GsonUtils; + import org.junit.Assert; import org.junit.Test; @@ -35,42 +38,40 @@ public void testSerialization() throws Exception { DataOutputStream dos = new DataOutputStream(Files.newOutputStream(path)); ColumnStats stats1 = new ColumnStats(); - stats1.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(stats1)); ColumnStats stats2 = new ColumnStats(); stats2.setAvgSerializedSize(1.1f); stats2.setNumDistinctValues(100L); stats2.setMaxSize(1000L); stats2.setNumNulls(10000L); - stats2.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(stats2)); ColumnStats stats3 = new ColumnStats(); stats3.setAvgSerializedSize(3.3f); stats3.setNumDistinctValues(200L); stats3.setMaxSize(2000L); stats3.setNumNulls(20000L); - stats3.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(stats3)); ColumnStats stats4 = new ColumnStats(stats3); - stats4.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(stats4)); dos.flush(); dos.close(); // 2. Read objects from file DataInputStream dis = new DataInputStream(Files.newInputStream(path)); - ColumnStats rStats1 = new ColumnStats(); - rStats1.readFields(dis); + ColumnStats rStats1 = GsonUtils.GSON.fromJson(Text.readString(dis), ColumnStats.class); Assert.assertEquals(rStats1, stats1); - ColumnStats rStats2 = new ColumnStats(); - rStats2.readFields(dis); + ColumnStats rStats2 = GsonUtils.GSON.fromJson(Text.readString(dis), ColumnStats.class); Assert.assertEquals(rStats2, stats2); - ColumnStats rStats3 = ColumnStats.read(dis); + ColumnStats rStats3 = GsonUtils.GSON.fromJson(Text.readString(dis), ColumnStats.class); Assert.assertEquals(rStats3, stats3); - ColumnStats rStats4 = ColumnStats.read(dis); + ColumnStats rStats4 = GsonUtils.GSON.fromJson(Text.readString(dis), ColumnStats.class); Assert.assertEquals(rStats4, stats4); Assert.assertEquals(rStats4, stats3); diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java index 45e4df06589b31..431ce02ae201a8 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java @@ -19,7 +19,9 @@ import org.apache.doris.common.DdlException; import org.apache.doris.common.FeConstants; +import org.apache.doris.common.io.Text; import org.apache.doris.common.jmockit.Deencapsulation; +import org.apache.doris.persist.gson.GsonUtils; import org.junit.Assert; import org.junit.Before; @@ -53,26 +55,26 @@ public void testSerialization() throws Exception { Column column1 = new Column("user", ScalarType.createChar(20), false, AggregateType.SUM, "", ""); - column1.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(column1)); Column column2 = new Column("age", ScalarType.createType(PrimitiveType.INT), false, AggregateType.REPLACE, "20", ""); - column2.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(column2)); Column column3 = new Column("name", PrimitiveType.BIGINT); column3.setIsKey(true); - column3.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(column3)); Column column4 = new Column("age", ScalarType.createType(PrimitiveType.INT), false, AggregateType.REPLACE, "20", ""); - column4.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(column4)); dos.flush(); dos.close(); // 2. Read objects from file DataInputStream dis = new DataInputStream(Files.newInputStream(path)); - Column rColumn1 = Column.read(dis); + Column rColumn1 = GsonUtils.GSON.fromJson(Text.readString(dis), Column.class); Assert.assertEquals("user", rColumn1.getName()); Assert.assertEquals(PrimitiveType.CHAR, rColumn1.getDataType()); Assert.assertEquals(AggregateType.SUM, rColumn1.getAggregationType()); @@ -83,16 +85,16 @@ public void testSerialization() throws Exception { Assert.assertFalse(rColumn1.isAllowNull()); // 3. Test read() - Column rColumn2 = Column.read(dis); + Column rColumn2 = GsonUtils.GSON.fromJson(Text.readString(dis), Column.class); Assert.assertEquals("age", rColumn2.getName()); Assert.assertEquals(PrimitiveType.INT, rColumn2.getDataType()); Assert.assertEquals(AggregateType.REPLACE, rColumn2.getAggregationType()); Assert.assertEquals("20", rColumn2.getDefaultValue()); - Column rColumn3 = Column.read(dis); + Column rColumn3 = GsonUtils.GSON.fromJson(Text.readString(dis), Column.class); Assert.assertEquals(rColumn3, column3); - Column rColumn4 = Column.read(dis); + Column rColumn4 = GsonUtils.GSON.fromJson(Text.readString(dis), Column.class); Assert.assertEquals(rColumn4, column4); Assert.assertEquals(rColumn2.toString(), column2.toString()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/MaterializedIndexTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/MaterializedIndexTest.java index ccc8f8925eb0f4..25b94bc59e828d 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/MaterializedIndexTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/MaterializedIndexTest.java @@ -19,6 +19,8 @@ import org.apache.doris.catalog.MaterializedIndex.IndexState; import org.apache.doris.common.FeConstants; +import org.apache.doris.common.io.Text; +import org.apache.doris.persist.gson.GsonUtils; import mockit.Mocked; import org.junit.Assert; @@ -70,14 +72,14 @@ public void testSerialization() throws Exception { Path path = Files.createFile(Paths.get("./index")); DataOutputStream dos = new DataOutputStream(Files.newOutputStream(path)); - index.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(index)); dos.flush(); dos.close(); // 2. Read objects from file DataInputStream dis = new DataInputStream(Files.newInputStream(path)); - MaterializedIndex rIndex = MaterializedIndex.read(dis); + MaterializedIndex rIndex = GsonUtils.GSON.fromJson(Text.readString(dis), MaterializedIndex.class); Assert.assertEquals(index, rIndex); // 3. delete files diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/RangePartitionInfoTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/RangePartitionInfoTest.java index e1112c8cb383c7..3121397a7722a8 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/RangePartitionInfoTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/RangePartitionInfoTest.java @@ -23,6 +23,8 @@ import org.apache.doris.analysis.SinglePartitionDesc; import org.apache.doris.common.AnalysisException; import org.apache.doris.common.DdlException; +import org.apache.doris.common.io.Text; +import org.apache.doris.persist.gson.GsonUtils; import com.google.common.collect.Lists; import org.junit.Assert; @@ -457,14 +459,14 @@ public void testSerialization() throws IOException, AnalysisException, DdlExcept partitionInfo = new RangePartitionInfo(partitionColumns); - partitionInfo.write(out); + Text.writeString(out, GsonUtils.GSON.toJson(partitionInfo)); out.flush(); out.close(); // 2. Read objects from file DataInputStream in = new DataInputStream(Files.newInputStream(path)); - RangePartitionInfo partitionInfo2 = (RangePartitionInfo) PartitionInfo.read(in); + RangePartitionInfo partitionInfo2 = GsonUtils.GSON.fromJson(Text.readString(in), RangePartitionInfo.class); Assert.assertEquals(partitionInfo.getType(), partitionInfo2.getType()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaTest.java index eb7dbca0775e54..63f61cc8747b87 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ReplicaTest.java @@ -18,6 +18,8 @@ package org.apache.doris.catalog; import org.apache.doris.catalog.Replica.ReplicaState; +import org.apache.doris.common.io.Text; +import org.apache.doris.persist.gson.GsonUtils; import mockit.Mocked; import org.junit.Assert; @@ -85,20 +87,19 @@ public void testSerialization() throws Exception { Replica olapReplica = new Replica(100L * count, 100L * count, 100L * count, 0, 100L * count, 0, 100 * count, ReplicaState.NORMAL, 0, 100L * count); list1.add(olapReplica); - olapReplica.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(olapReplica)); } Replica replica = new Replica(10L, 20L, 0, null); list1.add(replica); - replica.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(replica)); dos.flush(); dos.close(); // 2. Read a object from file DataInputStream dis = new DataInputStream(Files.newInputStream(path)); for (int count = 0; count < 10; ++count) { - Replica olapReplica = new Replica(); - olapReplica.readFields(dis); + Replica olapReplica = GsonUtils.GSON.fromJson(Text.readString(dis), Replica.class); Assert.assertEquals(100 * count, olapReplica.getId()); Assert.assertEquals(100 * count, olapReplica.getBackendId()); Assert.assertEquals(100 * count, olapReplica.getVersion()); @@ -107,8 +108,7 @@ public void testSerialization() throws Exception { Assert.assertEquals(Replica.ReplicaState.NORMAL, olapReplica.getState()); list2.add(olapReplica); } - Replica olapReplica = new Replica(); - olapReplica.readFields(dis); + Replica olapReplica = GsonUtils.GSON.fromJson(Text.readString(dis), Replica.class); list2.add(olapReplica); // 3. Check equal diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/TabletTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/TabletTest.java index d7fdb2694a8282..2b15d962884e17 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/TabletTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/TabletTest.java @@ -20,6 +20,8 @@ import org.apache.doris.catalog.Replica.ReplicaState; import org.apache.doris.common.FeConstants; import org.apache.doris.common.Pair; +import org.apache.doris.common.io.Text; +import org.apache.doris.persist.gson.GsonUtils; import org.apache.doris.thrift.TStorageMedium; import com.google.common.collect.Sets; @@ -117,13 +119,13 @@ public void deleteReplicaTest() { public void testSerialization() throws Exception { final Path path = Files.createTempFile("olapTabletTest", "tmp"); DataOutputStream dos = new DataOutputStream(Files.newOutputStream(path)); - tablet.write(dos); + Text.writeString(dos, GsonUtils.GSON.toJson(tablet)); dos.flush(); dos.close(); // 2. Read a object from file DataInputStream dis = new DataInputStream(Files.newInputStream(path)); - Tablet rTablet1 = Tablet.read(dis); + Tablet rTablet1 = GsonUtils.GSON.fromJson(Text.readString(dis), Tablet.class); Assert.assertEquals(1, rTablet1.getId()); Assert.assertEquals(3, rTablet1.getReplicas().size()); Assert.assertEquals(rTablet1.getReplicas().get(0).getVersion(), rTablet1.getReplicas().get(1).getVersion()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/TempPartitionTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/TempPartitionTest.java index 19b191a4cd2fad..04e6bb8a151089 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/TempPartitionTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/TempPartitionTest.java @@ -30,8 +30,10 @@ import org.apache.doris.common.AnalysisException; import org.apache.doris.common.FeConstants; import org.apache.doris.common.FeMetaVersion; +import org.apache.doris.common.io.Text; import org.apache.doris.common.jmockit.Deencapsulation; import org.apache.doris.meta.MetaContext; +import org.apache.doris.persist.gson.GsonUtils; import org.apache.doris.qe.ConnectContext; import org.apache.doris.qe.ShowExecutor; import org.apache.doris.qe.ShowResultSet; @@ -1299,7 +1301,7 @@ private void testSerializeTempPartitions(TempPartitions tempPartitionsInstance) file.createNewFile(); DataOutputStream out = new DataOutputStream(new FileOutputStream(file)); - tempPartitionsInstance.write(out); + Text.writeString(out, GsonUtils.GSON.toJson(tempPartitionsInstance)); out.flush(); out.close();