wgtmac commented on code in PR #257:
URL: https://github.com/apache/iceberg-cpp/pull/257#discussion_r2438415762


##########
src/iceberg/table_update.h:
##########
@@ -0,0 +1,358 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+/// \file iceberg/table_update.h
+/// Table metadata update operations for Iceberg tables.
+
+#include <memory>
+#include <optional>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "iceberg/iceberg_export.h"
+#include "iceberg/snapshot.h"
+#include "iceberg/type_fwd.h"
+
+namespace iceberg {
+
+/// \brief Base class for metadata update operations
+///
+/// Represents a change to table metadata. Each concrete subclass
+/// represents a specific type of update operation.
+class ICEBERG_EXPORT TableUpdate {
+ public:
+  virtual ~TableUpdate() = default;
+
+  /// \brief Apply this update to a TableMetadataBuilder
+  ///
+  /// This method modifies the builder by applying the update operation
+  /// it represents. Each subclass implements this to apply its specific
+  /// type of update.
+  ///
+  /// \param builder The builder to apply this update to
+  virtual void ApplyTo(TableMetadataBuilder& builder) const = 0;
+
+  /// \brief Generate update requirements for this metadata update
+  ///
+  /// This method generates the appropriate UpdateRequirement instances
+  /// that must be validated before this update can be applied. The context
+  /// provides information about the base metadata and operation mode.
+  ///
+  /// \param context The context containing base metadata and operation state
+  /// \return Status indicating success or failure with error details
+  virtual Status GenerateRequirements(TableUpdateContext& context) const = 0;
+};
+
+/// \brief Represents an assignment of a UUID to the table
+class ICEBERG_EXPORT AssignTableUUID : public TableUpdate {
+ public:
+  explicit AssignTableUUID(std::string uuid) : uuid_(std::move(uuid)) {}
+
+  const std::string& uuid() const { return uuid_; }
+
+  void ApplyTo(TableMetadataBuilder& builder) const override;
+
+  Status GenerateRequirements(TableUpdateContext& context) const override;
+
+ private:
+  std::string uuid_;
+};
+
+/// \brief Represents an upgrade of the table format version
+class ICEBERG_EXPORT UpgradeTableFormatVersion : public TableUpdate {
+ public:
+  explicit UpgradeTableFormatVersion(int8_t format_version)
+      : format_version_(format_version) {}
+
+  int8_t format_version() const { return format_version_; }
+
+  void ApplyTo(TableMetadataBuilder& builder) const override;
+
+  Status GenerateRequirements(TableUpdateContext& context) const override;
+
+ private:
+  int8_t format_version_;
+};
+
+/// \brief Represents adding a new schema to the table
+class ICEBERG_EXPORT AddTableSchema : public TableUpdate {
+ public:
+  explicit AddTableSchema(std::shared_ptr<Schema> schema, int32_t 
last_column_id)
+      : schema_(std::move(schema)), last_column_id_(last_column_id) {}
+
+  const std::shared_ptr<Schema>& schema() const { return schema_; }
+
+  int32_t last_column_id() const { return last_column_id_; }
+
+  void ApplyTo(TableMetadataBuilder& builder) const override;
+
+  Status GenerateRequirements(TableUpdateContext& context) const override;
+
+ private:
+  std::shared_ptr<Schema> schema_;
+  int32_t last_column_id_;
+};
+
+/// \brief Represents setting the current schema
+class ICEBERG_EXPORT SetCurrentTableSchema : public TableUpdate {

Review Comment:
   These names look a little bit weird. What about this?
   
   ```cpp
   class ICEBERG_EXPORT TableUpdate {
     // ...
   };
   
   namespace table {
   
   class ICEBERG_EXPORT AssignUUID : public TableUpdate {
     // ...
   };
   
   class ICEBERG_EXPORT UpgradeFormatVersion : public TableUpdate {
     // ...
   };
   
   }  // namespace table
   ```



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