Skip to content

Commit

Permalink
[Enhancement] Optimize performance of get physical partition from ola…
Browse files Browse the repository at this point in the history
…p table (backport #47198) (#49613)

Co-authored-by: meegoo <[email protected]>
  • Loading branch information
mergify[bot] and meegoo authored Aug 8, 2024
1 parent 7ed5838 commit 0b3519d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ public Partition resetPartitionForRestore(OlapTable localTbl, OlapTable remoteTb
physicalPartition.setIdForRestore(newPhysicalPartId);
physicalPartition.setParentId(newPartId);
remotePart.addSubPartition(physicalPartition);
remoteTbl.addPhysicalPartition(physicalPartition);
}
// save version info for creating replicas
long visibleVersion = physicalPartition.getVisibleVersion();
Expand Down
4 changes: 4 additions & 0 deletions fe/fe-core/src/main/java/com/starrocks/catalog/OlapTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,10 @@ public void addPartition(Partition partition) {
}
}

public void addPhysicalPartition(PhysicalPartition physicalPartition) {
physicalPartitionIdToPartitionId.put(physicalPartition.getId(), physicalPartition.getParentId());
}

// This is a private method.
// Call public "dropPartitionAndReserveTablet" and "dropPartition"
private void dropPartition(long dbId, String partitionName, boolean isForceDrop, boolean reserveTablets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,7 @@ public void addSubPartitions(Database db, OlapTable table, Partition partition,
for (PhysicalPartition subPartition : subPartitions) {
// add sub partition
partition.addSubPartition(subPartition);
olapTable.addPhysicalPartition(subPartition);
}

// add partition log
Expand All @@ -1641,6 +1642,7 @@ public void replayAddSubPartition(PhysicalPartitionPersistInfoV2 info) throws Dd
Partition partition = olapTable.getPartition(info.getPartitionId());
PhysicalPartition physicalPartition = info.getPhysicalPartition();
partition.addSubPartition(physicalPartition);
olapTable.addPhysicalPartition(physicalPartition);

if (!isCheckpointThread()) {
// add to inverted index
Expand Down

0 comments on commit 0b3519d

Please sign in to comment.