deepaknettem commented on code in PR #1156:
URL: https://github.com/apache/iceberg-cpp/pull/1156#discussion_r4743688030
##########
src/iceberg/expression/inclusive_metrics_evaluator.cc:
##########
@@ -382,6 +327,38 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
}
private:
+ template <typename Literals>
+ Result<bool> MayMatchAny(const std::shared_ptr<Bound>& expr, const Literals&
literals) {
+ const int32_t id = expr->reference()->field().field_id();
+ if (ContainsNullsOnly(id)) {
+ return kRowCannotMatch;
+ }
+ if (literals.size() > kInPredicateLimit) {
+ return kRowsMightMatch;
+ }
+ if (ContainsNaNsOnly(id)) {
+ return std::ranges::any_of(literals, &Literal::IsNaN);
+ }
+
+ ICEBERG_ASSIGN_OR_RAISE(auto lower, LowerBound(expr));
+ ICEBERG_ASSIGN_OR_RAISE(auto upper, UpperBound(expr));
+ if ((lower && lower->IsNaN()) || (upper && upper->IsNaN())) {
Review Comment:
just noticed this our discussion on #1186, it might be better to change this
to
std::ranges::any_of(literals, &Literal::IsNaN) (to double check that neither
of the bounds contains a NaN)
##########
src/iceberg/expression/inclusive_metrics_evaluator.cc:
##########
@@ -382,6 +327,38 @@ class InclusiveMetricsVisitor : public BoundVisitor<bool> {
}
private:
+ template <typename Literals>
+ Result<bool> MayMatchAny(const std::shared_ptr<Bound>& expr, const Literals&
literals) {
+ const int32_t id = expr->reference()->field().field_id();
+ if (ContainsNullsOnly(id)) {
+ return kRowCannotMatch;
+ }
+ if (literals.size() > kInPredicateLimit) {
+ return kRowsMightMatch;
+ }
+ if (ContainsNaNsOnly(id)) {
+ return std::ranges::any_of(literals, &Literal::IsNaN);
+ }
+
+ ICEBERG_ASSIGN_OR_RAISE(auto lower, LowerBound(expr));
+ ICEBERG_ASSIGN_OR_RAISE(auto upper, UpperBound(expr));
+ if ((lower && lower->IsNaN()) || (upper && upper->IsNaN())) {
+ // A NaN at either end makes the file's bounds unreliable.
+ return kRowsMightMatch;
+ }
+
+ auto outside_bounds = [&](const Literal& lit) {
Review Comment:
nice, very readable, thanks for adopting~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]