diff --git a/fe/src/com/baidu/palo/alter/RollupJob.java b/fe/src/com/baidu/palo/alter/RollupJob.java index 6db03cfacd1683..467f42766bc6c4 100644 --- a/fe/src/com/baidu/palo/alter/RollupJob.java +++ b/fe/src/com/baidu/palo/alter/RollupJob.java @@ -624,6 +624,7 @@ public int tryFinishJob() { MaterializedIndex rollupIndex = this.partitionIdToRollupIndex.get(partitionId); Preconditions.checkNotNull(rollupIndex); + long rollupRowCount = 0L; // 1. record replica info for (Tablet tablet : rollupIndex.getTablets()) { long tabletId = tablet.getId(); @@ -634,8 +635,21 @@ public int tryFinishJob() { replica.getDataSize(), replica.getRowCount()); this.partitionIdToReplicaInfos.put(partitionId, replicaInfo); } + + // calculate rollup index row count + long tabletRowCount = 0L; + for (Replica replica : tablet.getReplicas()) { + long replicaRowCount = replica.getRowCount(); + if (replicaRowCount > tabletRowCount) { + tabletRowCount = replicaRowCount; + } + } + rollupRowCount += tabletRowCount; + } // end for tablets + rollupIndex.setRowCount(rollupRowCount); + // 2. add to partition partition.createRollupIndex(rollupIndex); @@ -717,11 +731,24 @@ public void unprotectedReplayFinish(Database db) { Partition partition = olapTable.getPartition(partitionId); MaterializedIndex rollupIndex = entry.getValue(); + long rollupRowCount = 0L; for (Tablet tablet : rollupIndex.getTablets()) { for (Replica replica : tablet.getReplicas()) { replica.setState(ReplicaState.NORMAL); } + + // calculate rollup index row count + long tabletRowCount = 0L; + for (Replica replica : tablet.getReplicas()) { + long replicaRowCount = replica.getRowCount(); + if (replicaRowCount > tabletRowCount) { + tabletRowCount = replicaRowCount; + } + } + rollupRowCount += tabletRowCount; } + + rollupIndex.setRowCount(rollupRowCount); rollupIndex.setState(IndexState.NORMAL); MaterializedIndex baseIndex = partition.getIndex(baseIndexId);