From 9d7530e3e61db7b66c00e00b719794a2424b9e20 Mon Sep 17 00:00:00 2001 From: englefly Date: Fri, 27 Sep 2024 23:02:34 +0800 Subject: [PATCH] fmt --- .../doris/nereids/stats/StatsCalculator.java | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java index da61d442fcf024..9458407295d903 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java @@ -213,48 +213,6 @@ public static StatsCalculator estimate(GroupExpression groupExpression, boolean return statsCalculator; } - /** - * disable join reorder if any table row count is not available. - */ - public static void disableJoinReorderIfTableRowCountNotAvailable( - List scans, CascadesContext context) { - StatsCalculator calculator = new StatsCalculator(context); - for (LogicalOlapScan scan : scans) { - double rowCount = calculator.getOlapTableRowCount(scan); - if (rowCount == -1 && ConnectContext.get() != null) { - try { - ConnectContext.get().getSessionVariable().disableNereidsJoinReorderOnce(); - LOG.info("disable join reorder since row count not available: " - + scan.getTable().getNameWithFullQualifiers()); - } catch (Exception e) { - LOG.info("disableNereidsJoinReorderOnce failed"); - } - return; - } - } - } - - /** - * if the table is not analyzed and BE does not report row count, return -1 - */ - private double getOlapTableRowCount(OlapScan olapScan) { - OlapTable olapTable = olapScan.getTable(); - AnalysisManager analysisManager = Env.getCurrentEnv().getAnalysisManager(); - TableStatsMeta tableMeta = analysisManager.findTableStatsStatus(olapScan.getTable().getId()); - double rowCount = -1; - if (tableMeta != null && tableMeta.userInjected) { - rowCount = tableMeta.getRowCount(olapScan.getSelectedIndexId()); - } else { - rowCount = olapTable.getRowCountForIndex(olapScan.getSelectedIndexId(), true); - if (rowCount == -1) { - if (tableMeta != null) { - rowCount = tableMeta.getRowCount(olapScan.getSelectedIndexId()); - } - } - } - return rowCount; - } - public static StatsCalculator estimate(GroupExpression groupExpression, boolean forbidUnknownColStats, Map columnStatisticMap, boolean isPlayNereidsDump, CascadesContext context) { return StatsCalculator.estimate(groupExpression, @@ -1180,4 +1138,46 @@ public Statistics visitPhysicalCTEAnchor( return groupExpression.childStatistics(1); } + /** + * if the table is not analyzed and BE does not report row count, return -1 + */ + private double getOlapTableRowCount(OlapScan olapScan) { + OlapTable olapTable = olapScan.getTable(); + AnalysisManager analysisManager = Env.getCurrentEnv().getAnalysisManager(); + TableStatsMeta tableMeta = analysisManager.findTableStatsStatus(olapScan.getTable().getId()); + double rowCount = -1; + if (tableMeta != null && tableMeta.userInjected) { + rowCount = tableMeta.getRowCount(olapScan.getSelectedIndexId()); + } else { + rowCount = olapTable.getRowCountForIndex(olapScan.getSelectedIndexId(), true); + if (rowCount == -1) { + if (tableMeta != null) { + rowCount = tableMeta.getRowCount(olapScan.getSelectedIndexId()); + } + } + } + return rowCount; + } + + /** + * disable join reorder if any table row count is not available. + */ + public static void disableJoinReorderIfTableRowCountNotAvailable( + List scans, + CascadesContext context) { + StatsCalculator calculator = new StatsCalculator(context); + for (LogicalOlapScan scan : scans) { + double rowCount = calculator.getOlapTableRowCount(scan); + if (rowCount == -1 && ConnectContext.get() != null) { + try { + ConnectContext.get().getSessionVariable().disableNereidsJoinReorderOnce(); + LOG.info("disable join reorder since row count not available: " + + scan.getTable().getNameWithFullQualifiers()); + } catch (Exception e) { + LOG.info("disableNereidsJoinReorderOnce failed"); + } + return; + } + } + } }