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


##########
src/iceberg/metadata_cache.cc:
##########
@@ -0,0 +1,341 @@
+/*
+ * 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);
+}
+
+template <typename T>
+Result<T> ParseNumberProperty(
+    const std::unordered_map<std::string, std::string>& properties, 
std::string_view key,
+    T default_value) {
+  auto it = properties.find(std::string(key));
+  if (it == properties.end()) {
+    return default_value;
+  }
+  return StringUtils::ParseNumber<T>(it->second);
+}

Review Comment:
   `ParseNumberProperty()` forwards `StringUtils::ParseNumber()` errors 
directly, which produces messages that don’t identify which property key failed 
to parse. Since these are user-facing catalog/FileIO properties, it’s much 
easier to debug misconfiguration if the error includes the property name.



##########
src/iceberg/file_io_registry.cc:
##########
@@ -57,7 +59,10 @@ Result<std::unique_ptr<FileIO>> FileIORegistry::Load(
     }
     factory = it->second;
   }
-  return factory(properties);
+  ICEBERG_ASSIGN_OR_RAISE(auto io, factory(properties));
+  ICEBERG_PRECHECK(io != nullptr, "FileIO factory returned null for {}", name);
+  ICEBERG_RETURN_UNEXPECTED(io->ConfigureMetadataCache(properties));
+  return io;

Review Comment:
   `FileIORegistry::Load()` always calls `ConfigureMetadataCache(properties)`. 
When `properties` does not include any cache-related keys, this still installs 
a disabled cache instance and makes later attempts to enable caching fail as a 
“conflicting reconfiguration” (because configuration becomes immutable after 
the first call). Consider only configuring the cache when at least one cache 
property is explicitly provided, matching the guards used in catalog code paths.



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