Skip to content

Commit

Permalink
[Refactor](meta) Delete useless classes and write methods (apache#36894)
Browse files Browse the repository at this point in the history
Co-authored-by: zhangpeicheng <[email protected]>
  • Loading branch information
iszhangpch and zhangpeicheng authored Jun 28, 2024
1 parent 5765ffa commit 4e142a3
Show file tree
Hide file tree
Showing 30 changed files with 74 additions and 373 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -1439,6 +1440,7 @@ public Table getTable() {
return table;
}

@Deprecated
public void readFields(DataInput in) throws IOException {
dbId = in.readLong();
table = Table.read(in);
Expand Down
30 changes: 1 addition & 29 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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__";
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,19 @@

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;
import com.google.gson.annotations.SerializedName;
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")
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void setBucketNum(int bucketNum) {
this.bucketNum = bucketNum;
}

@Deprecated
@Override
public void readFields(DataInput in) throws IOException {
super.readFields(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public ListPartitionInfo(boolean isAutoCreatePartitions, ArrayList<Expr> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@

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;

import com.google.common.collect.Lists;
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;
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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")
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public String toSql(boolean forSync) {
return builder.toString();
}

@Deprecated
@Override
public void readFields(DataInput in) throws IOException {
super.readFields(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public void checkPartitionItemListsConflict(List<PartitionItem> list1, List<Part
RangeUtils.checkRangeConflict(list1, list2);
}

@Deprecated
public static PartitionInfo read(DataInput in) throws IOException {
if (Env.getCurrentEnvJournalVersion() >= FeMetaVersion.VERSION_136) {
return GsonUtils.GSON.fromJson(Text.readString(in), RangePartitionInfo.class);
Expand Down
22 changes: 3 additions & 19 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Replica.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Replica> VERSION_DESC_COMPARATOR = new VersionComparator<Replica>();
public static final LastSuccessVersionComparator<Replica> LAST_SUCCESS_VERSION_COMPARATOR =
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 4e142a3

Please sign in to comment.