wgtmac commented on code in PR #1120:
URL: https://github.com/apache/iceberg-cpp/pull/1120#discussion_r4637944541
##########
src/iceberg/inspect/metadata_scan.h:
##########
@@ -52,6 +52,11 @@ struct MetadataScanContext {
std::optional<int64_t> snapshot_id;
std::string ref_name;
std::optional<int64_t> as_of_time_in_millis;
+ std::shared_ptr<FileIO> io;
Review Comment:
Can we avoid adding `io` to the context? We can do similar things as
`TableScanContext` and `TableScanBuilder` do and let `MetadataScanBuilder` to
hold `io`. The context is designed to only hold user selected configuration for
a (metadata) table scan.
##########
src/iceberg/CMakeLists.txt:
##########
@@ -63,6 +63,7 @@ set(ICEBERG_SOURCES
inspect/metadata_table.cc
inspect/metadata_scan_task.cc
inspect/metadata_scan_task_reader.cc
+ inspect/metadata_table_util_internal.cc
Review Comment:
nit: rename it to `inspect/metadata_table_util.cc`
##########
src/iceberg/inspect/metadata_table_util_internal.cc:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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 "iceberg/inspect/metadata_table_util_internal.h"
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "iceberg/constants.h"
+#include "iceberg/schema.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/type.h"
+#include "iceberg/util/macros.h"
+#include "iceberg/util/snapshot_util.h"
+
+namespace iceberg::internal {
+
+namespace {
+/// A scan that plans one task for a metadata table's selected snapshot.
+///
+/// The task retains the captured metadata, schemas, and FileIO so it can
outlive the
+/// scan. Table-specific row reading is deferred to the supplied callback when
+/// MetadataScanTaskReader opens the task.
+class SnapshotMetadataScan : public MetadataScan {
+ public:
+ SnapshotMetadataScan(MetadataScanContext context,
+ SnapshotMetadataTask::ReadRowsFunction read_rows)
+ : MetadataScan(context),
+ task_(std::make_shared<SnapshotMetadataTask>(std::move(context),
read_rows)) {}
+
+ Result<MetadataScanTaskStreamPtr> PlanTasksStream() const override {
+ // Each planning call gets a fresh stream over the same retained task.
+ return MetadataScanTaskStream::FromVector({task_});
+ }
+
+ private:
+ const std::shared_ptr<MetadataScanTask> task_;
Review Comment:
Do you plan to support multiple tasks in the future? I'm fine with the
current implementation but we need to consider parallel task execution and
serialization for better performance.
##########
src/iceberg/inspect/metadata_table_util_internal.h:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <utility>
+
+#include "iceberg/iceberg_export.h"
+#include "iceberg/inspect/metadata_scan.h"
+#include "iceberg/inspect/metadata_scan_task.h"
+#include "iceberg/result.h"
+
+namespace iceberg::internal {
+
+/// A task retaining the captured metadata, projection, and manifest IO.
+class SnapshotMetadataTask : public MetadataScanTask {
+ public:
+ using ReadRowsFunction = Result<ArrowArrayStream> (*)(const
MetadataScanContext&,
+ const
std::shared_ptr<FileIO>&,
+ int64_t);
Review Comment:
nit: add a comment for parameter name for `int64_t`.
##########
src/iceberg/inspect/metadata_table_util_internal.h:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <utility>
+
+#include "iceberg/iceberg_export.h"
+#include "iceberg/inspect/metadata_scan.h"
+#include "iceberg/inspect/metadata_scan_task.h"
+#include "iceberg/result.h"
+
+namespace iceberg::internal {
+
+/// A task retaining the captured metadata, projection, and manifest IO.
+class SnapshotMetadataTask : public MetadataScanTask {
Review Comment:
Why not putting them near `StaticMetadataTask`? It looks inconsistent.
--
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]