3030
3131namespace iceberg {
3232
33- Result<std::optional<SchemaFieldConstRef>> NestedType::GetFieldByName (
33+ Result<std::optional<NestedType:: SchemaFieldConstRef>> NestedType::GetFieldByName (
3434 std::string_view name) const {
3535 return GetFieldByName (name, /* case_sensitive=*/ true );
3636}
@@ -48,21 +48,21 @@ std::string StructType::ToString() const {
4848 return repr;
4949}
5050std::span<const SchemaField> StructType::fields () const { return fields_; }
51- Result<std::optional<SchemaFieldConstRef>> StructType::GetFieldById (
51+ Result<std::optional<NestedType:: SchemaFieldConstRef>> StructType::GetFieldById (
5252 int32_t field_id) const {
5353 ICEBERG_RETURN_UNEXPECTED (InitFieldById ());
5454 auto it = field_by_id_.find (field_id);
5555 if (it == field_by_id_.end ()) return std::nullopt ;
5656 return it->second ;
5757}
58- Result<std::optional<SchemaFieldConstRef>> StructType::GetFieldByIndex (
58+ Result<std::optional<NestedType:: SchemaFieldConstRef>> StructType::GetFieldByIndex (
5959 int32_t index) const {
6060 if (index < 0 || static_cast <size_t >(index) >= fields_.size ()) {
61- return InvalidArgument (" index {} is out of range[0, {}) " , index, fields_. size () );
61+ return InvalidArgument (" Invalid index {} to get field from struct " , index);
6262 }
6363 return fields_[index];
6464}
65- Result<std::optional<SchemaFieldConstRef>> StructType::GetFieldByName (
65+ Result<std::optional<NestedType:: SchemaFieldConstRef>> StructType::GetFieldByName (
6666 std::string_view name, bool case_sensitive) const {
6767 if (case_sensitive) {
6868 ICEBERG_RETURN_UNEXPECTED (InitFieldByName ());
@@ -149,20 +149,21 @@ std::string ListType::ToString() const {
149149 return repr;
150150}
151151std::span<const SchemaField> ListType::fields () const { return {&element_, 1 }; }
152- Result<std::optional<SchemaFieldConstRef>> ListType::GetFieldById (
152+ Result<std::optional<NestedType:: SchemaFieldConstRef>> ListType::GetFieldById (
153153 int32_t field_id) const {
154154 if (field_id == element_.field_id ()) {
155155 return std::cref (element_);
156156 }
157157 return std::nullopt ;
158158}
159- Result<std::optional<SchemaFieldConstRef>> ListType::GetFieldByIndex (int index) const {
159+ Result<std::optional<NestedType::SchemaFieldConstRef>> ListType::GetFieldByIndex (
160+ int index) const {
160161 if (index == 0 ) {
161162 return std::cref (element_);
162163 }
163- return InvalidArgument (" index {} is out of range[0, {}) " , index, 1 );
164+ return InvalidArgument (" Invalid index {} to get field from list " , index);
164165}
165- Result<std::optional<SchemaFieldConstRef>> ListType::GetFieldByName (
166+ Result<std::optional<NestedType:: SchemaFieldConstRef>> ListType::GetFieldByName (
166167 std::string_view name, bool case_sensitive) const {
167168 if (case_sensitive) {
168169 if (name == kElementName ) {
@@ -208,23 +209,25 @@ std::string MapType::ToString() const {
208209 return repr;
209210}
210211std::span<const SchemaField> MapType::fields () const { return fields_; }
211- Result<std::optional<SchemaFieldConstRef>> MapType::GetFieldById (int32_t field_id) const {
212+ Result<std::optional<NestedType::SchemaFieldConstRef>> MapType::GetFieldById (
213+ int32_t field_id) const {
212214 if (field_id == key ().field_id ()) {
213215 return key ();
214216 } else if (field_id == value ().field_id ()) {
215217 return value ();
216218 }
217219 return std::nullopt ;
218220}
219- Result<std::optional<SchemaFieldConstRef>> MapType::GetFieldByIndex (int32_t index) const {
221+ Result<std::optional<NestedType::SchemaFieldConstRef>> MapType::GetFieldByIndex (
222+ int32_t index) const {
220223 if (index == 0 ) {
221224 return key ();
222225 } else if (index == 1 ) {
223226 return value ();
224227 }
225- return InvalidArgument (" index {} is out of range[0, {}) " , index, 2 );
228+ return InvalidArgument (" Invalid index {} to get field from map " , index);
226229}
227- Result<std::optional<SchemaFieldConstRef>> MapType::GetFieldByName (
230+ Result<std::optional<NestedType:: SchemaFieldConstRef>> MapType::GetFieldByName (
228231 std::string_view name, bool case_sensitive) const {
229232 if (case_sensitive) {
230233 if (name == kKeyName ) {
@@ -234,9 +237,10 @@ Result<std::optional<SchemaFieldConstRef>> MapType::GetFieldByName(
234237 }
235238 return std::nullopt ;
236239 }
237- if (StringUtils::ToLower (name) == kKeyName ) {
240+ const auto lower_case_name = StringUtils::ToLower (name);
241+ if (lower_case_name == kKeyName ) {
238242 return key ();
239- } else if (StringUtils::ToLower (name) == kValueName ) {
243+ } else if (lower_case_name == kValueName ) {
240244 return value ();
241245 }
242246 return std::nullopt ;
0 commit comments