Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Jun 24, 2024
1 parent a498879 commit d30650b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;
import org.apache.doris.thrift.TFunctionName;

import com.google.common.base.Strings;
Expand All @@ -33,15 +32,14 @@
import org.apache.logging.log4j.Logger;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Objects;

/**
* Class to represent a function name. Function names are specified as
* db.function_name.
*/
public class FunctionName implements Writable {
public class FunctionName {
private static final Logger LOG = LogManager.getLogger(FunctionName.class);

@SerializedName("db")
Expand Down Expand Up @@ -168,17 +166,6 @@ public TFunctionName toThrift() {
return name;
}

@Override
public void write(DataOutput out) throws IOException {
if (db != null) {
out.writeBoolean(true);
Text.writeString(out, db);
} else {
out.writeBoolean(false);
}
Text.writeString(out, fn);
}

public void readFields(DataInput in) throws IOException {
if (in.readBoolean()) {
db = Text.readString(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@

import org.apache.doris.analysis.DistributionDesc;
import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;

import com.google.gson.annotations.SerializedName;
import org.apache.commons.lang3.NotImplementedException;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Objects;

public abstract class DistributionInfo implements Writable {
public abstract class DistributionInfo {

public enum DistributionInfoType {
HASH,
Expand Down Expand Up @@ -86,11 +84,6 @@ public DistributionDesc toDistributionDesc() {
throw new NotImplementedException("toDistributionDesc not implemented");
}

@Override
public void write(DataOutput out) throws IOException {
Text.writeString(out, type.name());
}

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 @@ -25,7 +25,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.List;
Expand Down Expand Up @@ -67,17 +66,6 @@ public void setBucketNum(int bucketNum) {
this.bucketNum = bucketNum;
}

@Override
public void write(DataOutput out) throws IOException {
super.write(out);
int columnCount = distributionColumns.size();
out.writeInt(columnCount);
for (Column column : distributionColumns) {
column.write(out);
}
out.writeInt(bucketNum);
}

@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 @@ -17,9 +17,11 @@

package org.apache.doris.catalog;

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;
Expand Down Expand Up @@ -208,21 +210,7 @@ public int getTabletOrderIdx(long tabletId) {

@Override
public void write(DataOutput out) throws IOException {
super.write(out);

out.writeLong(id);

Text.writeString(out, state.name());
out.writeLong(rowCount);

int tabletCount = tablets.size();
out.writeInt(tabletCount);
for (Tablet tablet : tablets) {
tablet.write(out);
}

out.writeLong(rollupIndexId);
out.writeLong(rollupFinishedVersion);
Text.writeString(out, GsonUtils.GSON.toJson(this));
}

public void readFields(DataInput in) throws IOException {
Expand All @@ -245,9 +233,13 @@ public void readFields(DataInput in) throws IOException {
}

public static MaterializedIndex read(DataInput in) throws IOException {
MaterializedIndex materializedIndex = new MaterializedIndex();
materializedIndex.readFields(in);
return materializedIndex;
if (Env.getCurrentEnvJournalVersion() < FeMetaVersion.VERSION_136) {
MaterializedIndex mi = new MaterializedIndex();
mi.readFields(in);
return mi;
}

return GsonUtils.GSON.fromJson(Text.readString(in), MaterializedIndex.class);
}

@Override
Expand Down
39 changes: 1 addition & 38 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Partition.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;
import org.apache.doris.rpc.RpcException;

import com.google.common.base.Preconditions;
Expand All @@ -35,7 +34,6 @@
import org.apache.logging.log4j.Logger;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
import java.util.Map;
Expand All @@ -45,7 +43,7 @@
/**
* Internal representation of partition-related metadata.
*/
public class Partition extends MetaObject implements Writable {
public class Partition extends MetaObject {
private static final Logger LOG = LogManager.getLogger(Partition.class);

// Every partition starts from version 1, version 1 has no data
Expand Down Expand Up @@ -349,41 +347,6 @@ public static Partition read(DataInput in) throws IOException {
return partition;
}

@Override
public void write(DataOutput out) throws IOException {
super.write(out);

out.writeLong(id);
Text.writeString(out, name);
Text.writeString(out, state.name());

baseIndex.write(out);

int rollupCount = (idToVisibleRollupIndex != null) ? idToVisibleRollupIndex.size() : 0;
out.writeInt(rollupCount);
if (idToVisibleRollupIndex != null) {
for (Map.Entry<Long, MaterializedIndex> entry : idToVisibleRollupIndex.entrySet()) {
entry.getValue().write(out);
}
}

out.writeInt(idToShadowIndex.size());
for (MaterializedIndex shadowIndex : idToShadowIndex.values()) {
shadowIndex.write(out);
}

out.writeLong(visibleVersion);
out.writeLong(visibleVersionTime);
out.writeLong(visibleVersionHash);

out.writeLong(nextVersion);
out.writeLong(nextVersionHash);
out.writeLong(committedVersionHash);

Text.writeString(out, distributionInfo.getType().name());
distributionInfo.write(out);
}

@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 @@ -19,11 +19,14 @@

import org.apache.doris.thrift.TPartitionType;

import com.google.gson.annotations.SerializedName;

public enum PartitionType {
UNPARTITIONED("UNPARTITIONED"),
RANGE("RANGE"),
LIST("LIST");

@SerializedName("ts")
public String typeString;

private PartitionType(String typeString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.doris.analysis.RandomDistributionDesc;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Objects;

Expand Down Expand Up @@ -63,12 +62,6 @@ public String toSql(boolean forSync) {
return builder.toString();
}

@Override
public void write(DataOutput out) throws IOException {
super.write(out);
out.writeInt(bucketNum);
}

@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 @@ -19,21 +19,19 @@

import org.apache.doris.catalog.constraint.Constraint;
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;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* TableAttributes contains additional information about all table
*/
public class TableAttributes implements Writable {
public class TableAttributes {
public static final long TABLE_INIT_VERSION = 1L;

@SerializedName(value = "constraints")
Expand Down Expand Up @@ -73,11 +71,6 @@ public long getNextVersion() {
return visibleVersion + 1;
}

@Override
public void write(DataOutput out) throws IOException {
Text.writeString(out, GsonUtils.GSON.toJson(this));
}

public TableAttributes read(DataInput in) throws IOException {
TableAttributes tableAttributes = GsonUtils.GSON.fromJson(Text.readString(in), TableAttributes.class);
// To be compatible with previous versions
Expand Down

0 comments on commit d30650b

Please sign in to comment.