Copilot commented on code in PR #875:
URL: https://github.com/apache/iceberg-cpp/pull/875#discussion_r4400567322


##########
src/iceberg/file_io.h:
##########
@@ -154,6 +157,30 @@ class ICEBERG_EXPORT FileIO {
   virtual Result<std::string> ReadFile(const std::string& file_location,
                                        std::optional<size_t> length);
 
+  /// \brief Create an input handle backed by the metadata content cache when 
enabled.
+  ///
+  /// This is intended for immutable Iceberg manifest lists and manifests. 
Data files
+  /// and table metadata JSON should use NewInputFile or ReadFile directly.

Review Comment:
   The PR description says metadata JSON is included in the cache scope, but 
this doc comment explicitly says table metadata JSON should *not* go through 
the cached path, and the reviewed diffs only enable `cache_content` for 
manifests/manifest-lists. Either update the PR description to match the 
implemented scope, or update the implementation/docs so immutable metadata JSON 
reads also route through the cache as described.



##########
src/iceberg/arrow/arrow_io.cc:
##########
@@ -423,29 +424,46 @@ class ArrowInputFile : public InputFile {
   std::string_view location() const override { return location_; }
 
   Result<int64_t> Size() const override {
+    std::lock_guard lock(mutex_);
     if (file_size_.has_value()) {
       return *file_size_;
     }
     ::arrow::fs::FileInfo file_info(path_, ::arrow::fs::FileType::File);
     ICEBERG_ARROW_ASSIGN_OR_RETURN(auto input, fs_->OpenInputFile(file_info));
     ICEBERG_ARROW_ASSIGN_OR_RETURN(auto size, input->GetSize());
+    file_size_ = size;
+    pending_input_ = std::move(input);

Review Comment:
   This change holds an open `RandomAccessFile` in `pending_input_` after 
`Size()` is called. If callers frequently request sizes without subsequently 
calling `Open()` (or if `ArrowInputFile` objects live a long time), this can 
keep file descriptors open and increase FD/memory pressure. A safer approach is 
to avoid retaining the handle (store only `file_size_`), or retain it only 
under a narrowly-scoped workflow where `Open()` is guaranteed to follow 
immediately.



##########
src/iceberg/metadata_cache.cc:
##########
@@ -0,0 +1,375 @@
+/*
+ * 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/metadata_cache.h"
+
+#include <algorithm>
+#include <chrono>
+#include <condition_variable>
+#include <limits>
+#include <list>
+#include <mutex>
+#include <utility>
+
+#include "iceberg/util/macros.h"
+#include "iceberg/util/string_util.h"
+
+namespace iceberg {
+
+namespace {
+
+Result<bool> ParseBoolean(std::string_view key, const std::string& value) {
+  if (value == "true") {
+    return true;
+  }
+  if (value == "false") {
+    return false;
+  }
+  return InvalidArgument("Invalid boolean value '{}' for property {}", value, 
key);
+}

Review Comment:
   The PR description states these properties are Java-compatible, but 
`ParseBoolean` only accepts lowercase `true`/`false`. Java’s 
`Boolean.parseBoolean` treats values case-insensitively for `true` (and never 
throws), so configs like `TRUE`/`True` that work in Java will error here. 
Consider parsing booleans in a case-insensitive way (at minimum accepting 
`TRUE`/`True`/`FALSE`/`False`) to better match the promised compatibility.



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