nullccxsy commented on code in PR #180:
URL: https://github.com/apache/iceberg-cpp/pull/180#discussion_r2296178729
##########
src/iceberg/schema.h:
##########
@@ -54,13 +55,38 @@ class ICEBERG_EXPORT Schema : public StructType {
[[nodiscard]] std::string ToString() const override;
+ ///\brief Find thd SchemaField By field name
+ ///
+ /// Short names for maps and lists are included for any name that does not
conflict with
+ /// a canonical name. For example, a list, 'l', of structs with field 'x'
will produce
+ /// short name 'l.x' in addition to canonical name 'l.element.x'. a map 'm',
if its
+ /// value include a structs with field 'x' wil produce short name 'm.x' in
addition to
+ /// canonical name 'm.value.x'
+ [[nodiscard]] Result<std::optional<std::reference_wrapper<const
SchemaField>>>
+ FindFieldByName(std::string_view name, bool case_sensitive = true) const;
+
+ [[nodiscard]] Result<std::optional<std::reference_wrapper<const
SchemaField>>>
+ FindFieldById(int32_t field_id) const;
+
friend bool operator==(const Schema& lhs, const Schema& rhs) { return
lhs.Equals(rhs); }
+ private:
+ /// Mapping from field id to field.
+ mutable std::unordered_map<int32_t, std::reference_wrapper<const
SchemaField>>
+ id_to_field_;
+ /// Mapping from field name to field id.
+ mutable std::unordered_map<std::string, int32_t> name_to_id_;
+ /// Mapping from lowercased field name to field id
+ mutable std::unordered_map<std::string, int32_t> lowercase_name_to_id_;
+
private:
/// \brief Compare two schemas for equality.
[[nodiscard]] bool Equals(const Schema& other) const;
const std::optional<int32_t> schema_id_;
-};
+ Result<Status> InitIdToIndexMap() const;
+ Result<Status> InitNameToIndexMap() const;
+ Result<Status> InitLowerCaseNameToIndexMap() const;
Review Comment:
May name it `LazyIdToIndexMap` ?
--
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]