Skip to content

Commit

Permalink
[opt](binlog) Support rename column binlog (apache#39782)
Browse files Browse the repository at this point in the history
  • Loading branch information
smallx authored Sep 20, 2024
1 parent 7a00dd4 commit c55c721
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.doris.persist.ReplacePartitionOperationLog;
import org.apache.doris.persist.TableAddOrDropColumnsInfo;
import org.apache.doris.persist.TableInfo;
import org.apache.doris.persist.TableRenameColumnInfo;
import org.apache.doris.persist.TruncateTableInfo;
import org.apache.doris.thrift.TBinlog;
import org.apache.doris.thrift.TBinlogType;
Expand Down Expand Up @@ -330,6 +331,17 @@ public void addTableRename(TableInfo info, long commitSeq) {
addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false, info);
}

public void addColumnRename(TableRenameColumnInfo info, long commitSeq) {
long dbId = info.getDbId();
List<Long> tableIds = Lists.newArrayList();
tableIds.add(info.getTableId());
long timestamp = -1;
TBinlogType type = TBinlogType.RENAME_COLUMN;
String data = info.toJson();

addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false, info);
}

// get binlog by dbId, return first binlog.version > version
public Pair<TStatus, TBinlog> getBinlog(long dbId, long tableId, long prevCommitSeq) {
TStatus status = new TStatus(TStatusCode.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,9 @@ public void logPartitionRename(TableInfo tableInfo) {
}

public void logColumnRename(TableRenameColumnInfo info) {
logEdit(OperationType.OP_RENAME_COLUMN, info);
long logId = logEdit(OperationType.OP_RENAME_COLUMN, info);
LOG.info("log column rename, logId : {}, infos: {}", logId, info);
Env.getCurrentEnv().getBinlogManager().addColumnRename(info, logId);
}

public void logAddBroker(BrokerMgr.ModifyBrokerInfo info) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public static TableRenameColumnInfo read(DataInput in) throws IOException {
return GsonUtils.GSON.fromJson(Text.readString(in), TableRenameColumnInfo.class);
}

public String toJson() {
return GsonUtils.GSON.toJson(this);
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
Expand Down
1 change: 1 addition & 0 deletions gensrc/thrift/FrontendService.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ enum TBinlogType {
REPLACE_PARTITIONS = 12,
TRUNCATE_TABLE = 13,
RENAME_TABLE = 14,
RENAME_COLUMN = 15,
}

struct TBinlog {
Expand Down

0 comments on commit c55c721

Please sign in to comment.