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


##########
src/iceberg/table.h:
##########
@@ -19,17 +19,91 @@
 
 #pragma once
 
+#include <map>
 #include <string>
+#include <vector>
 
+#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 std::string name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual std::string uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual void Refresh() = 0;

Review Comment:
   Hmm, do we want a table to be able to do I/O, or should it effectively be a 
POD (albeit not actually a POD)?



##########
src/iceberg/table_identifier.h:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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_identifier.h
+/// A TableIdentifier is a unique identifier for a table
+
+#include <string>
+#include <vector>
+
+#include "iceberg/iceberg_export.h"
+
+namespace iceberg {
+
+/// \brief A namespace in a catalog.
+struct ICEBERG_EXPORT Namespace {
+  std::vector<std::string> levels;
+};
+
+/// \brief Identifies a table in iceberg catalog.
+struct ICEBERG_EXPORT TableIdentifier {
+  Namespace name_space;

Review Comment:
   `name_space` -> `namespace`?



##########
src/iceberg/table.h:
##########
@@ -19,17 +19,91 @@
 
 #pragma once
 
+#include <map>
 #include <string>
+#include <vector>
 
+#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 std::string name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual std::string uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual void 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 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 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 std::map<int32_t, std::shared_ptr<SortOrder>> sort_orders() const = 
0;
+
+  /// \brief Return a map of string properties for this table
+  virtual std::map<std::string, std::string> properties() const = 0;
+
+  /// \brief Return the table's base location
+  virtual 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 std::vector<std::shared_ptr<Snapshot>> snapshots() const = 0;
+
+  /// \brief Get the snapshot history of this table
+  ///
+  /// \return a vector of history entries
+  virtual std::vector<std::shared_ptr<HistoryEntry>> history() const = 0;
+
+  /// \brief Create a new table scan for this table
+  ///
+  /// Once a table scan is created, it can be refined to project columns and 
filter data.
+  virtual std::shared_ptr<TableScan> NewScan() const = 0;

Review Comment:
   I feel like this can be unique_ptr?



##########
src/iceberg/table.h:
##########
@@ -19,17 +19,91 @@
 
 #pragma once
 
+#include <map>
 #include <string>
+#include <vector>
 
+#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 std::string name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual std::string uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual void 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 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 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 std::map<int32_t, std::shared_ptr<SortOrder>> sort_orders() const = 
0;
+
+  /// \brief Return a map of string properties for this table
+  virtual std::map<std::string, std::string> properties() const = 0;

Review Comment:
   maybe `map const&`?



##########
src/iceberg/table.h:
##########
@@ -19,17 +19,91 @@
 
 #pragma once
 
+#include <map>
 #include <string>
+#include <vector>
 
+#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 std::string name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual std::string uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual void 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 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 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 std::map<int32_t, std::shared_ptr<SortOrder>> sort_orders() const = 
0;
+
+  /// \brief Return a map of string properties for this table
+  virtual std::map<std::string, std::string> properties() const = 0;
+
+  /// \brief Return the table's base location
+  virtual std::string location() const = 0;

Review Comment:
   maybe `string const&`?



##########
src/iceberg/table.h:
##########
@@ -19,17 +19,91 @@
 
 #pragma once
 
+#include <map>
 #include <string>
+#include <vector>
 
+#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 std::string name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual std::string uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual void 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 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 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 std::map<int32_t, std::shared_ptr<SortOrder>> sort_orders() const = 
0;
+
+  /// \brief Return a map of string properties for this table
+  virtual std::map<std::string, std::string> properties() const = 0;
+
+  /// \brief Return the table's base location
+  virtual 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 std::vector<std::shared_ptr<Snapshot>> snapshots() const = 0;
+
+  /// \brief Get the snapshot history of this table
+  ///
+  /// \return a vector of history entries
+  virtual std::vector<std::shared_ptr<HistoryEntry>> history() const = 0;
+
+  /// \brief Create a new table scan for this table
+  ///
+  /// Once a table scan is created, it can be refined to project columns and 
filter data.
+  virtual std::shared_ptr<TableScan> NewScan() const = 0;
+
+  /// \brief Create a new append API to add files to this table and commit
+  virtual std::shared_ptr<AppendFiles> NewAppend() = 0;

Review Comment:
   Why are some of these shared_ptr and some of these unique_ptr? It feels like 
AppendFiles and Transaction are morally the same kind of operation?



##########
src/iceberg/type_fwd.h:
##########
@@ -81,4 +81,36 @@ class TimestampTzType;
 class Type;
 class UuidType;
 
+/// \brief Error types for iceberg.
+/// TODO: add more and sort them based on some rules.
+enum class Error {

Review Comment:
   nit: maybe ErrorKind, ErrorType?



##########
src/iceberg/table.h:
##########
@@ -19,17 +19,91 @@
 
 #pragma once
 
+#include <map>
 #include <string>
+#include <vector>
 
+#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 std::string name() const = 0;
+
+  /// \brief Returns the UUID of the table
+  virtual std::string uuid() const = 0;
+
+  /// \brief Refresh the current table metadata
+  virtual void 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 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 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 std::map<int32_t, std::shared_ptr<SortOrder>> sort_orders() const = 
0;
+
+  /// \brief Return a map of string properties for this table
+  virtual std::map<std::string, std::string> properties() const = 0;
+
+  /// \brief Return the table's base location
+  virtual std::string location() const = 0;

Review Comment:
   (ditto for various others)



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