| 775 | } |
| 776 | |
| 777 | String PlanPrinter::TextPrinter::printQError(const PlanNodeBase & plan, const StepProfiles & profiles) |
| 778 | { |
| 779 | const auto & stats = plan.getStatistics(); |
| 780 | std::stringstream out; |
| 781 | |
| 782 | size_t step_id = plan.getId(); |
| 783 | if (profiles.count(step_id)) |
| 784 | { |
| 785 | const auto & profile = profiles.at(step_id); |
| 786 | if (plan.getChildren().size() > 1) |
| 787 | { |
| 788 | size_t max_input_rows = 0; |
| 789 | for (const auto & p : plan.getChildren()) |
| 790 | { |
| 791 | if (profiles.count(p->getId()) == 0) |
| 792 | continue; |
| 793 | max_input_rows = std::max(max_input_rows, profiles.at(p->getId())->output_rows); |
| 794 | } |
| 795 | if (max_input_rows == 0) |
| 796 | out << "Filtered: 0.0%"; |
| 797 | else |
| 798 | { |
| 799 | double max_rows = static_cast<double>(max_input_rows); |
| 800 | double filtered = max_rows > 0 ? (((max_rows - static_cast<double>(profile->output_rows)) * static_cast<double>(100) / max_rows)) : 0.0; |
| 801 | out << "Filtered: " << std::fixed << std::setprecision(1) << filtered << "%"; |
| 802 | } |
| 803 | } |
| 804 | else if (plan.getChildren().size() == 1) |
| 805 | { |
| 806 | if (profiles.count(plan.getChildren()[0]->getId()) == 0) |
| 807 | out << "Filtered: 0.0%"; |
| 808 | else |
| 809 | { |
| 810 | auto child_input_rows = static_cast<double>(profiles.at(plan.getChildren()[0]->getId())->output_rows); |
| 811 | double filtered = child_input_rows > 0 ? ((child_input_rows - static_cast<double>(profile->output_rows)) * static_cast<double>(100) / child_input_rows) : 0.0; |
| 812 | out << "Filtered: " << std::fixed << std::setprecision(1) << filtered << "%"; |
| 813 | } |
| 814 | } |
| 815 | else |
| 816 | { |
| 817 | out << "Filtered: 0.0%"; |
| 818 | } |
| 819 | |
| 820 | if (stats && stats.value()->getRowCount() != 0 && profile->output_rows != 0) |
| 821 | { |
| 822 | if (profile->output_rows > stats.value()->getRowCount()) |
| 823 | out << ", QError: " << std::fixed << std::setprecision(1) |
| 824 | << static_cast<double>(profile->output_rows) / static_cast<double>(stats.value()->getRowCount()); |
| 825 | else |
| 826 | out << ", QError: " << std::fixed << std::setprecision(1) |
| 827 | << static_cast<double>(stats.value()->getRowCount()) / static_cast<double>(profile->output_rows); |
| 828 | } |
| 829 | return out.str(); |
| 830 | } |
| 831 | return ""; |
| 832 | } |
| 833 | |
| 834 | String PlanPrinter::TextPrinter::printPrefix(PlanNodeBase & plan) |
nothing calls this directly
no test coverage detected