| 112 | return G(secondOperand) ? ToDouble() : secondOperand.ToDouble(); |
| 113 | } |
| 114 | double TExpressionVariable::HistogramPercentile(const TExpressionVariable& percentile) const { |
| 115 | if (!ToHistogramPointsAndBins().IsValidData(percentile.ToDouble())) { |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | const auto& result = ToHistogramPointsAndBins().FindBinAndPartion(percentile.ToDouble()); |
| 120 | const auto& binIndex = result.first; |
| 121 | const auto& partion = result.second; |
| 122 | |
| 123 | // if percentile in [last point; +inf) return last point * 1.1 |
| 124 | if (static_cast<size_t>(binIndex) == ToHistogramPointsAndBins().GetBins().size() - 1) { |
| 125 | return ToHistogramPointsAndBins().GetPoints().back() * 1.1; |
| 126 | } |
| 127 | |
| 128 | auto leftBorderPoint = binIndex != 0 ? ToHistogramPointsAndBins().GetPoints()[binIndex - 1] : 0; |
| 129 | auto rightBorderPoint = ToHistogramPointsAndBins().GetPoints()[binIndex]; |
| 130 | |
| 131 | // if right border is max_int return left border * 1.1 |
| 132 | if (rightBorderPoint == std::numeric_limits<int>::max()) { |
| 133 | return ToHistogramPointsAndBins().GetPoints()[ToHistogramPointsAndBins().GetPoints().size() - 2] * 1.1; |
| 134 | } |
| 135 | |
| 136 | return leftBorderPoint + (rightBorderPoint - leftBorderPoint) * partion; |
| 137 | } |
| 138 | double TExpressionVariable::Or(const TExpressionVariable& secondOperand) const { |
| 139 | return !(IsZeroDoubleValue() && secondOperand.IsZeroDoubleValue()); |
| 140 | } |
no test coverage detected