Skip to content

Commit

Permalink
[BugFix] Fix incorrect materialized view row count (#51944)
Browse files Browse the repository at this point in the history
Signed-off-by: kaijian.ding <[email protected]>
  • Loading branch information
kaijianding authored Oct 17, 2024
1 parent 6ecdc5b commit 1df36e4
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.common.collect.Maps;
import com.starrocks.catalog.MaterializedIndex.IndexExtState;
import com.starrocks.common.Config;
import com.starrocks.common.Pair;
import com.starrocks.common.util.FrontendDaemon;
import com.starrocks.common.util.concurrent.lock.LockType;
import com.starrocks.common.util.concurrent.lock.Locker;
Expand Down Expand Up @@ -116,7 +117,7 @@ protected void runAfterCatalogReady() {

// NOTE: calculate the row first with read lock, then update the stats with write lock
locker.lockTableWithIntensiveDbLock(db.getId(), table.getId(), LockType.READ);
Map<Long, Long> indexRowCountMap = Maps.newHashMap();
Map<Pair<Long, Long>, Long> indexRowCountMap = Maps.newHashMap();
try {
OlapTable olapTable = (OlapTable) table;
for (Partition partition : olapTable.getAllPartitions()) {
Expand All @@ -129,7 +130,8 @@ protected void runAfterCatalogReady() {
for (Tablet tablet : index.getTablets()) {
indexRowCount += tablet.getRowCount(version);
} // end for tablets
indexRowCountMap.put(index.getId(), indexRowCount);
indexRowCountMap.put(Pair.create(physicalPartition.getId(), index.getId()),
indexRowCount);
if (!olapTable.isTempPartition(partition.getId())) {
totalRowCount += indexRowCount;
}
Expand All @@ -150,7 +152,8 @@ protected void runAfterCatalogReady() {
for (PhysicalPartition physicalPartition : partition.getSubPartitions()) {
for (MaterializedIndex index :
physicalPartition.getMaterializedIndices(IndexExtState.VISIBLE)) {
Long indexRowCount = indexRowCountMap.get(index.getId());
Long indexRowCount =
indexRowCountMap.get(Pair.create(physicalPartition.getId(), index.getId()));
if (indexRowCount != null) {
index.setRowCount(indexRowCount);
}
Expand Down

0 comments on commit 1df36e4

Please sign in to comment.