HuaHuaY commented on code in PR #418:
URL: https://github.com/apache/iceberg-cpp/pull/418#discussion_r2629362279


##########
src/iceberg/transaction.cc:
##########
@@ -0,0 +1,111 @@
+
+/*
+ * 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.
+ */
+#include "iceberg/transaction.h"
+
+#include "iceberg/catalog.h"
+#include "iceberg/table.h"
+#include "iceberg/table_metadata.h"
+#include "iceberg/table_requirement.h"
+#include "iceberg/table_requirements.h"
+#include "iceberg/table_update.h"
+#include "iceberg/update/update_properties.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+Transaction::Transaction(std::shared_ptr<Table> table, Kind kind, bool 
auto_commit)
+    : table_(std::move(table)),
+      kind_(kind),
+      auto_commit_(auto_commit),
+      
metadata_builder_(TableMetadataBuilder::BuildFrom(table_->metadata().get())) {}
+
+Transaction::~Transaction() = default;
+
+Result<std::shared_ptr<Transaction>> Transaction::Make(std::shared_ptr<Table> 
table,
+                                                       Kind kind, bool 
auto_commit) {
+  if (!table || !table->catalog()) [[unlikely]] {
+    return InvalidArgument("Table and catalog cannot be null");
+  }
+  return std::shared_ptr<Transaction>(
+      new Transaction(std::move(table), kind, auto_commit));

Review Comment:
   ```suggestion
     return std::make_shared<Transaction>(std::move(table), kind, auto_commit);
   ```



##########
src/iceberg/table.cc:
##########
@@ -21,16 +21,40 @@
 
 #include "iceberg/catalog.h"
 #include "iceberg/partition_spec.h"
+#include "iceberg/result.h"
 #include "iceberg/schema.h"
 #include "iceberg/sort_order.h"
 #include "iceberg/table_metadata.h"
 #include "iceberg/table_properties.h"
 #include "iceberg/table_scan.h"
+#include "iceberg/transaction.h"
 #include "iceberg/update/update_properties.h"
 #include "iceberg/util/macros.h"
 
 namespace iceberg {
 
+Result<std::shared_ptr<Table>> Table::Make(TableIdentifier identifier,
+                                           std::shared_ptr<TableMetadata> 
metadata,
+                                           std::string metadata_location,
+                                           std::shared_ptr<FileIO> io,
+                                           std::shared_ptr<Catalog> catalog) {
+  if (metadata == nullptr) [[unlikely]] {
+    return InvalidArgument("Metadata cannot be null");
+  }
+  if (metadata_location.empty()) [[unlikely]] {
+    return InvalidArgument("Metadata location cannot be empty");
+  }
+  if (io == nullptr) [[unlikely]] {
+    return InvalidArgument("FileIO cannot be null");
+  }
+  if (catalog == nullptr) [[unlikely]] {
+    return InvalidArgument("Catalog cannot be null");
+  }
+  return std::shared_ptr<Table>(new Table(std::move(identifier), 
std::move(metadata),
+                                          std::move(metadata_location), 
std::move(io),
+                                          std::move(catalog)));

Review Comment:
   ```suggestion
     return std::make_shared<Table>(std::move(identifier), std::move(metadata),
                                    std::move(metadata_location), std::move(io),
                                    std::move(catalog));
   ```



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