yuguotao commented on code in PR #47:
URL: https://github.com/apache/iceberg-cpp/pull/47#discussion_r2012260699


##########
src/iceberg/catalog.h:
##########
@@ -0,0 +1,194 @@
+/*
+ * 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
+
+#include <map>
+#include <memory>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "iceberg/error.h"
+#include "iceberg/expected.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/type_fwd.h"
+
+namespace iceberg {
+
+/// \brief A Catalog API for table create, drop, and load operations.
+///
+/// Note that these functions are named after the corresponding operationId
+/// specified by the Iceberg Rest Catalog API.
+class ICEBERG_EXPORT Catalog {
+ public:
+  virtual ~Catalog() = default;
+
+  /// \brief Return the name for this catalog
+  virtual std::string_view name() const = 0;
+
+  /// \brief Return all the identifiers under this namespace
+  ///
+  /// \param ns a namespace
+  /// \return a list of identifiers for tables or ErrorKind::kNoSuchNamespace
+  /// if the namespace does not exist
+  virtual expected<std::vector<TableIdentifier>, Error> ListTables(

Review Comment:
   should std::unique_ptr<std::vector<TableIdentifier>> be used 
    instead of std::vector<TableIdentifier>  to avoid copying ?



##########
src/iceberg/transaction.h:
##########
@@ -0,0 +1,53 @@
+
+/*
+ * 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
+
+#include <memory>
+
+#include "iceberg/iceberg_export.h"
+#include "iceberg/type_fwd.h"
+
+namespace iceberg {
+
+/// \brief A transaction for performing multiple updates to a table
+class ICEBERG_EXPORT Transaction {
+ public:
+  virtual ~Transaction() = default;
+
+  /// \brief Return the Table that this transaction will update
+  ///
+  /// \return this transaction's table
+  virtual const std::shared_ptr<Table>& table() const = 0;
+
+  /// \brief Create a new append API to add files to this table
+  ///
+  /// \return a new AppendFiles
+  virtual std::shared_ptr<AppendFiles> NewAppend() = 0;
+
+  /// \brief Apply the pending changes from all actions and commit
+  ///
+  /// May throw ValidationException if any update cannot be applied to the 
current table
+  /// metadata. May throw CommitFailedException if the updates cannot be 
committed due to
+  /// conflicts.
+  virtual void CommitTransaction() = 0;

Review Comment:
   Abort or rollback is automatically called when a commit fails ?



##########
src/iceberg/table.h:
##########
@@ -19,17 +19,93 @@
 
 #pragma once
 
+#include <map>
+#include <memory>
 #include <string>
+#include <vector>
 
+#include "iceberg/error.h"
+#include "iceberg/expected.h"
 #include "iceberg/iceberg_export.h"
+#include "iceberg/type_fwd.h"
 
 namespace iceberg {
 
-/// \brief The metadata of an Iceberg table.
+/// \brief Represents an Iceberg table
 class ICEBERG_EXPORT Table {
  public:
   virtual ~Table() = default;
-  virtual std::string print() const = 0;
+
+  /// \brief Return the full name for this table
+  virtual const std::string& name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual const std::string& uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual expected<void, Error> Refresh() = 0;
+
+  /// \brief Return the schema for this table
+  virtual const std::shared_ptr<Schema>& schema() const = 0;
+
+  /// \brief Return a map of schema for this table
+  virtual const std::map<int32_t, std::shared_ptr<Schema>>& schemas() const = 
0;
+
+  /// \brief Return the partition spec for this table
+  virtual const std::shared_ptr<PartitionSpec>& spec() const = 0;
+
+  /// \brief Return a map of partition specs for this table
+  virtual const std::map<int32_t, std::shared_ptr<PartitionSpec>>& specs() 
const = 0;
+
+  /// \brief Return the sort order for this table
+  virtual const std::shared_ptr<SortOrder>& sort_order() const = 0;
+
+  /// \brief Return a map of sort order IDs to sort orders for this table
+  virtual const std::map<int32_t, std::shared_ptr<SortOrder>>& sort_orders() 
const = 0;
+
+  /// \brief Return a map of string properties for this table
+  virtual const std::map<std::string, std::string>& properties() const = 0;
+
+  /// \brief Return the table's base location
+  virtual const std::string& location() const = 0;
+
+  /// \brief Return the table's current snapshot
+  virtual const std::shared_ptr<Snapshot>& current_snapshot() const = 0;
+
+  /// \brief Get the snapshot of this table with the given id, or null if 
there is no
+  /// matching snapshot
+  ///
+  /// \param snapshot_id the ID of the snapshot to get
+  /// \return the Snapshot with the given id
+  virtual expected<std::shared_ptr<Snapshot>, Error> snapshot(
+      int64_t snapshot_id) const = 0;
+
+  /// \brief Get the snapshots of this table
+  virtual const std::vector<std::shared_ptr<Snapshot>>& snapshots() const = 0;
+
+  /// \brief Get the snapshot history of this table
+  ///
+  /// \return a vector of history entries
+  virtual const std::vector<std::shared_ptr<HistoryEntry>>& history() const = 
0;

Review Comment:
   Enumerator or Iterator  here too ?



##########
src/iceberg/catalog.h:
##########
@@ -0,0 +1,194 @@
+/*
+ * 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
+
+#include <map>
+#include <memory>
+#include <string>
+#include <string_view>
+#include <vector>
+
+#include "iceberg/error.h"
+#include "iceberg/expected.h"
+#include "iceberg/table_identifier.h"
+#include "iceberg/type_fwd.h"
+
+namespace iceberg {
+
+/// \brief A Catalog API for table create, drop, and load operations.
+///
+/// Note that these functions are named after the corresponding operationId
+/// specified by the Iceberg Rest Catalog API.
+class ICEBERG_EXPORT Catalog {
+ public:
+  virtual ~Catalog() = default;
+
+  /// \brief Return the name for this catalog
+  virtual std::string_view name() const = 0;
+
+  /// \brief Return all the identifiers under this namespace
+  ///
+  /// \param ns a namespace
+  /// \return a list of identifiers for tables or ErrorKind::kNoSuchNamespace
+  /// if the namespace does not exist
+  virtual expected<std::vector<TableIdentifier>, Error> ListTables(

Review Comment:
   We can forward declare TableIdentifierList / TableIdentifierListPtr.



##########
src/iceberg/table.h:
##########
@@ -19,17 +19,93 @@
 
 #pragma once
 
+#include <map>
+#include <memory>
 #include <string>
+#include <vector>
 
+#include "iceberg/error.h"
+#include "iceberg/expected.h"
 #include "iceberg/iceberg_export.h"
+#include "iceberg/type_fwd.h"
 
 namespace iceberg {
 
-/// \brief The metadata of an Iceberg table.
+/// \brief Represents an Iceberg table
 class ICEBERG_EXPORT Table {
  public:
   virtual ~Table() = default;
-  virtual std::string print() const = 0;
+
+  /// \brief Return the full name for this table
+  virtual const std::string& name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual const std::string& uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual expected<void, Error> Refresh() = 0;
+
+  /// \brief Return the schema for this table
+  virtual const std::shared_ptr<Schema>& schema() const = 0;
+
+  /// \brief Return a map of schema for this table
+  virtual const std::map<int32_t, std::shared_ptr<Schema>>& schemas() const = 
0;
+
+  /// \brief Return the partition spec for this table
+  virtual const std::shared_ptr<PartitionSpec>& spec() const = 0;
+
+  /// \brief Return a map of partition specs for this table
+  virtual const std::map<int32_t, std::shared_ptr<PartitionSpec>>& specs() 
const = 0;
+
+  /// \brief Return the sort order for this table
+  virtual const std::shared_ptr<SortOrder>& sort_order() const = 0;
+
+  /// \brief Return a map of sort order IDs to sort orders for this table
+  virtual const std::map<int32_t, std::shared_ptr<SortOrder>>& sort_orders() 
const = 0;
+
+  /// \brief Return a map of string properties for this table
+  virtual const std::map<std::string, std::string>& properties() const = 0;
+
+  /// \brief Return the table's base location
+  virtual const std::string& location() const = 0;
+
+  /// \brief Return the table's current snapshot
+  virtual const std::shared_ptr<Snapshot>& current_snapshot() const = 0;
+
+  /// \brief Get the snapshot of this table with the given id, or null if 
there is no
+  /// matching snapshot
+  ///
+  /// \param snapshot_id the ID of the snapshot to get
+  /// \return the Snapshot with the given id
+  virtual expected<std::shared_ptr<Snapshot>, Error> snapshot(
+      int64_t snapshot_id) const = 0;
+
+  /// \brief Get the snapshots of this table
+  virtual const std::vector<std::shared_ptr<Snapshot>>& snapshots() const = 0;

Review Comment:
   Should we return an Enumerator or Iterator type if there are too many 
snapshots?



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to