Skip to content

Commit

Permalink
rebuild bf info when replay editlog
Browse files Browse the repository at this point in the history
  • Loading branch information
qidaye committed Nov 21, 2024
1 parent b14cd87 commit 9f063ff
Showing 1 changed file with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ private void processDropColumn(DropColumnClause alterClause, Table externalTable
* @throws DdlException
*/
private boolean processDropColumn(DropColumnClause alterClause, OlapTable olapTable,
Map<Long, LinkedList<Column>> indexSchemaMap, List<Index> indexes,
Map<String, String> propertyMap)
Map<Long, LinkedList<Column>> indexSchemaMap, List<Index> indexes)
throws DdlException {

String dropColName = alterClause.getColName();
Expand Down Expand Up @@ -435,15 +434,16 @@ private boolean processDropColumn(DropColumnClause alterClause, OlapTable olapTa
// drop bloom filter column
Set<String> bfCols = olapTable.getCopiedBfColumns();
if (bfCols != null) {
Set<String> newBfCols = new HashSet<>();
Set<String> newBfCols = null;
for (String bfCol : bfCols) {
if (!bfCol.equalsIgnoreCase(dropColName)) {
if (newBfCols == null) {
newBfCols = Sets.newHashSet();
}
newBfCols.add(bfCol);
}
}
propertyMap.put(PropertyAnalyzer.PROPERTIES_BF_COLUMNS, Joiner.on(",").join(newBfCols));
// drop bloom filter column, should write editlog and can not do light schema change
lightSchemaChange = false;
olapTable.setBloomFilterInfo(newBfCols, olapTable.getBfFpp());
}

for (int i = 1; i < indexIds.size(); i++) {
Expand Down Expand Up @@ -2080,7 +2080,7 @@ public int getAsInt() {
} else if (alterClause instanceof DropColumnClause) {
// drop column and drop indexes on this column
boolean clauseCanLigthSchemaChange = processDropColumn((DropColumnClause) alterClause, olapTable,
indexSchemaMap, newIndexes, propertyMap);
indexSchemaMap, newIndexes);
if (!clauseCanLigthSchemaChange) {
lightSchemaChange = false;
}
Expand Down Expand Up @@ -2956,6 +2956,25 @@ public void modifyTableLightSchemaChange(String rawSql, Database db, OlapTable o
LOG.info("finished modify table's add or drop or modify columns. table: {}, job: {}, is replay: {}",
olapTable.getName(), jobId, isReplay);
}
// for bloom filter, rebuild bloom filter info by table schema in replay
if (isReplay) {
Set<String> bfCols = olapTable.getCopiedBfColumns();
if (bfCols != null) {
List<Column> columns = olapTable.getBaseSchema();
Set<String> newBfCols = null;
for (String bfCol : bfCols) {
for (Column column : columns) {
if (column.getName().equalsIgnoreCase(bfCol)) {
if (newBfCols == null) {
newBfCols = Sets.newHashSet();
}
newBfCols.add(column.getName());
}
}
}
olapTable.setBloomFilterInfo(newBfCols, olapTable.getBfFpp());
}
}
}

public void replayModifyTableLightSchemaChange(TableAddOrDropColumnsInfo info)
Expand Down

0 comments on commit 9f063ff

Please sign in to comment.