YinZheng-Sun commented on code in PR #956:
URL: https://github.com/apache/iceberg-cpp/pull/956#discussion_r4237258416


##########
src/iceberg/parquet/parquet_metrics_row_group_filter.cc:
##########
@@ -0,0 +1,327 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <algorithm>
+#include <compare>
+#include <functional>
+#include <optional>
+#include <unordered_map>
+
+#include <parquet/statistics.h>
+
+#include "iceberg/expression/expression_visitor.h"
+#include "iceberg/expression/rewrite_not.h"
+#include "iceberg/metadata_columns.h"
+#include "iceberg/parquet/parquet_metrics_internal.h"
+#include "iceberg/parquet/parquet_metrics_row_group_filter_internal.h"
+#include "iceberg/parquet/parquet_schema_util_internal.h"
+#include "iceberg/type.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg::parquet {
+
+namespace {
+
+constexpr size_t kInPredicateLimit = 200;
+// True means a matching row may exist; false means the group can be skipped.
+constexpr bool kRowsMightMatch = true;
+constexpr bool kRowsCannotMatch = false;
+
+class MetricsVisitor : public BoundVisitor<bool> {
+ public:
+  MetricsVisitor(const ::parquet::arrow::SchemaManifest& manifest,
+                 const ::parquet::RowGroupMetaData& row_group,
+                 const std::unordered_map<int32_t, int>& column_indices)
+      : manifest_(manifest), row_group_(row_group), 
column_indices_(column_indices) {}
+
+  Result<bool> AlwaysTrue() override { return kRowsMightMatch; }
+
+  Result<bool> AlwaysFalse() override { return kRowsCannotMatch; }
+
+  Result<bool> Not(bool) override { return kRowsMightMatch; }

Review Comment:
   Java and Rust’s row-group metrics visitors do return !result, but their 
normal scan paths eliminate NOT before evaluation.
   Here, Make() also applies RewriteNot, so this method should not be reached. 
I used true as a conservative fallback because a might-match result cannot 
safely be negated: a group containing both 1 and 20 can match both x < 10 and 
NOT(x < 10).
   I’ll add a comment making the rewrite precondition and the reason for this 
fallback explicit.



-- 
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]

Reply via email to