mapleFU commented on code in PR #180:
URL: https://github.com/apache/iceberg-cpp/pull/180#discussion_r2302731017


##########
src/iceberg/schema.cc:
##########
@@ -19,13 +19,56 @@
 
 #include "iceberg/schema.h"
 
+#include <algorithm>
 #include <format>
+#include <functional>
 
 #include "iceberg/type.h"
 #include "iceberg/util/formatter.h"  // IWYU pragma: keep
+#include "iceberg/util/macros.h"
+#include "iceberg/util/string_utils.h"
+#include "iceberg/util/visit_type.h"
 
 namespace iceberg {
 
+class IdToFieldVisitor {
+ public:
+  explicit IdToFieldVisitor(
+      std::unordered_map<int32_t, std::reference_wrapper<const SchemaField>>&
+          id_to_field);
+  Status Visit(const Type& type);
+  Status VisitNestedType(const Type& type);
+
+ private:
+  std::unordered_map<int32_t, std::reference_wrapper<const SchemaField>>& 
id_to_field_;
+};
+
+class NameToIdVisitor {
+ public:
+  explicit NameToIdVisitor(
+      std::unordered_map<std::string, int32_t>& name_to_id, bool 
case_sensitive = true,
+      std::function<std::string(std::string_view)> quoting_func = {});

Review Comment:
   Ever used?



##########
src/iceberg/schema.cc:
##########
@@ -44,4 +87,181 @@ bool Schema::Equals(const Schema& other) const {
   return schema_id_ == other.schema_id_ && fields_ == other.fields_;
 }
 
+Result<std::optional<std::reference_wrapper<const SchemaField>>> 
Schema::FindFieldByName(
+    std::string_view name, bool case_sensitive) const {
+  if (case_sensitive) {
+    ICEBERG_RETURN_UNEXPECTED(InitNameToIdMap());
+    auto it = name_to_id_.find(std::string(name));

Review Comment:
   I remeber we can construct a transparent lookup rather than build an 
std::string



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