zhjwpku commented on code in PR #1178:
URL: https://github.com/apache/iceberg-cpp/pull/1178#discussion_r4721417230


##########
src/iceberg/update/update_schema.cc:
##########
@@ -225,61 +227,41 @@ class ApplyChangesVisitor {
   }
 
   /// \brief Helper function to apply move operations to a list of fields
-  static std::vector<SchemaField> MoveFields(
-      std::vector<SchemaField>&& fields, const 
std::vector<UpdateSchema::Move>& moves);
+  static Result<std::vector<SchemaField>> MoveFields(
+      std::vector<SchemaField> fields, const std::vector<UpdateSchema::Move>& 
moves);
 
   const std::unordered_set<int32_t>& deletes_;
   const std::unordered_map<int32_t, std::shared_ptr<SchemaField>>& updates_;
   const std::unordered_map<int32_t, std::vector<int32_t>>& 
parent_to_added_ids_;
   const std::unordered_map<int32_t, std::vector<UpdateSchema::Move>>& moves_;
 };
 
-std::vector<SchemaField> ApplyChangesVisitor::MoveFields(
-    std::vector<SchemaField>&& fields, const std::vector<UpdateSchema::Move>& 
moves) {
-  std::vector<SchemaField> reordered = std::move(fields);
-
+Result<std::vector<SchemaField>> ApplyChangesVisitor::MoveFields(
+    std::vector<SchemaField> fields, const std::vector<UpdateSchema::Move>& 
moves) {
   for (const auto& move : moves) {
-    auto it = std::ranges::find_if(reordered, [&move](const SchemaField& 
field) {
-      return field.field_id() == move.field_id;
-    });
-
-    if (it == reordered.end()) {
-      continue;

Review Comment:
   Could we keep the existing switch and return a validation error whenever a 
lookup fails, both here and in the BEFORE and AFTER branches? That would match 
Java's behavior with a smaller diff. Not a strong opinion though.



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