Code review comment: this is fixed size, no need to resize

Code under review:
private Statistics computeOlapScan(LogicalOlapScan olapScan) {
        OlapTable olapTable = olapScan.getTable();

        if (olapScan.getSelectedIndexId() != olapScan.getTable().getBaseIndexId() || olapTable instanceof MTMV) {
            
            Optional<Statistics> optStats = cascadesContext.getStatementContext()
                    .getStatistics(olapScan.getRelationId());
            if (optStats.isPresent()) {
                double actualRowCount = olapScan.getTable().getRowCountForNereids();
                
                if (actualRowCount > optStats.get().getRowCount()) {
                    return optStats.get();
                }
            }
        }

        StatisticsBuilder builder = new StatisticsBuilder();

        
        if (StatisticConstants.isSystemTable(olapTable) || !FeConstants.enableInternalSchemaDb
                || ConnectContext.get() == null
                || ConnectContext.get().getSessionVariable().internalSession) {
            for (Slot slot : olapScan.getOutput()) {
                builder.putColumnStatistics(slot, ColumnStatistic.UNKNOWN);
            }
            setHasUnknownColStatsInStatementContext();
            builder.setRowCount(olapTable.getRowCountForNereids());
            return builder.build();
        }

        
        if (ConnectContext.get() == null || !ConnectContext.get().getSessionVariable().enableStats) {
            
            double rowCount = 1;
            for (Slot slot : olapScan.getOutput()) {
                if (isVisibleSlotReference(slot)) {
                    ColumnStatistic cache = getColumnStatistic(olapTable, slot.getName(),
                            olapScan.getSelectedIndexIdForMV());
                    rowCount = Math.max(rowCount, cache.count);
                }
                builder.putColumnStatistics(slot,
                        new ColumnStatisticBuilder(ColumnStatistic.UNKNOWN).setCount(rowCount).build());
            }
            setHasUnknownColStatsInStatementContext();
            return builder.setRowCount(rowCount).build();
        }

        
        
        List<SlotReference> outputSlotReferences = new ArrayList<>();
        for (Slot slot : olapScan.getOutput()) {
            if (isVisibleSlotReference(slot)) {
                outputSlotReferences.add((SlotReference) slot);
            } else {
                builder.putColumnStatistics(slot, ColumnStatistic.UNKNOWN);
            }
        }
        
        if (!olapScan.getSelectedPartitionIds().isEmpty()) {
            double rowCount = getSelectedPartitionRowCount(olapScan);
            
            if (rowCount > 0) {
                List<String> selectedPartitionNames = new ArrayList<>(olapScan.getSelectedPartitionIds().size());
                olapScan.getSelectedPartitionIds().forEach(id -> {
                    selectedPartitionNames.add(olapScan.getTable().getPartition(id).getName());
                });
                for (SlotReference slot : outputSlotReferences) {
                    ColumnStatistic cache = getColumnStatsFromPartitionCache(olapScan, slot, selectedPartitionNames);
                    ColumnStatisticBuilder colStatsBuilder = new ColumnStatisticBuilder(cache);
                    adjustColStats(olapScan, slot, colStatsBuilder);
                    builder.putColumnStatistics(slot, colStatsBuilder.build());
                    rowCount = Math.max(rowCount, colStatsBuilder.getCount());
                }
                checkIfUnknownStatsUsedAsKey(builder);
                return builder.setRowCount(rowCount).build();
            }
        }

        
        double rowCount = olapScan.getTable().getRowCountForNereids();
        for (SlotReference slot : outputSlotReferences) {
            ColumnStatistic cache = getColumnStatsFromTableCache(olapScan, slot);
            ColumnStatisticBuilder colStatsBuilder = new ColumnStatisticBuilder(cache);
            adjustColStats(olapScan, slot, colStatsBuilder);
            builder.putColumnStatistics(slot, colStatsBuilder.build());
            rowCount = Math.max(rowCount, colStatsBuilder.getCount());
        }
        checkIfUnknownStatsUsedAsKey(builder);
        return builder.setRowCount(rowCount).build();
    }

Line commented on: List<String> selectedPartitionNames = new ArrayList<>(olapScan.getSelectedPartitionIds().size());

Revised code:
private Statistics computeOlapScan(LogicalOlapScan olapScan) {
        OlapTable olapTable = olapScan.getTable();

        if (olapScan.getSelectedIndexId() != olapScan.getTable().getBaseIndexId() || olapTable instanceof MTMV) {
            
            Optional<Statistics> optStats = cascadesContext.getStatementContext()
                    .getStatistics(olapScan.getRelationId());
            if (optStats.isPresent()) {
                double actualRowCount = olapScan.getTable().getRowCountForNereids();
                
                if (actualRowCount > optStats.get().getRowCount()) {
                    return optStats.get();
                }
            }
        }

        StatisticsBuilder builder = new StatisticsBuilder();

        
        if (StatisticConstants.isSystemTable(olapTable) || !FeConstants.enableInternalSchemaDb
                || ConnectContext.get() == null
                || ConnectContext.get().getSessionVariable().internalSession) {
            for (Slot slot : olapScan.getOutput()) {
                builder.putColumnStatistics(slot, ColumnStatistic.UNKNOWN);
            }
            setHasUnknownColStatsInStatementContext();
            builder.setRowCount(olapTable.getRowCountForNereids());
            return builder.build();
        }

        
        if (ConnectContext.get() == null || !ConnectContext.get().getSessionVariable().enableStats) {
            
            double rowCount = 1;
            for (Slot slot : olapScan.getOutput()) {
                if (isVisibleSlotReference(slot)) {
                    ColumnStatistic cache = getColumnStatistic(olapTable, slot.getName(),
                            olapScan.getSelectedIndexIdForMV());
                    rowCount = Math.max(rowCount, cache.count);
                }
                builder.putColumnStatistics(slot,
                        new ColumnStatisticBuilder(ColumnStatistic.UNKNOWN).setCount(rowCount).build());
            }
            setHasUnknownColStatsInStatementContext();
            return builder.setRowCount(rowCount).build();
        }

        
        
        List<SlotReference> outputSlotReferences = new ArrayList<>();
        for (Slot slot : olapScan.getOutput()) {
            if (isVisibleSlotReference(slot)) {
                outputSlotReferences.add((SlotReference) slot);
            } else {
                builder.putColumnStatistics(slot, ColumnStatistic.UNKNOWN);
            }
        }
        
        if (!olapScan.getSelectedPartitionIds().isEmpty()) {
            double rowCount = getSelectedPartitionRowCount(olapScan);
            
            if (rowCount > 0) {
                List<String> selectedPartitionNames = new ArrayList<>(olapScan.getSelectedPartitionIds().size());
                olapScan.getSelectedPartitionIds().forEach(id -> {
                    selectedPartitionNames.add(olapScan.getTable().getPartition(id).getName());
                });
                for (SlotReference slot : outputSlotReferences) {
                    ColumnStatistic cache = getColumnStatsFromPartitionCache(olapScan, slot, selectedPartitionNames);
                    ColumnStatisticBuilder colStatsBuilder = new ColumnStatisticBuilder(cache);
                    adjustColStats(olapScan, slot, colStatsBuilder);
                    builder.putColumnStatistics(slot, colStatsBuilder.build());
                    rowCount = Math.max(rowCount, colStatsBuilder.getCount());
                }
                checkIfUnknownStatsUsedAsKey(builder);
                return builder.setRowCount(rowCount).build();
            }
        }

        
        double rowCount = olapScan.getTable().getRowCountForNereids();
        for (SlotReference slot : outputSlotReferences) {
            ColumnStatistic cache = getColumnStatsFromTableCache(olapScan, slot);
            ColumnStatisticBuilder colStatsBuilder = new ColumnStatisticBuilder(cache);
            adjustColStats(olapScan, slot, colStatsBuilder);
            builder.putColumnStatistics(slot, colStatsBuilder.build());
            rowCount = Math.max(rowCount, colStatsBuilder.getCount());
        }
        checkIfUnknownStatsUsedAsKey(builder);
        return builder.setRowCount(rowCount).build();
    }